changeset 6:c8c435a06d13

Support loading the host loader and its prereqs with libhost_.so
author Gregor Richards <Richards@codu.org>
date Mon, 14 Dec 2009 10:51:51 -0500
parents 6b8e05507b18
children 02ad5f8614e8
files elfload/src/elfload.c
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/elfload/src/elfload.c	Sun Dec 13 19:28:20 2009 -0500
+++ b/elfload/src/elfload.c	Mon Dec 14 10:51:51 2009 -0500
@@ -58,7 +58,12 @@
     if (strncmp(nm, "libhost_", 8) == 0) {
         f->hostlib = HOSTLIB_HOST;
 #if defined(HAVE_DLFCN_H)
-        f->prog = dlopen(nm + 8, RTLD_NOW|RTLD_GLOBAL);
+        if (strcmp(nm, "libhost_.so") == 0) {
+            /* the entire host */
+            f->prog = dlopen(NULL, RTLD_NOW|RTLD_GLOBAL);
+        } else {
+            f->prog = dlopen(nm + 8, RTLD_NOW|RTLD_GLOBAL);
+        }
         if (f->prog == NULL) {
             fprintf(stderr, "Could not resolve host library %s.\n", nm + 8);
             exit(1);
@@ -102,7 +107,7 @@
     /* only native-bit supported for the moment */
     if ((SIZEOF_VOID_P == 4 && f->ehdr->e_ident[EI_CLASS] != ELFCLASS32) ||
         (SIZEOF_VOID_P == 8 && f->ehdr->e_ident[EI_CLASS] != ELFCLASS64)) {
-        fprintf(stderr, "%s is not a %d-bit ELF file.\n", SIZEOF_VOID_P * 8, nm);
+        fprintf(stderr, "%s is not a %d-bit ELF file.\n", nm, SIZEOF_VOID_P * 8);
         exit(1);
     }