summaryrefslogtreecommitdiffstats
path: root/libexec/rtld-elf/rtld.h
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2012-03-20 13:20:49 +0000
committerkib <kib@FreeBSD.org>2012-03-20 13:20:49 +0000
commitc49b39491ded257751332662302997df5b34fd12 (patch)
tree141ae8f14c62c6f65aeb3d57bd0ca7ebd14c319a /libexec/rtld-elf/rtld.h
parente87823cf6ee42b9d37c7af7ba277341a2fd2fac9 (diff)
downloadFreeBSD-src-c49b39491ded257751332662302997df5b34fd12.zip
FreeBSD-src-c49b39491ded257751332662302997df5b34fd12.tar.gz
Fix several problems with our ELF filters implementation.
Do not relocate twice an object which happens to be needed by loaded binary (or dso) and some filtee opened due to symbol resolution when relocating need objects. Record the state of the relocation processing in Obj_Entry and short-circuit relocate_objects() if current object already processed. Do not call constructors for filtees loaded during the early relocation processing before image is initialized enough to run user-provided code. Filtees are loaded using dlopen_object(), which normally performs relocation and initialization. If filtee is lazy-loaded during the relocation of dso needed by the main object, dlopen_object() runs too earlier, when most runtime services are not yet ready. Postpone the constructors call to the time when main binary and depended libraries constructors are run, passing the new flag RTLD_LO_EARLY to dlopen_object(). Symbol lookups callers inform symlook_* functions about early stage of initialization with SYMLOOK_EARLY. Pass flags through all functions participating in object relocation. Use the opportunity and fix flags argument to find_symdef() in arch-specific reloc.c to use proper name SYMLOOK_IN_PLT instead of true, which happen to have the same numeric value. Reported and tested by: theraven Reviewed by: kan MFC after: 2 weeks
Diffstat (limited to 'libexec/rtld-elf/rtld.h')
-rw-r--r--libexec/rtld-elf/rtld.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/libexec/rtld-elf/rtld.h b/libexec/rtld-elf/rtld.h
index 9dfa0a2..2aabffe 100644
--- a/libexec/rtld-elf/rtld.h
+++ b/libexec/rtld-elf/rtld.h
@@ -229,6 +229,7 @@ typedef struct Struct_Obj_Entry {
bool mainprog : 1; /* True if this is the main program */
bool rtld : 1; /* True if this is the dynamic linker */
+ bool relocated : 1; /* True if processed by relocate_objects() */
bool textrel : 1; /* True if there are relocations to text seg */
bool symbolic : 1; /* True if generated with "-Bsymbolic" */
bool bind_now : 1; /* True if all relocations should be made first */
@@ -267,6 +268,7 @@ typedef struct Struct_Obj_Entry {
#define SYMLOOK_IN_PLT 0x01 /* Lookup for PLT symbol */
#define SYMLOOK_DLSYM 0x02 /* Return newest versioned symbol. Used by
dlsym. */
+#define SYMLOOK_EARLY 0x04 /* Symlook is done during initialization. */
/* Flags for load_object(). */
#define RTLD_LO_NOLOAD 0x01 /* dlopen() specified RTLD_NOLOAD. */
@@ -274,6 +276,8 @@ typedef struct Struct_Obj_Entry {
#define RTLD_LO_TRACE 0x04 /* Only tracing. */
#define RTLD_LO_NODELETE 0x08 /* Loaded object cannot be closed. */
#define RTLD_LO_FILTEES 0x10 /* Loading filtee. */
+#define RTLD_LO_EARLY 0x20 /* Do not call ctors, postpone it to the
+ initialization during the image start. */
/*
* Symbol cache entry used during relocation to avoid multiple lookups
@@ -353,11 +357,12 @@ const Ver_Entry *fetch_ventry(const Obj_Entry *obj, unsigned long);
* MD function declarations.
*/
int do_copy_relocations(Obj_Entry *);
-int reloc_non_plt(Obj_Entry *, Obj_Entry *, struct Struct_RtldLockState *);
+int reloc_non_plt(Obj_Entry *, Obj_Entry *, int flags,
+ struct Struct_RtldLockState *);
int reloc_plt(Obj_Entry *);
-int reloc_jmpslots(Obj_Entry *, struct Struct_RtldLockState *);
+int reloc_jmpslots(Obj_Entry *, int flags, struct Struct_RtldLockState *);
int reloc_iresolve(Obj_Entry *, struct Struct_RtldLockState *);
-int reloc_gnu_ifunc(Obj_Entry *, struct Struct_RtldLockState *);
+int reloc_gnu_ifunc(Obj_Entry *, int flags, struct Struct_RtldLockState *);
void allocate_initial_tls(Obj_Entry *);
#endif /* } */
OpenPOWER on IntegriCloud