summaryrefslogtreecommitdiffstats
path: root/libexec/rtld-elf/mips/reloc.c
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/mips/reloc.c
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/mips/reloc.c')
-rw-r--r--libexec/rtld-elf/mips/reloc.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/libexec/rtld-elf/mips/reloc.c b/libexec/rtld-elf/mips/reloc.c
index fd108f9..24e56ce 100644
--- a/libexec/rtld-elf/mips/reloc.c
+++ b/libexec/rtld-elf/mips/reloc.c
@@ -258,7 +258,8 @@ _mips_rtld_bind(Obj_Entry *obj, Elf_Size reloff)
}
int
-reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, RtldLockState *lockstate)
+reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, int flags,
+ RtldLockState *lockstate)
{
const Elf_Rel *rel;
const Elf_Rel *rellim;
@@ -317,7 +318,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, RtldLockState *lockstate)
* to 0 if there are non-PLT references, but older
* versions of GNU ld do not do this.
*/
- def = find_symdef(i, obj, &defobj, false, NULL,
+ def = find_symdef(i, obj, &defobj, flags, NULL,
lockstate);
if (def == NULL)
return -1;
@@ -359,7 +360,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, RtldLockState *lockstate)
}
} else {
/* TODO: add cache here */
- def = find_symdef(i, obj, &defobj, false, NULL,
+ def = find_symdef(i, obj, &defobj, flags, NULL,
lockstate);
if (def == NULL) {
dbg("Warning4, can't find symbole %d", i);
@@ -458,7 +459,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, RtldLockState *lockstate)
Elf_Addr old = load_ptr(where, rlen);
Elf_Addr val = old;
- def = find_symdef(r_symndx, obj, &defobj, false, NULL,
+ def = find_symdef(r_symndx, obj, &defobj, flags, NULL,
lockstate);
if (def == NULL)
return -1;
@@ -482,7 +483,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, RtldLockState *lockstate)
Elf_Addr old = load_ptr(where, rlen);
Elf_Addr val = old;
- def = find_symdef(r_symndx, obj, &defobj, false, NULL,
+ def = find_symdef(r_symndx, obj, &defobj, flags, NULL,
lockstate);
if (def == NULL)
return -1;
@@ -509,7 +510,7 @@ reloc_non_plt(Obj_Entry *obj, Obj_Entry *obj_rtld, RtldLockState *lockstate)
Elf_Addr old = load_ptr(where, rlen);
Elf_Addr val = old;
- def = find_symdef(r_symndx, obj, &defobj, false, NULL,
+ def = find_symdef(r_symndx, obj, &defobj, flags, NULL,
lockstate);
if (def == NULL)
@@ -577,7 +578,7 @@ reloc_plt(Obj_Entry *obj)
* LD_BIND_NOW was set - force relocation for all jump slots
*/
int
-reloc_jmpslots(Obj_Entry *obj, RtldLockState *lockstate)
+reloc_jmpslots(Obj_Entry *obj, int flags, RtldLockState *lockstate)
{
/* Do nothing */
obj->jmpslots_done = true;
@@ -594,7 +595,8 @@ reloc_iresolve(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
}
int
-reloc_gnu_ifunc(Obj_Entry *obj, struct Struct_RtldLockState *lockstate)
+reloc_gnu_ifunc(Obj_Entry *obj, int flags,
+ struct Struct_RtldLockState *lockstate)
{
/* XXX not implemented */
OpenPOWER on IntegriCloud