Skip to content

Commit

Permalink
um: Fix overlapping ELF segments when statically linked
Browse files Browse the repository at this point in the history
When statically linked, the .text section in UML kernels is not page
aligned, causing it to share a page with the executable headers. As
.text and the executable headers have different permissions, this causes
the kernel to wish to map the same page twice (once as headers with r--
permissions, once as .text with r-x permissions), causing a segfault,
and a nasty message printed to the host kernel's dmesg:

"Uhuuh, elf segment at 0000000060000000 requested but the memory is
mapped already"

By aligning the .text to a page boundary (as in the dynamically linked
version in dyn.lds.S), there is no such overlap, and the kernel runs
correctly.

Signed-off-by: David Gow <[email protected]>
Reviewed-by: Brendan Higgins <[email protected]>
Signed-off-by: Richard Weinberger <[email protected]>
  • Loading branch information
sulix authored and richardweinberger committed Mar 29, 2020
1 parent 7334339 commit 598f563
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion arch/um/kernel/uml.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ SECTIONS
__binary_start = START;

. = START + SIZEOF_HEADERS;
. = ALIGN(PAGE_SIZE);

_text = .;
INIT_TEXT_SECTION(0)
. = ALIGN(PAGE_SIZE);

.text :
{
Expand Down

0 comments on commit 598f563

Please sign in to comment.