Skip to content

Commit b6b17a8

Browse files
aurxenonmattst88
authored andcommitted
alpha: fix R_ALPHA_LITERAL reloc for large modules
Previously, R_ALPHA_LITERAL relocations would overflow for large kernel modules. This was because the Alpha's apply_relocate_add was relying on the kernel's module loader to have sorted the GOT towards the very end of the module as it was mapped into memory in order to correctly assign the global pointer. While this behavior would mostly work fine for small kernel modules, this approach would overflow on kernel modules with large GOT's since the global pointer would be very far away from the GOT, and thus, certain entries would be out of range. This patch fixes this by instead using the Tru64 behavior of assigning the global pointer to be 32KB away from the start of the GOT. The change made in this patch won't work for multi-GOT kernel modules as it makes the assumption the module only has one GOT located at the beginning of .got, although for the vast majority kernel modules, this should be fine. Of the kernel modules that would previously result in a relocation error, none of them, even modules like nouveau, have even come close to filling up a single GOT, and they've all worked fine under this patch. Signed-off-by: Edward Humes <aurxenon@lunos.org> Signed-off-by: Matt Turner <mattst88@gmail.com>
1 parent 73c4f82 commit b6b17a8

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

arch/alpha/kernel/module.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,8 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
146146
base = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr;
147147
symtab = (Elf64_Sym *)sechdrs[symindex].sh_addr;
148148

149-
/* The small sections were sorted to the end of the segment.
150-
The following should definitely cover them. */
151-
gp = (u64)me->core_layout.base + me->core_layout.size - 0x8000;
152149
got = sechdrs[me->arch.gotsecindex].sh_addr;
150+
gp = got + 0x8000;
153151

154152
for (i = 0; i < n; i++) {
155153
unsigned long r_sym = ELF64_R_SYM (rela[i].r_info);

0 commit comments

Comments
 (0)