From d186323a2db1f8bf65b24236ce8d2ddff1b4385a Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Sat, 5 Jan 2019 09:36:32 -0600 Subject: Fix compatibility with Linux 4.17+ The gcompat loader compiled as a static binary doesn't work on Linux since commit a4ff8e8620d3f4, failing with the error: ``` Uhuuh, elf segment at 0000000000400000 requested but the memory is mapped already ``` This is because the binary we are the ELF interpreter for is also loaded at 0x400000. While it's actually okay to overlap the binary, since we're going to call `execve` again, the kernel doesn't allow the overlap anymore. Fix that by compiling the loader as static PIE, so it can be loaded at a different address. Signed-off-by: Samuel Holland --- CHANGELOG.rst | 1 + Makefile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 25b57e0..c494a38 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -15,6 +15,7 @@ Build system ------------ * Allow building against libobstack. +* Fix compatibility with Linux 4.17 and newer. pthread ------- diff --git a/Makefile b/Makefile index 0f18af0..6a36129 100644 --- a/Makefile +++ b/Makefile @@ -73,7 +73,7 @@ ${LIBGCOMPAT_NAME}: ${LIBGCOMPAT_OBJ} ${LIBGCOMPAT_OBJ}: ${LIBGCOMPAT_INCLUDE} ${LOADER_NAME}: ${LOADER_OBJ} - ${CC} ${CFLAGS} ${LDFLAGS} -static -o ${LOADER_NAME} ${LOADER_OBJ} + ${CC} ${CFLAGS} ${LDFLAGS} -static-pie -o ${LOADER_NAME} ${LOADER_OBJ} .c.o: ${CC} ${CPPFLAGS} ${CFLAGS} -c -D_BSD_SOURCE \ -- cgit v1.2.3-60-g2f50