ld: implement support for exposing ld functions to loaded executables
This commit is contained in:
+20
-13
@@ -2,15 +2,16 @@
|
||||
#define MSG_NO_MALLOC
|
||||
|
||||
#include "elf.h"
|
||||
#include "self.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <heap/heap.h>
|
||||
#include <mango/log.h>
|
||||
#include <mango/msg.h>
|
||||
#include <mango/task.h>
|
||||
#include <mango/types.h>
|
||||
#include <mango/vm.h>
|
||||
#include <magenta/log.h>
|
||||
#include <magenta/msg.h>
|
||||
#include <magenta/task.h>
|
||||
#include <magenta/types.h>
|
||||
#include <magenta/vm.h>
|
||||
#include <rosetta/bootstrap.h>
|
||||
#include <rosetta/fs.h>
|
||||
#include <stdarg.h>
|
||||
@@ -101,7 +102,7 @@ static int load_images(const char *task_name, struct image_list *list)
|
||||
report_error(
|
||||
task_name,
|
||||
status,
|
||||
"error while loading %s",
|
||||
"C error while loading %s",
|
||||
image->e_leaf.l_name);
|
||||
return status;
|
||||
}
|
||||
@@ -112,7 +113,7 @@ static int load_images(const char *task_name, struct image_list *list)
|
||||
report_error(
|
||||
task_name,
|
||||
status,
|
||||
"error while loading %s",
|
||||
"B error while loading %s",
|
||||
image->e_leaf.l_name);
|
||||
return status;
|
||||
}
|
||||
@@ -123,8 +124,8 @@ static int load_images(const char *task_name, struct image_list *list)
|
||||
report_error(
|
||||
task_name,
|
||||
status,
|
||||
"error while loading %s",
|
||||
image->e_leaf.l_name);
|
||||
"A error while loading %s",
|
||||
image);
|
||||
return status;
|
||||
}
|
||||
case ELF_IMAGE_LOADED:
|
||||
@@ -139,7 +140,7 @@ static int load_images(const char *task_name, struct image_list *list)
|
||||
report_error(
|
||||
task_name,
|
||||
-new_dependencies,
|
||||
"error while loading %s",
|
||||
"F error while loading %s",
|
||||
image->e_leaf.l_name);
|
||||
return -new_dependencies;
|
||||
}
|
||||
@@ -174,7 +175,7 @@ static int link_images(const char *task_name, struct image_list *list)
|
||||
report_error(
|
||||
task_name,
|
||||
status,
|
||||
"error while loading %s",
|
||||
"E error while loading %s",
|
||||
image->e_leaf.l_name);
|
||||
return status;
|
||||
}
|
||||
@@ -221,6 +222,9 @@ int main(const struct rosetta_bootstrap *bs)
|
||||
const char *task_name = bs->bs_argv[2];
|
||||
const char *image_name = get_image_name(exec_path);
|
||||
|
||||
kern_tracef("ld: exec_path=%s", exec_path);
|
||||
kern_tracef("ld: task_name=%s", task_name);
|
||||
|
||||
image_list_init(&images);
|
||||
|
||||
struct elf_image *exec = NULL;
|
||||
@@ -229,7 +233,7 @@ int main(const struct rosetta_bootstrap *bs)
|
||||
report_error(
|
||||
task_name,
|
||||
err,
|
||||
"error while loading %s",
|
||||
"D error while loading %s",
|
||||
exec_path);
|
||||
return -1;
|
||||
}
|
||||
@@ -251,6 +255,9 @@ int main(const struct rosetta_bootstrap *bs)
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct elf_image *self = get_self();
|
||||
image_list_put(&images, &self->e_leaf);
|
||||
|
||||
struct image_list_iterator it;
|
||||
image_list_iterator_begin(&it, &images);
|
||||
|
||||
@@ -265,7 +272,7 @@ int main(const struct rosetta_bootstrap *bs)
|
||||
image_list_iterator_move_next(&it);
|
||||
}
|
||||
|
||||
dump_loaded_images(&images);
|
||||
// dump_loaded_images(&images);
|
||||
kern_tracef("ld finished");
|
||||
struct rosetta_bootstrap exec_bsinfo;
|
||||
memcpy(&exec_bsinfo, bs, sizeof exec_bsinfo);
|
||||
|
||||
Reference in New Issue
Block a user