diff options
author | jake <jake@FreeBSD.org> | 2003-01-21 02:42:44 +0000 |
---|---|---|
committer | jake <jake@FreeBSD.org> | 2003-01-21 02:42:44 +0000 |
commit | c1e42cc8bb6beb27c070748587d19f1d63fc956a (patch) | |
tree | a6736a5694dc3395d090d1d257e111c315fd88a0 /sys/i386 | |
parent | 013247cd19dd036ba508021e0edaba94b2a75960 (diff) | |
download | FreeBSD-src-c1e42cc8bb6beb27c070748587d19f1d63fc956a.zip FreeBSD-src-c1e42cc8bb6beb27c070748587d19f1d63fc956a.tar.gz |
Resolve relative relocations in klds before trying to parse the module's
metadata. This fixes module dependency resolution by the kernel linker on
sparc64, where the relocations for the metadata are different than on other
architectures; the relative offset is in the addend of an Elf_Rela record
instead of the original value of the location being patched.
Also fix printf formats in debug code.
Submitted by: Hartmut Brandt <brandt@fokus.gmd.de>
PR: 46732
Tested on: alpha (obrien), i386, sparc64
Diffstat (limited to 'sys/i386')
-rw-r--r-- | sys/i386/i386/elf_machdep.c | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/sys/i386/i386/elf_machdep.c b/sys/i386/i386/elf_machdep.c index 71520de..4cf9f21 100644 --- a/sys/i386/i386/elf_machdep.c +++ b/sys/i386/i386/elf_machdep.c @@ -86,8 +86,8 @@ SYSINIT(elf32, SI_SUB_EXEC, SI_ORDER_ANY, &freebsd_brand_info); /* Process one elf relocation with addend. */ -int -elf_reloc(linker_file_t lf, const void *data, int type) +static int +elf_reloc_internal(linker_file_t lf, const void *data, int type, int local) { Elf_Addr relocbase = (Elf_Addr) lf->address; Elf_Addr *where; @@ -116,6 +116,15 @@ elf_reloc(linker_file_t lf, const void *data, int type) panic("unknown reloc type %d\n", type); } + if (local) { + if (rtype == R_386_RELATIVE) { /* A + B */ + addr = relocbase + addend; + if (*where != addr) + *where = addr; + } + return (0); + } + switch (rtype) { case R_386_NONE: /* none */ @@ -156,10 +165,7 @@ elf_reloc(linker_file_t lf, const void *data, int type) *where = addr; break; - case R_386_RELATIVE: /* B + A */ - addr = relocbase + addend; - if (*where != addr) - *where = addr; + case R_386_RELATIVE: break; default: @@ -171,6 +177,20 @@ elf_reloc(linker_file_t lf, const void *data, int type) } int +elf_reloc(linker_file_t lf, const void *data, int type) +{ + + return (elf_reloc_internal(lf, data, type, 0)); +} + +int +elf_reloc_local(linker_file_t lf, const void *data, int type) +{ + + return (elf_reloc_internal(lf, data, type, 1)); +} + +int elf_cpu_load_file(linker_file_t lf __unused) { |