Skip to content

Commit 335de24

Browse files
hdellermcgrof
authored andcommitted
modules: Ensure 64-bit alignment on __ksymtab_* sections
On 64-bit architectures without CONFIG_HAVE_ARCH_PREL32_RELOCATIONS (e.g. ppc64, ppc64le, parisc, s390x,...) the __KSYM_REF() macro stores 64-bit pointers into the __ksymtab* sections. Make sure that those sections will be correctly aligned at module link time, otherwise unaligned memory accesses may happen at runtime. As per unaligned-memory-access [0] "unaligned memory accesses [...] will not work correctly on certain platforms and will cause performance problems on others", so fix this. The __kcrctab* sections store 32-bit entities, so use ALIGN(4) for those. Signed-off-by: Helge Deller <[email protected]> [mcgrof: added unaligned-memory-access justification] Link: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/core-api/unaligned-memory-access.rst # [0] Signed-off-by: Luis Chamberlain <[email protected]>
1 parent 8e929cb commit 335de24

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

scripts/module.lds.S

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ SECTIONS {
1818
*(.export_symbol)
1919
}
2020

21-
__ksymtab 0 : { *(SORT(___ksymtab+*)) }
22-
__ksymtab_gpl 0 : { *(SORT(___ksymtab_gpl+*)) }
23-
__kcrctab 0 : { *(SORT(___kcrctab+*)) }
24-
__kcrctab_gpl 0 : { *(SORT(___kcrctab_gpl+*)) }
21+
__ksymtab 0 : ALIGN(8) { *(SORT(___ksymtab+*)) }
22+
__ksymtab_gpl 0 : ALIGN(8) { *(SORT(___ksymtab_gpl+*)) }
23+
__kcrctab 0 : ALIGN(4) { *(SORT(___kcrctab+*)) }
24+
__kcrctab_gpl 0 : ALIGN(4) { *(SORT(___kcrctab_gpl+*)) }
2525

2626
.ctors 0 : ALIGN(8) { *(SORT(.ctors.*)) *(.ctors) }
2727
.init_array 0 : ALIGN(8) { *(SORT(.init_array.*)) *(.init_array) }

0 commit comments

Comments
 (0)