diff options
author | Mitchell Horne <mhorne@FreeBSD.org> | 2020-10-07 18:48:10 +0000 |
---|---|---|
committer | Mitchell Horne <mhorne@FreeBSD.org> | 2020-10-07 18:48:10 +0000 |
commit | 8481aab1ac34ef07fcf747efbcf4fdbb0435b2f0 (patch) | |
tree | 785ea3ad4528b61ff876ce3b2106c7f323102d0d /sys/amd64 | |
parent | 194ddc011ad10900a405fb81cf48a022badf77b8 (diff) | |
download | src-test-8481aab1ac34ef07fcf747efbcf4fdbb0435b2f0.tar.gz src-test-8481aab1ac34ef07fcf747efbcf4fdbb0435b2f0.zip |
Print symbol index for unsupported relocation types
It is unlikely, but possible, that an unrecognized or unsupported
relocation type is encountered while trying to load a kernel module. If
this occurs we should offer the symbol index as a hint to the user.
While here, fix some small style issues.
Reviewed by: markj, kib (amd64 part, in D26701)
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Notes
Notes:
svn path=/head/; revision=366519
Diffstat (limited to 'sys/amd64')
-rw-r--r-- | sys/amd64/amd64/elf_machdep.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/sys/amd64/amd64/elf_machdep.c b/sys/amd64/amd64/elf_machdep.c index 81aa32e9bce5c..0aea4a0d355ba 100644 --- a/sys/amd64/amd64/elf_machdep.c +++ b/sys/amd64/amd64/elf_machdep.c @@ -309,11 +309,11 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data, case R_X86_64_NONE: /* none */ break; - case R_X86_64_64: /* S + A */ + case R_X86_64_64: /* S + A */ error = lookup(lf, symidx, 1, &addr); val = addr + addend; if (error != 0) - return -1; + return (-1); if (*where != val) *where = val; break; @@ -325,7 +325,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data, where32 = (Elf32_Addr *)where; val32 = (Elf32_Addr)(addr + addend - (Elf_Addr)where); if (error != 0) - return -1; + return (-1); if (*where32 != val32) *where32 = val32; break; @@ -335,7 +335,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data, val32 = (Elf32_Addr)(addr + addend); where32 = (Elf32_Addr *)where; if (error != 0) - return -1; + return (-1); if (*where32 != val32) *where32 = val32; break; @@ -345,14 +345,15 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data, * There shouldn't be copy relocations in kernel * objects. */ - printf("kldload: unexpected R_COPY relocation\n"); + printf("kldload: unexpected R_COPY relocation, " + "symbol index %ld\n", symidx); return (-1); case R_X86_64_GLOB_DAT: /* S */ case R_X86_64_JMP_SLOT: /* XXX need addend + offset */ error = lookup(lf, symidx, 1, &addr); if (error != 0) - return -1; + return (-1); if (*where != addr) *where = addr; break; @@ -372,8 +373,8 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data, break; default: - printf("kldload: unexpected relocation type %ld\n", - rtype); + printf("kldload: unexpected relocation type %ld, " + "symbol index %ld\n", rtype, symidx); return (-1); } return (0); |