[klibc] [PATCH] x86_64: fix shared library breakage with new binutils versions

Sergey Vlasov vsu at altlinux.ru
Sun Feb 18 12:30:44 PST 2007

In recent versions of binutils the maximum page size for x86_64 was
increased from 1 MB to 2 MB:


This change breaks building of the klibc shared library - klibc.so
data is pushed over the 4 MB mark, where it may overlap the main
executable (which is linked starting at 4 MB).

Adding the "-z max-page-size=0x100000" option fixes the problem with
new binutils, and does not break linking with old binutils (ld
silently ignores unknown "-z KEYWORD" options).

Signed-off-by: Sergey Vlasov <vsu at altlinux.ru>
 Alternatively, you may pull from the following git repo and branch:

    git://git.altlinux.org/people/vsu/packages/klibc.git upstream-fixes

 usr/klibc/arch/x86_64/MCONFIG |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/usr/klibc/arch/x86_64/MCONFIG b/usr/klibc/arch/x86_64/MCONFIG
index a229905..b40c627 100644
--- a/usr/klibc/arch/x86_64/MCONFIG
+++ b/usr/klibc/arch/x86_64/MCONFIG
@@ -29,7 +29,11 @@ KLIBCLDFLAGS      = -m elf_x86_64
 # This address needs to be reachable using normal inter-module
 # calls, and work on the memory models for this architecture
 # 2 MB - normal binaries start at 4 MB
-KLIBCSHAREDFLAGS     = -Ttext 0x00200200
+# Recent binutils use max-page-size=0x200000 by default, which pushes
+# klibc.so data over the 4 MB mark, overlapping the executable.
+# Revert to the old max-page-size=0x100000 value.
+KLIBCSHAREDFLAGS     = -Ttext 0x00200200 -z max-page-size=0x100000
 # Additional asm- directories needed during installation
 ASMARCH = asm-i386

More information about the klibc mailing list