Skip to content

Commit 70b61e3

Browse files
keesKAGA-KOKO
authored andcommitted
x86, kaslr: Handle Gold linker for finding bss/brk
When building with the Gold linker, the .bss and .brk areas of vmlinux are shown as consecutive instead of having the same file offset. Allow for either state, as long as things add up correctly. Fixes: e602336 ("x86, kaslr: Prevent .bss from overlaping initrd") Reported-by: Markus Trippelsdorf <[email protected]> Signed-off-by: Kees Cook <[email protected]> Cc: Junjie Mao <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Cc: [email protected] Signed-off-by: Thomas Gleixner <[email protected]>
1 parent 45e2a9d commit 70b61e3

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

arch/x86/tools/calc_run_size.pl

+10-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,16 @@
1919
if ($file_offset == 0) {
2020
$file_offset = $offset;
2121
} elsif ($file_offset != $offset) {
22-
die ".bss and .brk lack common file offset\n";
22+
# BFD linker shows the same file offset in ELF.
23+
# Gold linker shows them as consecutive.
24+
next if ($file_offset + $mem_size == $offset + $size);
25+
26+
printf STDERR "file_offset: 0x%lx\n", $file_offset;
27+
printf STDERR "mem_size: 0x%lx\n", $mem_size;
28+
printf STDERR "offset: 0x%lx\n", $offset;
29+
printf STDERR "size: 0x%lx\n", $size;
30+
31+
die ".bss and .brk are non-contiguous\n";
2332
}
2433
}
2534
}

0 commit comments

Comments
 (0)