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/sparc64 | |
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/sparc64')
-rw-r--r-- | sys/sparc64/sparc64/elf_machdep.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/sys/sparc64/sparc64/elf_machdep.c b/sys/sparc64/sparc64/elf_machdep.c index 592be48..a14db6c 100644 --- a/sys/sparc64/sparc64/elf_machdep.c +++ b/sys/sparc64/sparc64/elf_machdep.c @@ -235,6 +235,28 @@ static long reloc_target_bitmask[] = { }; #define RELOC_VALUE_BITMASK(t) (reloc_target_bitmask[t]) +int +elf_reloc_local(linker_file_t lf, const void *data, int type) +{ + const Elf_Rela *rela; + Elf_Addr value; + Elf_Addr *where; + + if (type != ELF_RELOC_RELA) + return (-1); + + rela = (const Elf_Rela *)data; + if (ELF_R_TYPE(rela->r_info) != R_SPARC_RELATIVE) + return (-1); + + value = rela->r_addend + (Elf_Addr)lf->address; + where = (Elf_Addr *)((Elf_Addr)lf->address + rela->r_offset); + + *where = value; + + return (0); +} + /* Process one elf relocation with addend. */ int elf_reloc(linker_file_t lf, const void *data, int type) @@ -258,7 +280,7 @@ elf_reloc(linker_file_t lf, const void *data, int type) rtype = ELF_R_TYPE(rela->r_info); symidx = ELF_R_SYM(rela->r_info); - if (rtype == R_SPARC_NONE) + if (rtype == R_SPARC_NONE || rtype == R_SPARC_RELATIVE) return (0); if (rtype == R_SPARC_JMP_SLOT || rtype == R_SPARC_COPY || |