Commit d186323a authored by Samuel Holland's avatar Samuel Holland

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's avatarSamuel Holland <samuel@sholland.org>
parent de9e45d7
......@@ -15,6 +15,7 @@ Build system
------------
* Allow building against libobstack.
* Fix compatibility with Linux 4.17 and newer.
pthread
-------
......
......@@ -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 \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment