This series fixes link/load issues I found on i386 with Debian's toolchain (gcc 8 with PIE as default, binutils 2.31). Ben. Ben Hutchings (2): [klibc] i386: Use -Ttext-segment to avoid address collision [klibc] Disable PIE scripts/Kbuild.klibc | 3 ++- usr/klibc/arch/i386/MCONFIG | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://www.zytor.com/pipermail/klibc/attachments/20190106/3a4f9db3/attachment.sig>
Ben Hutchings
2019-Jan-06 19:30 UTC
[klibc] [PATCH klibc 1/2] i386: Use -Ttext-segment to avoid address collision
Building klibc for i386 with binutils 2.31 adds an extra .note.gnu.property section to klibc.so, the address of which is not affected by the -Ttext option. Loading a klibc executable then fails with the following kernel log message: 9409 (sh.shared): Uhuuh, elf segment at 0000000000600000 requested but the memory is mapped already I don't exactly see why this is happening, but it is triggered by the new section and the collision can be avoided by passing -Ttext-segment instead of -Ttext, similarly to x86_64. Signed-off-by: Ben Hutchings <ben at decadent.org.uk> --- usr/klibc/arch/i386/MCONFIG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/klibc/arch/i386/MCONFIG b/usr/klibc/arch/i386/MCONFIG index 1150ecedf799..bfec004a3c8b 100644 --- a/usr/klibc/arch/i386/MCONFIG +++ b/usr/klibc/arch/i386/MCONFIG @@ -30,7 +30,7 @@ KLIBCBITSIZE = 32 # This address needs to be reachable using normal inter-module # calls, and work on the memory models for this architecture # 96 MB - normal binaries start at 128 MB -KLIBCSHAREDFLAGS = -Ttext 0x06000200 +KLIBCSHAREDFLAGS = -Ttext-segment 0x06000000 # Asm includes for i386 are in the merged x86 tree KLIBCARCHINCFLAGS = -I$(KLIBCKERNELOBJ)/arch/x86/include -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://www.zytor.com/pipermail/klibc/attachments/20190106/20782905/attachment.sig>
We link all executables as non-relocatable, so it makes no sense to generate PIE code. In addition, PIE code on i386 requires a working GOT which we don't generate. Signed-off-by: Ben Hutchings <ben at decadent.org.uk> --- scripts/Kbuild.klibc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/Kbuild.klibc b/scripts/Kbuild.klibc index f147a37309e3..35c375edd909 100644 --- a/scripts/Kbuild.klibc +++ b/scripts/Kbuild.klibc @@ -67,7 +67,8 @@ include $(srctree)/scripts/Kbuild.include # --------------------------------------------------------------------------- KLIBCREQFLAGS := $(call cc-option, -fno-stack-protector, ) \ - $(call cc-option, -fwrapv, ) + $(call cc-option, -fwrapv, ) \ + $(call cc-option, -fno-PIE, ) KLIBCARCHREQFLAGS : KLIBCOPTFLAGS : KLIBCWARNFLAGS := -W -Wall -Wno-sign-compare -Wno-unused-parameter -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://www.zytor.com/pipermail/klibc/attachments/20190106/35c7319e/attachment.sig>
Seemingly Similar Threads
- [PATCH klibc 0/4] Fix the KLIBCKERNEL{SRC,OBJ} mess
- [PATCH klibc 1/3] Revert " Kbuild: Tell gas we don't want executable stacks"
- [kvm-unit-tests PATCH v3 0/4] Update patch set
- [PATCH 0/5] Clang compatibility patches
- [kvm-unit-tests PATCH v3 0/4] Update patch set