From b466954d4e6ffa78f98b19458bcf1560d8d8c776 Mon Sep 17 00:00:00 2001 From: mdodd Date: Wed, 18 Jun 2003 03:34:29 +0000 Subject: - Add support for DT_FLAGS. - Define various things from the most recent ELF spec. --- libexec/rtld-elf/map_object.c | 1 + libexec/rtld-elf/rtld.c | 19 ++++++++++++++++++- libexec/rtld-elf/rtld.h | 2 ++ 3 files changed, 21 insertions(+), 1 deletion(-) (limited to 'libexec') diff --git a/libexec/rtld-elf/map_object.c b/libexec/rtld-elf/map_object.c index 5dc6b8c..7ad9dc5 100644 --- a/libexec/rtld-elf/map_object.c +++ b/libexec/rtld-elf/map_object.c @@ -309,6 +309,7 @@ obj_free(Obj_Entry *obj) STAILQ_REMOVE_HEAD(&obj->dagmembers, link); free(elm); } + free(obj->origin_path); free(obj->priv); free(obj); } diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index ab40371..0dea9e6 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -602,6 +602,7 @@ digest_dynamic(Obj_Entry *obj, int early) break; case DT_RPATH: + case DT_RUNPATH: /* XXX: process separately */ /* * We have to wait until later to process this, because we * might not have gotten the address of the string table yet. @@ -628,6 +629,22 @@ digest_dynamic(Obj_Entry *obj, int early) ((Elf_Dyn*)dynp)->d_un.d_ptr = (Elf_Addr) &r_debug; break; + case DT_FLAGS: + if (dynp->d_un.d_val & DF_ORIGIN) { + obj->origin_path = xmalloc(PATH_MAX); + if (rtld_dirname(obj->path, obj->origin_path) == -1) + die(); + } + if (dynp->d_un.d_val & DF_SYMBOLIC) + obj->symbolic = true; + if (dynp->d_un.d_val & DF_TEXTREL) + obj->textrel = true; + if (dynp->d_un.d_val & DF_BIND_NOW) + obj->bind_now = true; + if (dynp->d_un.d_val & DF_STATIC_TLS) + ; + break; + default: if (!early) { dbg("Ignoring d_tag %ld = %#lx", (long)dynp->d_tag, @@ -1401,7 +1418,7 @@ relocate_objects(Obj_Entry *first, bool bind_now, Obj_Entry *rtldobj) if (reloc_plt(obj) == -1) return -1; /* Relocate the jump slots if we are doing immediate binding. */ - if (bind_now) + if (obj->bind_now || bind_now) if (reloc_jmpslots(obj) == -1) return -1; diff --git a/libexec/rtld-elf/rtld.h b/libexec/rtld-elf/rtld.h index 21a03c8..c145fa1 100644 --- a/libexec/rtld-elf/rtld.h +++ b/libexec/rtld-elf/rtld.h @@ -109,6 +109,7 @@ typedef struct Struct_Obj_Entry { struct Struct_Obj_Entry *next; char *path; /* Pathname of underlying file (%) */ + char *origin_path; /* Directory path of origin file */ int refcount; int dl_refcount; /* Number of times loaded by dlopen */ @@ -153,6 +154,7 @@ typedef struct Struct_Obj_Entry { bool rtld; /* True if this is the dynamic linker */ bool textrel; /* True if there are relocations to text seg */ bool symbolic; /* True if generated with "-Bsymbolic" */ + bool bind_now; /* True if all relocations should be made first */ bool traced; /* Already printed in ldd trace output */ bool jmpslots_done; /* Already have relocated the jump slots */ bool init_done; /* Already have added object to init list */ -- cgit v1.1