[syslinux] [PATCH] mk/efi: add -znoseparate-code to LD_FLAGS for EFI builds

Johannes Frohnhofen jf at daedalean.ai
Tue Jul 28 05:47:26 PDT 2020

More recent versions of the GNU linker (>= 2.31) create a separate
code "PT_LOAD" segment by default (as of
Building syslinux EFI images with this -zseparate-code enabled creates
broken EFI images, since efi/wrapper.c only copies the first PT_LOAD
segment to the EFI.
This patch adds -znoseparate-code to the LD_FLAGS for EFI builds to
restore the original behavior.

PS: I am aware that development activity is low. We still wanted to
contribute this fix in case it may be helpful to anyone.


Signed-off-by: Johannes Frohnhofen <jf at daedalean.ai>

--- mk/efi.mk.orig 2020-07-28 12:31:48.814356659 +0000
+++ mk/efi.mk 2020-07-28 12:37:22.292205578 +0000
@@ -37,7 +37,8 @@ CRT0 := $(LIBDIR)/crt0-efi-$(EFI_SUBARCH
 LDSCRIPT := $(LIBDIR)/elf_$(EFI_SUBARCH)_efi.lds

 LDFLAGS = -T $(SRC)/$(ARCH)/syslinux.ld -Bsymbolic -pie -nostdlib
-znocombreloc \
- -L$(LIBDIR) --hash-style=gnu -m elf_$(ARCH) $(CRT0) -E
+ -znoseparate-code -L$(LIBDIR) --hash-style=gnu -m elf_$(ARCH) \
+                $(CRT0) -E

       -fomit-frame-pointer -D__COM32__ -D__FIRMWARE_$(FIRMWARE)__ \

More information about the Syslinux mailing list