From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 87E693857C42; Thu, 13 Aug 2020 22:39:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 87E693857C42 From: "bbatliner at ocient dot com" To: glibc-bugs@sourceware.org Subject: [Bug libc/26386] New: libc_nonshared.a 32-bit relocations Date: Thu, 13 Aug 2020 22:39:54 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Version: 2.28 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bbatliner at ocient dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: glibc-bugs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-bugs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Aug 2020 22:39:54 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D26386 Bug ID: 26386 Summary: libc_nonshared.a 32-bit relocations Product: glibc Version: 2.28 Status: UNCONFIRMED Severity: normal Priority: P2 Component: libc Assignee: unassigned at sourceware dot org Reporter: bbatliner at ocient dot com CC: drepper.fsp at gmail dot com Target Milestone: --- Referred by Florian Weimer to create a bug report for this behavior:=20 https://sourceware.org/pipermail/libc-help/2020-August/005397.html glibc-devel-2.28-101.el8.x86_64 from the BaseOS repo is causing linking errors for our C++ builds, likely due to 32-bit relocations compiled into libc_nonshared.a. Here's a minimal C program to reproduce the error: ``` #include void foo() {} int main() { atexit(&foo); return 0; } ``` On CentOS 8.2.2004 with glibc 2.28 and gcc 8.2.0 compiled with mcmodel=3Dlarge (some paths truncated with ...): $ gcc -S -o foo.s foo.c $ as --64 -o foo.o foo.s $ ld -Tfoo.lds --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -rpath /.../gcc/stage-8.2.0/bin/lib64 -L/.../gcc/stage-8.2.0/bin/lib64 -o a.out /lib/../lib64/crt1.o /lib/../lib64/crti.o /.../gcc/stage-8.2.0/bin/lib/gcc/x86_64-pc-linux-gnu/8.2.0/crtbegin.o -L/.../gcc/stage-8.2.0/bin/lib/gcc/x86_64-pc-linux-gnu/8.2.0 -L/.../gcc/stage-8.2.0/bin/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../li= b64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/.../gcc/stage-8.2.0/bin/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../.. foo.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /.../gcc/stage-8.2.0/bin/lib/gcc/x86_64-pc-linux-gnu/8.2.0/crtend.o /lib/../lib64/crtn.o ld: /usr/lib64/libc_nonshared.a(atexit.oS): in function `atexit': (.text+0x7): relocation truncated to fit: R_X86_64_PC32 against symbol `__dso_handle' defined in .data section in /.../gcc/stage-8.2.0/bin/lib/gcc/x86_64-pc-linux-gnu/8.2.0/crtbegin.o The linker script foo.lds is the default ld linker script, with `. =3D 0x200000000000;` inserted just before `.data` to force the data to be beyond the 32-bit address space. On CentOS 7.8.2003 with glibc 2.17 and gcc 8.2.0 compiled with mcmodel=3Dlarge: $ gcc -S -o foo.s foo.c $ as --64 -o foo.o foo.s $ ld -Tfoo.lds --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -rpath /.../gcc/stage-8.2.0/bin/lib64 -L/.../gcc/stage-8.2.0/bin/lib64 -o a.out /lib/../lib64/crt1.o /lib/../lib64/crti.o /.../gcc/stage-8.2.0/bin/lib/gcc/x86_64-pc-linux-gnu/8.2.0/crtbegin.o -L/.../gcc/stage-8.2.0/bin/lib/gcc/x86_64-pc-linux-gnu/8.2.0 -L/.../gcc/stage-8.2.0/bin/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../li= b64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/.../gcc/stage-8.2.0/bin/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../.. foo.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /.../gcc/stage-8.2.0/bin/lib/gcc/x86_64-pc-linux-gnu/8.2.0/crtend.o /lib/../lib64/crtn.o ld: failed to convert GOTPCREL relocation; relink with --no-relax The GOTPCREL relocation comes from glibc 2.17's libc_nonshared.a: $ readelf -r /lib64/libc_nonshared.a | grep __dso_handle 000000000003 000900000009 R_X86_64_GOTPCREL 0000000000000000 __dso_handle = - 4 000000000003 000900000009 R_X86_64_GOTPCREL 0000000000000000 __dso_handle = - 4 Linking with --no-relax resolves the issue on CentOS 7 / glibc 2.17. However, on CentOS 8 / glibc 2.28: $ readelf -r /lib64/libc_nonshared.a | grep __dso_handle 000000000007 003200000002 R_X86_64_PC32 0000000000000000 __dso_handle = - 4 000000000007 003200000002 R_X86_64_PC32 0000000000000000 __dso_handle = - 4 000000000007 003200000002 R_X86_64_PC32 0000000000000000 __dso_handle = - 4 The relocations are PC32 and are always truncated, failing to link. Florian believes this to be a regression introduced in commit 825adeeed1e95990fd1efb70d9ac3eb7f1ea802a. --=20 You are receiving this mail because: You are on the CC list for the bug.=