From: Luca Boccassi Date: Tue, 23 May 2023 01:12:12 +0000 (+0100) Subject: elf2efi: ensure minimum gap between .text and other sections X-Git-Tag: v254-rc1~382^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e78fc81d30f254dec3ce998ba19ecee22bb3eb04;p=thirdparty%2Fsystemd.git elf2efi: ensure minimum gap between .text and other sections When linking an almost empty binary the linker can merged .text with a later section, creating a RWE segment, that then it rejects. --- diff --git a/tools/elf2efi.lds b/tools/elf2efi.lds index 805efc156d1..6e9eff0763a 100644 --- a/tools/elf2efi.lds +++ b/tools/elf2efi.lds @@ -6,6 +6,13 @@ SECTIONS { .text ALIGN(CONSTANT(MAXPAGESIZE)) : { *(.text .text.*) } + + /* When linking a minimal addon stub, the linker can merge .text and .dynsym, creating a RWE + * segment, and then rejects it. Ensure there's a gap so that we end up with two separate segments. + * The alignments for the next sections are only applied if the section exists, so they are not + * enough, and we need to have this unconditional one. */ + . = ALIGN(CONSTANT(MAXPAGESIZE)); + .rodata ALIGN(CONSTANT(MAXPAGESIZE)) : { *(.rodata .rodata.*) *(.srodata .srodata.*)