Skip to content

Commit d90f2d7

Browse files
keesgregkh
authored andcommitted
x86, kaslr: Handle Gold linker for finding bss/brk
commit 70b61e3 upstream. 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 <markus@trippelsdorf.de> Signed-off-by: Kees Cook <keescook@chromium.org> Cc: Junjie Mao <eternal.n08@gmail.com> Link: http://lkml.kernel.org/r/20141118001604.GA25045@www.outflux.net Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1a829c5 commit d90f2d7

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎arch/x86/tools/calc_run_size.pl‎

Lines changed: 10 additions & 1 deletion
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)