Message ID | 20200516135332.3969575-1-slyich@gmail.com |
---|---|
State | Dropped |
Headers |
Return-Path: <libc-alpha-bounces@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C6FFA3840C2D; Sat, 16 May 2020 13:53:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C6FFA3840C2D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1589637227; bh=wOFzzPHn0n8RgZeAvLp0LPn4/G/vmHHorDpttf5b0lA=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=rQxjzXRMHzXdZIGu6xgphL10fO5N0CUBdEvyS2TBk9OzD1MO4bfcowbl9Y9WKcbuf XXgRnh7ZsErNXor5tTLjKdU609SFLlJvc+ampG8odQ5LDrelQPmEb3XAXwihJ5XjUg maGsaH/Rf83fgSh5dWqjLq0EJ9w065wBL985+mGs= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by sourceware.org (Postfix) with ESMTPS id 0E377386F442 for <libc-alpha@sourceware.org>; Sat, 16 May 2020 13:53:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0E377386F442 Received: by mail-wr1-x443.google.com with SMTP id l18so6638107wrn.6 for <libc-alpha@sourceware.org>; Sat, 16 May 2020 06:53:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wOFzzPHn0n8RgZeAvLp0LPn4/G/vmHHorDpttf5b0lA=; b=Wx6hw5pghkNf1LYyK6YvEOI++Hu+kH4da9YGn19tbSdiVPKrgF+3w3B+j2Yep+K1rY LeVsMBFHyqsPGLSW+m5TjythIjnb+a/XGjBhXWDE/bxUoJlEiBBY7vfD6+NUELifubfJ MLoCQeV/Dq3/YFaffTO7dgKXjE9sP/0mqRxofSn3MpeL/ZV+ijaYFFd4LlHfSJoidB02 zPqpiEDC72oNn1tULq7461LwkN8jV/M+aOBVsl9VgtDm2tzo1afeKeT3DD8gRTIb3p0p q/A4CBxDzdPzbPgemV8YvKkNeXY5Ka0oJLOwhmGX8jc9lJckwoUqWqCCLdTChWhcCE2j 4TCw== X-Gm-Message-State: AOAM53312Mm3WKJd/2fwjAlPImax4c2R3tsCdotEENx4dEayRvcv4RiK hXKW+adDQByGvtPWz9/mfPcBWXUxVTc= X-Google-Smtp-Source: ABdhPJwW/WYIRVkkb18BYvg1wPLkBjEiNMDJaR3LnpUlNDY73t/hcWmTNOK5VyyH+zq7ynX4Bny65Q== X-Received: by 2002:a5d:5503:: with SMTP id b3mr9797646wrv.272.1589637224110; Sat, 16 May 2020 06:53:44 -0700 (PDT) Received: from sf.home (host81-147-8-205.range81-147.btcentralplus.com. [81.147.8.205]) by smtp.gmail.com with ESMTPSA id y4sm8230240wro.91.2020.05.16.06.53.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 May 2020 06:53:43 -0700 (PDT) Received: by sf.home (Postfix, from userid 1000) id 662285A22061; Sat, 16 May 2020 14:53:42 +0100 (BST) To: libc-alpha@sourceware.org Subject: [PATCH] ia64: fix dl-sysdep miscompilation on gcc-10 Date: Sat, 16 May 2020 14:53:32 +0100 Message-Id: <20200516135332.3969575-1-slyich@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list <libc-alpha.sourceware.org> List-Unsubscribe: <http://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <http://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> From: slyich--- via Libc-alpha <libc-alpha@sourceware.org> Reply-To: slyich@gmail.com Cc: Sergei Trofimovich <slyfox@gentoo.org> Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" <libc-alpha-bounces@sourceware.org> |
Series |
ia64: fix dl-sysdep miscompilation on gcc-10
|
|
Commit Message
develop--- via Libc-alpha
May 16, 2020, 1:53 p.m. UTC
From: Sergei Trofimovich <slyfox@gentoo.org> gcc-10 enabled -fno-common by default. This caused glibc link failure: ``` $ ia64-unknown-linux-gnu-gcc -pipe -O2 -nostdlib -nostartfiles \ -static -o .../elf/sln ... libc.a(dl-support.o): in function `setup_vdso': glibc-2.31/elf/setup-vdso.h:116:(.text+0x1322): relocation truncated to fit: GPREL22 against `.text' collect2: error: ld returned 1 exit status ``` The difference between gcc-9 and gcc-10 is the way relocation is generated for ia64-specific symbol '_dl_sysinfo_break', defined as: ```c 32 #ifndef __ASSEMBLER__ 33 /* Don't declare this as a function---we want it's entry-point, not 34 it's function descriptor... */ 35 extern int _dl_sysinfo_break attribute_hidden; 36 # define DL_SYSINFO_DEFAULT ((uintptr_t) &_dl_sysinfo_break) 37 # define DL_SYSINFO_IMPLEMENTATION \ 38 asm (".text\n\t" \ 39 ".hidden _dl_sysinfo_break\n\t" \ 40 ".proc _dl_sysinfo_break\n\t" \ ``` Note: it's declared as ".sdata" (defined nearby GOT) but assumed to be defined in ".text" as it's really a direct function address. As a result generated relocation changed from: from `GPREL64I`: ``` 1390: 05 00 84 1e 98 11 [MLX] st8 [r15]=r33 1391: GPREL64I .text 1396: 00 00 00 00 00 e0 movl r15=0x0;; 139c: 01 00 00 60 13a0: 0b 78 04 1e 00 20 [MMI] add r15=r1,r15;; ``` to `GPREL22`: ``` if (GLRO(dl_sysinfo) == DL_SYSINFO_DEFAULT) 1320: 0b 80 00 1c 18 10 [MMI] ld8 r16=[r14];; 1322: GPREL22 .text 1326: 00 08 3d 30 23 e0 st8 [r15]=r33 132c: 01 08 00 90 addl r15=0,r1;; ``` This change explicitly declares symbol to be in ".text" section. That allows gcc to generate far relocations. Regression tested on glibc-master and gcc-10.1.0 on rx3600. Bug: https://bugs.gentoo.org/723268 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> --- sysdeps/unix/sysv/linux/ia64/dl-sysdep.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Comments
On 16/05/2020 10:53, slyich--- via Libc-alpha wrote: > From: Sergei Trofimovich <slyfox@gentoo.org> > > gcc-10 enabled -fno-common by default. This caused glibc link failure: > > ``` > $ ia64-unknown-linux-gnu-gcc -pipe -O2 -nostdlib -nostartfiles \ > -static -o .../elf/sln ... > libc.a(dl-support.o): in function `setup_vdso': > glibc-2.31/elf/setup-vdso.h:116:(.text+0x1322): > relocation truncated to fit: GPREL22 against `.text' > collect2: error: ld returned 1 exit status > ``` I can't reproduce it with master (b6ad64b907ab00) with GCC 10.1.1 20200520. (built using build-many-glibcs.py). I tried to explicit use -fno-common on CFLAGS. Are you sing a non default compiler option? > > The difference between gcc-9 and gcc-10 is the way relocation is > generated for ia64-specific symbol '_dl_sysinfo_break', defined as: > > ```c > 32 #ifndef __ASSEMBLER__ > 33 /* Don't declare this as a function---we want it's entry-point, not > 34 it's function descriptor... */ > 35 extern int _dl_sysinfo_break attribute_hidden; > 36 # define DL_SYSINFO_DEFAULT ((uintptr_t) &_dl_sysinfo_break) > 37 # define DL_SYSINFO_IMPLEMENTATION \ > 38 asm (".text\n\t" \ > 39 ".hidden _dl_sysinfo_break\n\t" \ > 40 ".proc _dl_sysinfo_break\n\t" \ > ``` > > Note: it's declared as ".sdata" (defined nearby GOT) but assumed > to be defined in ".text" as it's really a direct function address. > > As a result generated relocation changed from: > > from `GPREL64I`: > > ``` > 1390: 05 00 84 1e 98 11 [MLX] st8 [r15]=r33 > 1391: GPREL64I .text > 1396: 00 00 00 00 00 e0 movl r15=0x0;; > 139c: 01 00 00 60 > 13a0: 0b 78 04 1e 00 20 [MMI] add r15=r1,r15;; > ``` > > to `GPREL22`: > > ``` > if (GLRO(dl_sysinfo) == DL_SYSINFO_DEFAULT) > > 1320: 0b 80 00 1c 18 10 [MMI] ld8 r16=[r14];; > 1322: GPREL22 .text > 1326: 00 08 3d 30 23 e0 st8 [r15]=r33 > 132c: 01 08 00 90 addl r15=0,r1;; > ``` > > This change explicitly declares symbol to be in ".text" section. > That allows gcc to generate far relocations. > > Regression tested on glibc-master and gcc-10.1.0 on rx3600. The rationale is sound, but the trick to define a function pointer a data variable on text sections seems hacky and fragile. I still think it could be a fix, but I think we should refactor and simplify the over-enginnering of NEED_DL_SYSINFO/USE_DL_SYSINFO. > > Bug: https://bugs.gentoo.org/723268 > Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> > --- > sysdeps/unix/sysv/linux/ia64/dl-sysdep.h | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h b/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h > index 78fa6dd2c9..e526e02ff4 100644 > --- a/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h > +++ b/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h > @@ -32,7 +32,9 @@ > #ifndef __ASSEMBLER__ > /* Don't declare this as a function---we want it's entry-point, not > it's function descriptor... */ > -extern int _dl_sysinfo_break attribute_hidden; > +/* Use section ".text" to force far GPREL64 relocation instead of > + GPREL22 . */ > +extern int _dl_sysinfo_break attribute_hidden __attribute__((section(".text"))); > # define DL_SYSINFO_DEFAULT ((uintptr_t) &_dl_sysinfo_break) > # define DL_SYSINFO_IMPLEMENTATION \ > asm (".text\n\t" \ >
On Wed, 20 May 2020 16:45:03 -0300 Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org> wrote: > On 16/05/2020 10:53, slyich--- via Libc-alpha wrote: > > From: Sergei Trofimovich <slyfox@gentoo.org> > > > > gcc-10 enabled -fno-common by default. This caused glibc link failure: > > > > ``` > > $ ia64-unknown-linux-gnu-gcc -pipe -O2 -nostdlib -nostartfiles \ > > -static -o .../elf/sln ... > > libc.a(dl-support.o): in function `setup_vdso': > > glibc-2.31/elf/setup-vdso.h:116:(.text+0x1322): > > relocation truncated to fit: GPREL22 against `.text' > > collect2: error: ld returned 1 exit status > > ``` > > I can't reproduce it with master (b6ad64b907ab00) with GCC 10.1.1 20200520. > (built using build-many-glibcs.py). I tried to explicit use -fno-common on > CFLAGS. Are you sing a non default compiler option? My apologies. Missed your email. The CFLAGS options should be default. Full command is: """ ia64-unknown-linux-gnu-gcc -pipe -fdiagnostics-show-option -Wall -Wextra -Wstack-protector -O2 -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu dl-support.c -c -std=gnu11 -fgnu89-inline -pipe -fdiagnostics-show-option -Wall -Wextra -Wstack-protector -O2 -Wall -Wwrite-strings -Wundef -fmerge-all-constants -frounding-math -fno-stack-protector -Wstrict-prototypes -Wold-style-definition -fmath-errno -fpie -ftls-model=initial-exec -U_FORTIFY_SOURCE -I../include -I/tmp/portage/cross-ia64-unknown-linux-gnu/glibc-2.31-r3/work/build-default-ia64-unknown-linux-gnu-nptl/elf -I/tmp/portage/cross-ia64-unknown-linux-gnu/glibc-2.31-r3/work/build-default-ia64-unknown-linux-gnu-nptl -I../sysdeps/unix/sysv/linux/ia64 -I../sysdeps/ia64/nptl -I../sysdeps/unix/sysv/linux/wordsize-64 -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux -I../sysdeps/nptl -I../sysdeps/pthread -I../sysdeps/gnu -I../sysdeps/unix/inet -I../sysdeps/unix/sysv -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/ia64/fpu -I../sysdeps/ia64 -I../sysdeps/wordsize-64 -I../sysdeps/ieee754/float128 -I../sysdeps/ieee754/ldbl-96/include -I../sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754 -I../sysdeps/generic -I.. -I../libio -I. -nostdinc -isystem /usr/lib/gcc/ia64-unknown-linux-gnu/10.1.0/include -isystem /usr/lib/gcc/ia64-unknown-linux-gnu/10.1.0/include-fixed -isystem /usr/ia64-unknown-linux-gnu/usr/include -D_LIBC_REENTRANT -include /tmp/portage/cross-ia64-unknown-linux-gnu/glibc-2.31-r3/work/build-default-ia64-unknown-linux-gnu-nptl/libc-modules.h -DMODULE_NAME=libc -include ../include/libc-symbols.h -DPIC -DTOP_NAMESPACE=glibc -o /tmp/portage/cross-ia64-unknown-linux-gnu/glibc-2.31-r3/work/build-default-ia64-unknown-linux-gnu-nptl/elf/dl-support.o -MD -MP -MF /tmp/portage/cross-ia64-unknown-linux-gnu/glibc-2.31-r3/work/build-default-ia64-unknown-linux-gnu-nptl/elf/dl-support.o.dt -MT /tmp/portage/cross-ia64-unknown-linux-gnu/glibc-2.31-r3/work/build-default-ia64-unknown-linux-gnu-nptl/elf/dl-support.o """ Might be an effect of default --enable-default-pie --enable-default-ssp. Or an effect of applied GCC patch: https://gcc.gnu.org/PR84553 I can try to extract smaller .c example that generates unlinkable GPREL22 against cross-section symbols if it's useful. $ LANG=C ia64-unknown-linux-gnu-gcc -v # Using built-in specs. COLLECT_GCC=/usr/bin/ia64-unknown-linux-gnu-gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/ia64-unknown-linux-gnu/10.1.0/lto-wrapper Target: ia64-unknown-linux-gnu Configured with: /tmp/portage-tmpdir/portage/cross-ia64-unknown-linux-gnu/gcc-10.1.0/work/gcc-10.1.0/configure --host=x86_64-pc-linux-gnu --target=ia64-unknown-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/ia64-unknown-linux-gnu/gcc-bin/10.1.0 --includedir=/usr/lib/gcc/ia64-unknown-linux-gnu/10.1.0/include --datadir=/usr/share/gcc-data/ia64-unknown-linux-gnu/10.1.0 --mandir=/usr/share/gcc-data/ia64-unknown-linux-gnu/10.1.0/man --infodir=/usr/share/gcc-data/ia64-unknown-linux-gnu/10.1.0/info --with-gxx-include-dir=/usr/lib/gcc/ia64-unknown-linux-gnu/10.1.0/include/g++-v10 --with-python-dir=/share/gcc-data/ia64-unknown-linux-gnu/10.1.0/python --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 10.1.0 p1' --disable-esp --enable-libstdcxx-time --enable-poison-system-directories --with-sysroot=/usr/ia64-unknown-linux-gnu --disable-bootstrap --enable-__cxa_atexit --enable-clocale=gnu --disable-multilib --disable-altivec --disable-fixed-point --enable-libgomp --disable-libmudflap --disable-libssp --disable-libada --disable-systemtap --disable-vtable-verify --disable-libvtv --without-zstd --enable-lto --without-isl --disable-libsanitizer --enable-default-pie --enable-default-ssp Thread model: posix Supported LTO compression algorithms: zlib gcc version 10.1.0 (Gentoo 10.1.0 p1) > > > > The difference between gcc-9 and gcc-10 is the way relocation is > > generated for ia64-specific symbol '_dl_sysinfo_break', defined as: > > > > ```c > > 32 #ifndef __ASSEMBLER__ > > 33 /* Don't declare this as a function---we want it's entry-point, not > > 34 it's function descriptor... */ > > 35 extern int _dl_sysinfo_break attribute_hidden; > > 36 # define DL_SYSINFO_DEFAULT ((uintptr_t) &_dl_sysinfo_break) > > 37 # define DL_SYSINFO_IMPLEMENTATION \ > > 38 asm (".text\n\t" \ > > 39 ".hidden _dl_sysinfo_break\n\t" \ > > 40 ".proc _dl_sysinfo_break\n\t" \ > > ``` > > > > Note: it's declared as ".sdata" (defined nearby GOT) but assumed > > to be defined in ".text" as it's really a direct function address. > > > > As a result generated relocation changed from: > > > > from `GPREL64I`: > > > > ``` > > 1390: 05 00 84 1e 98 11 [MLX] st8 [r15]=r33 > > 1391: GPREL64I .text > > 1396: 00 00 00 00 00 e0 movl r15=0x0;; > > 139c: 01 00 00 60 > > 13a0: 0b 78 04 1e 00 20 [MMI] add r15=r1,r15;; > > ``` > > > > to `GPREL22`: > > > > ``` > > if (GLRO(dl_sysinfo) == DL_SYSINFO_DEFAULT) > > > > 1320: 0b 80 00 1c 18 10 [MMI] ld8 r16=[r14];; > > 1322: GPREL22 .text > > 1326: 00 08 3d 30 23 e0 st8 [r15]=r33 > > 132c: 01 08 00 90 addl r15=0,r1;; > > ``` > > > > This change explicitly declares symbol to be in ".text" section. > > That allows gcc to generate far relocations. > > > > Regression tested on glibc-master and gcc-10.1.0 on rx3600. > > The rationale is sound, but the trick to define a function pointer a > data variable on text sections seems hacky and fragile. I still think > it could be a fix, but I think we should refactor and simplify > the over-enginnering of NEED_DL_SYSINFO/USE_DL_SYSINFO. > > > > > Bug: https://bugs.gentoo.org/723268 > > Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> > > --- > > sysdeps/unix/sysv/linux/ia64/dl-sysdep.h | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h b/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h > > index 78fa6dd2c9..e526e02ff4 100644 > > --- a/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h > > +++ b/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h > > @@ -32,7 +32,9 @@ > > #ifndef __ASSEMBLER__ > > /* Don't declare this as a function---we want it's entry-point, not > > it's function descriptor... */ > > -extern int _dl_sysinfo_break attribute_hidden; > > +/* Use section ".text" to force far GPREL64 relocation instead of > > + GPREL22 . */ > > +extern int _dl_sysinfo_break attribute_hidden __attribute__((section(".text"))); > > # define DL_SYSINFO_DEFAULT ((uintptr_t) &_dl_sysinfo_break) > > # define DL_SYSINFO_IMPLEMENTATION \ > > asm (".text\n\t" \ > >
On Sun, 31 May 2020 20:34:43 +0100 Sergei Trofimovich <slyich@gmail.com> wrote: > On Wed, 20 May 2020 16:45:03 -0300 > Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org> wrote: > > > On 16/05/2020 10:53, slyich--- via Libc-alpha wrote: > > > From: Sergei Trofimovich <slyfox@gentoo.org> > > > > > > gcc-10 enabled -fno-common by default. This caused glibc link failure: > > > > > > ``` > > > $ ia64-unknown-linux-gnu-gcc -pipe -O2 -nostdlib -nostartfiles \ > > > -static -o .../elf/sln ... > > > libc.a(dl-support.o): in function `setup_vdso': > > > glibc-2.31/elf/setup-vdso.h:116:(.text+0x1322): > > > relocation truncated to fit: GPREL22 against `.text' > > > collect2: error: ld returned 1 exit status > > > ``` > > > > I can't reproduce it with master (b6ad64b907ab00) with GCC 10.1.1 20200520. > > (built using build-many-glibcs.py). I tried to explicit use -fno-common on > > CFLAGS. Are you sing a non default compiler option? > > My apologies. Missed your email. > > The CFLAGS options should be default. Full command is: > > """ > ia64-unknown-linux-gnu-gcc -pipe -fdiagnostics-show-option -Wall -Wextra -Wstack-protector -O2 -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu dl-support.c -c -std=gnu11 -fgnu89-inline -pipe -fdiagnostics-show-option -Wall -Wextra -Wstack-protector -O2 -Wall -Wwrite-strings -Wundef -fmerge-all-constants -frounding-math -fno-stack-protector -Wstrict-prototypes -Wold-style-definition -fmath-errno -fpie -ftls-model=initial-exec -U_FORTIFY_SOURCE -I../include -I/tmp/portage/cross-ia64-unknown-linux-gnu/glibc-2.31-r3/work/build-default-ia64-unknown-linux-gnu-nptl/elf -I/tmp/portage/cross-ia64-unknown-linux-gnu/glibc-2.31-r3/work/build-default-ia64-unknown-linux-gnu-nptl -I../sysdeps/unix/sysv/linux/ia64 -I../sysdeps/ia64/nptl -I../sysdeps/unix/sysv/linux/wordsize-64 -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux -I../sysdeps/nptl -I../sysdeps/pthread -I../sysdeps/gnu -I../sysdeps/unix/inet -I../sysdeps/unix/sysv -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/ia64/fpu -I../sysdeps/ia64 -I../sysdeps/wordsize-64 -I../sysdeps/ieee754/float128 -I../sysdeps/ieee754/ldbl-96/include -I../sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754 -I../sysdeps/generic -I.. -I../libio -I. -nostdinc -isystem /usr/lib/gcc/ia64-unknown-linux-gnu/10.1.0/include -isystem /usr/lib/gcc/ia64-unknown-linux-gnu/10.1.0/include-fixed -isystem /usr/ia64-unknown-linux-gnu/usr/include -D_LIBC_REENTRANT -include /tmp/portage/cross-ia64-unknown-linux-gnu/glibc-2.31-r3/work/build-default-ia64-unknown-linux-gnu-nptl/libc-modules.h -DMODULE_NAME=libc -include ../include/libc-symbols.h -DPIC -DTOP_NAMESPACE=glibc -o /tmp/portage/cross-ia64-unknown-linux-gnu/glibc-2.31-r3/work/build-default-ia64-unknown-linux-gnu-nptl/elf/dl-support.o -MD -MP -MF /tmp/portage/cross-ia64-unknown-linux-gnu/glibc-2.31-r3/work/build-default-ia64-unknown-linux-gnu-nptl/elf/dl-support.o.dt -MT /tmp/portage/cross-ia64-unknown-linux-gnu/glibc-2.31-r3/work/build-default-ia64-unknown-linux-gnu-nptl/elf/dl-support.o > """ > > Might be an effect of default --enable-default-pie --enable-default-ssp. > Or an effect of applied GCC patch: https://gcc.gnu.org/PR84553 > > I can try to extract smaller .c example that generates unlinkable > GPREL22 against cross-section symbols if it's useful. > > $ LANG=C ia64-unknown-linux-gnu-gcc -v > # Using built-in specs. > COLLECT_GCC=/usr/bin/ia64-unknown-linux-gnu-gcc > COLLECT_LTO_WRAPPER=/usr/libexec/gcc/ia64-unknown-linux-gnu/10.1.0/lto-wrapper > Target: ia64-unknown-linux-gnu > Configured with: /tmp/portage-tmpdir/portage/cross-ia64-unknown-linux-gnu/gcc-10.1.0/work/gcc-10.1.0/configure --host=x86_64-pc-linux-gnu --target=ia64-unknown-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/ia64-unknown-linux-gnu/gcc-bin/10.1.0 --includedir=/usr/lib/gcc/ia64-unknown-linux-gnu/10.1.0/include --datadir=/usr/share/gcc-data/ia64-unknown-linux-gnu/10.1.0 --mandir=/usr/share/gcc-data/ia64-unknown-linux-gnu/10.1.0/man --infodir=/usr/share/gcc-data/ia64-unknown-linux-gnu/10.1.0/info --with-gxx-include-dir=/usr/lib/gcc/ia64-unknown-linux-gnu/10.1.0/include/g++-v10 --with-python-dir=/share/gcc-data/ia64-unknown-linux-gnu/10.1.0/python --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 10.1.0 p1' --disable-esp --enable-libstdcxx-time --enable-poison-system-directories --with-sysroot=/usr/ia64-unknown-linux-gnu --disable-bootstrap --enable-__cxa_atexit --enable-clocale=gnu --disable-multilib --disable-altivec --disable-fixed-point --enable-libgomp --disable-libmudflap --disable-libssp --disable-libada --disable-systemtap --disable-vtable-verify --disable-libvtv --without-zstd --enable-lto --without-isl --disable-libsanitizer --enable-default-pie --enable-default-ssp > Thread model: posix > Supported LTO compression algorithms: zlib > gcc version 10.1.0 (Gentoo 10.1.0 p1) Tl;DR: I think I managed to write small reproducer, and I think it illustrates that my fix is not effective and still breaks in some setups :( I hope that helps. Detailed example: $ cat a.c // code reference, avoids function descriptor #ifdef USE_TEXT extern int asm_f __attribute__((visibility("hidden"))) __attribute__((section(".text"))); #else extern int asm_f __attribute__((visibility("hidden"))); #endif long asm_f_ref; asm ( ".text\n\t" \ ".hidden asm_f\n\t" ".proc asm_f\n\t" "asm_f:\n\t" ".prologue\n\t" ".body\n\t" "br.ret.sptk.many b0;\n\t" ".endp asm_f\n\t" ".previous" ); void _start() { asm_f_ref = (unsigned long)&asm_f; } $ cat mk.bash #!/bin/bash local_cc_root=/home/slyfox/dev/git/gcc-ia64/gcc for define in "" "-DUSE_TEST"; do for static in "" "-static"; do for fpie in "" "-fPIE"; do for common in "-fcommon" "-fno-common"; do echo "" for cc in "ia64-unknown-linux-gnu-gcc" "${local_cc_root}/xgcc -B${local_cc_root}"; do echo "define=${define} static=${static} common=${common} fpie=${fpie} cc=${cc}" LANG=C $cc a.c -o a -O2 -nostdlib -nostartfiles ${static} ${define} ${fpie} ${common} done done done done done Running: $ LANG=C ./mk.bash define= static= common=-fcommon fpie= cc=ia64-unknown-linux-gnu-gcc define= static= common=-fcommon fpie= cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc define= static= common=-fno-common fpie= cc=ia64-unknown-linux-gnu-gcc define= static= common=-fno-common fpie= cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc /tmp/ccBYnt9X.o: in function `_start': a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' collect2: error: ld returned 1 exit status define= static= common=-fcommon fpie=-fPIE cc=ia64-unknown-linux-gnu-gcc define= static= common=-fcommon fpie=-fPIE cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc define= static= common=-fno-common fpie=-fPIE cc=ia64-unknown-linux-gnu-gcc define= static= common=-fno-common fpie=-fPIE cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc /tmp/ccH3sdkO.o: in function `_start': a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' collect2: error: ld returned 1 exit status define= static=-static common=-fcommon fpie= cc=ia64-unknown-linux-gnu-gcc define= static=-static common=-fcommon fpie= cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc define= static=-static common=-fno-common fpie= cc=ia64-unknown-linux-gnu-gcc /tmp/ccUvQ1vf.o: in function `_start': a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' collect2: error: ld returned 1 exit status define= static=-static common=-fno-common fpie= cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc /tmp/cc9epOsD.o: in function `_start': a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' collect2: error: ld returned 1 exit status define= static=-static common=-fcommon fpie=-fPIE cc=ia64-unknown-linux-gnu-gcc define= static=-static common=-fcommon fpie=-fPIE cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc define= static=-static common=-fno-common fpie=-fPIE cc=ia64-unknown-linux-gnu-gcc /tmp/ccPXdLl4.o: in function `_start': a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' collect2: error: ld returned 1 exit status define= static=-static common=-fno-common fpie=-fPIE cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc /tmp/cca5Gl7p.o: in function `_start': a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' collect2: error: ld returned 1 exit status define=-DUSE_TEST static= common=-fcommon fpie= cc=ia64-unknown-linux-gnu-gcc define=-DUSE_TEST static= common=-fcommon fpie= cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc define=-DUSE_TEST static= common=-fno-common fpie= cc=ia64-unknown-linux-gnu-gcc define=-DUSE_TEST static= common=-fno-common fpie= cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc /tmp/ccodz56d.o: in function `_start': a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' collect2: error: ld returned 1 exit status define=-DUSE_TEST static= common=-fcommon fpie=-fPIE cc=ia64-unknown-linux-gnu-gcc define=-DUSE_TEST static= common=-fcommon fpie=-fPIE cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc define=-DUSE_TEST static= common=-fno-common fpie=-fPIE cc=ia64-unknown-linux-gnu-gcc define=-DUSE_TEST static= common=-fno-common fpie=-fPIE cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc /tmp/cc7dWmZ3.o: in function `_start': a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' collect2: error: ld returned 1 exit status define=-DUSE_TEST static=-static common=-fcommon fpie= cc=ia64-unknown-linux-gnu-gcc define=-DUSE_TEST static=-static common=-fcommon fpie= cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc define=-DUSE_TEST static=-static common=-fno-common fpie= cc=ia64-unknown-linux-gnu-gcc /tmp/ccJ2hnsw.o: in function `_start': a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' collect2: error: ld returned 1 exit status define=-DUSE_TEST static=-static common=-fno-common fpie= cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc /tmp/ccko7sNT.o: in function `_start': a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' collect2: error: ld returned 1 exit status define=-DUSE_TEST static=-static common=-fcommon fpie=-fPIE cc=ia64-unknown-linux-gnu-gcc define=-DUSE_TEST static=-static common=-fcommon fpie=-fPIE cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc define=-DUSE_TEST static=-static common=-fno-common fpie=-fPIE cc=ia64-unknown-linux-gnu-gcc /tmp/cchRq1Nl.o: in function `_start': a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' collect2: error: ld returned 1 exit status define=-DUSE_TEST static=-static common=-fno-common fpie=-fPIE cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc /tmp/ccgQ5Y6G.o: in function `_start': a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' collect2: error: ld returned 1 exit status Local compiler was build from today's gcc-master as: #!/bin/bash ../gcc/configure \ \ --build=x86_64-pc-linux-gnu \ --host=x86_64-pc-linux-gnu \ --target=ia64-unknown-linux-gnu \ \ --with-sysroot=/usr/ia64-unknown-linux-gnu \ --enable-languages=c \ --disable-bootstrap \ --prefix="$(pwd)/../gcc-ia64-installed" \ \ --enable-languages=c \ --disable-nls \ \ CFLAGS="-O1" CXXFLAGS="-O1" LDFLAGS="-O1" \ "$@"
On 31/05/2020 18:40, Sergei Trofimovich wrote: > On Sun, 31 May 2020 20:34:43 +0100 > Sergei Trofimovich <slyich@gmail.com> wrote: > >> On Wed, 20 May 2020 16:45:03 -0300 >> Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org> wrote: >> >>> On 16/05/2020 10:53, slyich--- via Libc-alpha wrote: >>>> From: Sergei Trofimovich <slyfox@gentoo.org> >>>> >>>> gcc-10 enabled -fno-common by default. This caused glibc link failure: >>>> >>>> ``` >>>> $ ia64-unknown-linux-gnu-gcc -pipe -O2 -nostdlib -nostartfiles \ >>>> -static -o .../elf/sln ... >>>> libc.a(dl-support.o): in function `setup_vdso': >>>> glibc-2.31/elf/setup-vdso.h:116:(.text+0x1322): >>>> relocation truncated to fit: GPREL22 against `.text' >>>> collect2: error: ld returned 1 exit status >>>> ``` >>> >>> I can't reproduce it with master (b6ad64b907ab00) with GCC 10.1.1 20200520. >>> (built using build-many-glibcs.py). I tried to explicit use -fno-common on >>> CFLAGS. Are you sing a non default compiler option? >> >> My apologies. Missed your email. >> >> The CFLAGS options should be default. Full command is: >> >> """ >> ia64-unknown-linux-gnu-gcc -pipe -fdiagnostics-show-option -Wall -Wextra -Wstack-protector -O2 -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu dl-support.c -c -std=gnu11 -fgnu89-inline -pipe -fdiagnostics-show-option -Wall -Wextra -Wstack-protector -O2 -Wall -Wwrite-strings -Wundef -fmerge-all-constants -frounding-math -fno-stack-protector -Wstrict-prototypes -Wold-style-definition -fmath-errno -fpie -ftls-model=initial-exec -U_FORTIFY_SOURCE -I../include -I/tmp/portage/cross-ia64-unknown-linux-gnu/glibc-2.31-r3/work/build-default-ia64-unknown-linux-gnu-nptl/elf -I/tmp/portage/cross-ia64-unknown-linux-gnu/glibc-2.31-r3/work/build-default-ia64-unknown-linux-gnu-nptl -I../sysdeps/unix/sysv/linux/ia64 -I../sysdeps/ia64/nptl -I../sysdeps/unix/sysv/linux/wordsize-64 -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux -I../sysdeps/nptl -I../sysdeps/pthread -I../sysdeps/gnu -I../sysdeps/unix/inet -I../sysdeps/unix/sysv -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/ia64/fpu -I../sysdeps/ia64 -I../sysdeps/wordsize-64 -I../sysdeps/ieee754/float128 -I../sysdeps/ieee754/ldbl-96/include -I../sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754 -I../sysdeps/generic -I.. -I../libio -I. -nostdinc -isystem /usr/lib/gcc/ia64-unknown-linux-gnu/10.1.0/include -isystem /usr/lib/gcc/ia64-unknown-linux-gnu/10.1.0/include-fixed -isystem /usr/ia64-unknown-linux-gnu/usr/include -D_LIBC_REENTRANT -include /tmp/portage/cross-ia64-unknown-linux-gnu/glibc-2.31-r3/work/build-default-ia64-unknown-linux-gnu-nptl/libc-modules.h -DMODULE_NAME=libc -include ../include/libc-symbols.h -DPIC -DTOP_NAMESPACE=glibc -o /tmp/portage/cross-ia64-unknown-linux-gnu/glibc-2.31-r3/work/build-default-ia64-unknown-linux-gnu-nptl/elf/dl-support.o -MD -MP -MF /tmp/portage/cross-ia64-unknown-linux-gnu/glibc-2.31-r3/work/build-default-ia64-unknown-linux-gnu-nptl/elf/dl-support.o.dt -MT /tmp/portage/cross-ia64-unknown-linux-gnu/glibc-2.31-r3/work/build-default-ia64-unknown-linux-gnu-nptl/elf/dl-support.o >> """ >> >> Might be an effect of default --enable-default-pie --enable-default-ssp. >> Or an effect of applied GCC patch: https://gcc.gnu.org/PR84553 >> >> I can try to extract smaller .c example that generates unlinkable >> GPREL22 against cross-section symbols if it's useful. >> >> $ LANG=C ia64-unknown-linux-gnu-gcc -v >> # Using built-in specs. >> COLLECT_GCC=/usr/bin/ia64-unknown-linux-gnu-gcc >> COLLECT_LTO_WRAPPER=/usr/libexec/gcc/ia64-unknown-linux-gnu/10.1.0/lto-wrapper >> Target: ia64-unknown-linux-gnu >> Configured with: /tmp/portage-tmpdir/portage/cross-ia64-unknown-linux-gnu/gcc-10.1.0/work/gcc-10.1.0/configure --host=x86_64-pc-linux-gnu --target=ia64-unknown-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/ia64-unknown-linux-gnu/gcc-bin/10.1.0 --includedir=/usr/lib/gcc/ia64-unknown-linux-gnu/10.1.0/include --datadir=/usr/share/gcc-data/ia64-unknown-linux-gnu/10.1.0 --mandir=/usr/share/gcc-data/ia64-unknown-linux-gnu/10.1.0/man --infodir=/usr/share/gcc-data/ia64-unknown-linux-gnu/10.1.0/info --with-gxx-include-dir=/usr/lib/gcc/ia64-unknown-linux-gnu/10.1.0/include/g++-v10 --with-python-dir=/share/gcc-data/ia64-unknown-linux-gnu/10.1.0/python --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 10.1.0 p1' --disable-esp --enable-libstdcxx-time --enable-poison-system-directories --with-sysroot=/usr/ia64-unknown-linux-gnu --disable-bootstrap --enable-__cxa_atexit --enable-clocale=gnu --disable-multilib --disable-altivec --disable-fixed-point --enable-libgomp --disable-libmudflap --disable-libssp --disable-libada --disable-systemtap --disable-vtable-verify --disable-libvtv --without-zstd --enable-lto --without-isl --disable-libsanitizer --enable-default-pie --enable-default-ssp >> Thread model: posix >> Supported LTO compression algorithms: zlib >> gcc version 10.1.0 (Gentoo 10.1.0 p1) > > Tl;DR: > > I think I managed to write small reproducer, and I think it illustrates > that my fix is not effective and still breaks in some setups :( In fact I think your testcase has a small typo below ;) > > I hope that helps. > > Detailed example: > > $ cat a.c > // code reference, avoids function descriptor > #ifdef USE_TEXT > extern int asm_f __attribute__((visibility("hidden"))) __attribute__((section(".text"))); > #else > extern int asm_f __attribute__((visibility("hidden"))); > #endif > > long asm_f_ref; > > asm ( > ".text\n\t" \ > ".hidden asm_f\n\t" > ".proc asm_f\n\t" > "asm_f:\n\t" > ".prologue\n\t" > ".body\n\t" > "br.ret.sptk.many b0;\n\t" > ".endp asm_f\n\t" > ".previous" > ); > > void _start() { > asm_f_ref = (unsigned long)&asm_f; > } > > $ cat mk.bash > #!/bin/bash > > local_cc_root=/home/slyfox/dev/git/gcc-ia64/gcc > > for define in "" "-DUSE_TEST"; do I think it should be USE_TEXT instead. > for static in "" "-static"; do > for fpie in "" "-fPIE"; do > for common in "-fcommon" "-fno-common"; do > echo "" > for cc in "ia64-unknown-linux-gnu-gcc" "${local_cc_root}/xgcc -B${local_cc_root}"; do > echo "define=${define} static=${static} common=${common} fpie=${fpie} cc=${cc}" > LANG=C $cc a.c -o a -O2 -nostdlib -nostartfiles ${static} ${define} ${fpie} ${common} > done > done > done > done > done > > Running: > > $ LANG=C ./mk.bash > > define= static= common=-fcommon fpie= cc=ia64-unknown-linux-gnu-gcc > define= static= common=-fcommon fpie= cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > > define= static= common=-fno-common fpie= cc=ia64-unknown-linux-gnu-gcc > define= static= common=-fno-common fpie= cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > /tmp/ccBYnt9X.o: in function `_start': > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > collect2: error: ld returned 1 exit status > > define= static= common=-fcommon fpie=-fPIE cc=ia64-unknown-linux-gnu-gcc > define= static= common=-fcommon fpie=-fPIE cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > > define= static= common=-fno-common fpie=-fPIE cc=ia64-unknown-linux-gnu-gcc > define= static= common=-fno-common fpie=-fPIE cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > /tmp/ccH3sdkO.o: in function `_start': > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > collect2: error: ld returned 1 exit status > > define= static=-static common=-fcommon fpie= cc=ia64-unknown-linux-gnu-gcc > define= static=-static common=-fcommon fpie= cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > > define= static=-static common=-fno-common fpie= cc=ia64-unknown-linux-gnu-gcc > /tmp/ccUvQ1vf.o: in function `_start': > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > collect2: error: ld returned 1 exit status > define= static=-static common=-fno-common fpie= cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > /tmp/cc9epOsD.o: in function `_start': > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > collect2: error: ld returned 1 exit status > > define= static=-static common=-fcommon fpie=-fPIE cc=ia64-unknown-linux-gnu-gcc > define= static=-static common=-fcommon fpie=-fPIE cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > > define= static=-static common=-fno-common fpie=-fPIE cc=ia64-unknown-linux-gnu-gcc > /tmp/ccPXdLl4.o: in function `_start': > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > collect2: error: ld returned 1 exit status > define= static=-static common=-fno-common fpie=-fPIE cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > /tmp/cca5Gl7p.o: in function `_start': > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > collect2: error: ld returned 1 exit status > > define=-DUSE_TEST static= common=-fcommon fpie= cc=ia64-unknown-linux-gnu-gcc > define=-DUSE_TEST static= common=-fcommon fpie= cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > > define=-DUSE_TEST static= common=-fno-common fpie= cc=ia64-unknown-linux-gnu-gcc > define=-DUSE_TEST static= common=-fno-common fpie= cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > /tmp/ccodz56d.o: in function `_start': > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > collect2: error: ld returned 1 exit status > > define=-DUSE_TEST static= common=-fcommon fpie=-fPIE cc=ia64-unknown-linux-gnu-gcc > define=-DUSE_TEST static= common=-fcommon fpie=-fPIE cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > > define=-DUSE_TEST static= common=-fno-common fpie=-fPIE cc=ia64-unknown-linux-gnu-gcc > define=-DUSE_TEST static= common=-fno-common fpie=-fPIE cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > /tmp/cc7dWmZ3.o: in function `_start': > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > collect2: error: ld returned 1 exit status > > define=-DUSE_TEST static=-static common=-fcommon fpie= cc=ia64-unknown-linux-gnu-gcc > define=-DUSE_TEST static=-static common=-fcommon fpie= cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > > define=-DUSE_TEST static=-static common=-fno-common fpie= cc=ia64-unknown-linux-gnu-gcc > /tmp/ccJ2hnsw.o: in function `_start': > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > collect2: error: ld returned 1 exit status > define=-DUSE_TEST static=-static common=-fno-common fpie= cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > /tmp/ccko7sNT.o: in function `_start': > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > collect2: error: ld returned 1 exit status > > define=-DUSE_TEST static=-static common=-fcommon fpie=-fPIE cc=ia64-unknown-linux-gnu-gcc > define=-DUSE_TEST static=-static common=-fcommon fpie=-fPIE cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > > define=-DUSE_TEST static=-static common=-fno-common fpie=-fPIE cc=ia64-unknown-linux-gnu-gcc > /tmp/cchRq1Nl.o: in function `_start': > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > collect2: error: ld returned 1 exit status > define=-DUSE_TEST static=-static common=-fno-common fpie=-fPIE cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > /tmp/ccgQ5Y6G.o: in function `_start': > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > collect2: error: ld returned 1 exit status With the above fix I am seeing: --- define= static= common=-fcommon fpie= cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc define= static= common=-fno-common fpie= cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc /tmp/ccwUMGjK.o: in function `_start': a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' collect2: error: ld returned 1 exit status define= static= common=-fcommon fpie=-fPIE cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc define= static= common=-fno-common fpie=-fPIE cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc /tmp/cc9nPVOO.o: in function `_start': a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' collect2: error: ld returned 1 exit status define= static=-static common=-fcommon fpie= cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc define= static=-static common=-fno-common fpie= cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc /tmp/ccV4QyrT.o: in function `_start': a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' collect2: error: ld returned 1 exit status define= static=-static common=-fcommon fpie=-fPIE cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc define= static=-static common=-fno-common fpie=-fPIE cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc /tmp/ccSgHDDW.o: in function `_start': a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' collect2: error: ld returned 1 exit status define=-DUSE_TEXT static= common=-fcommon fpie= cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc define=-DUSE_TEXT static= common=-fno-common fpie= cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc define=-DUSE_TEXT static= common=-fcommon fpie=-fPIE cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc define=-DUSE_TEXT static= common=-fno-common fpie=-fPIE cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc define=-DUSE_TEXT static=-static common=-fcommon fpie= cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc define=-DUSE_TEXT static=-static common=-fno-common fpie= cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc define=-DUSE_TEXT static=-static common=-fcommon fpie=-fPIE cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc define=-DUSE_TEXT static=-static common=-fno-common fpie=-fPIE cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc --- So it does seem that using the __attribute__((section(".text"))) does help ia64 in this case. Due the current status I think it should be a better and simpler fix. The alternative would be remove the _dl_sysinfo_break and rewrite the syscall mechanism (in both ASM pre-processor and INTERNAL_SYSCALL macros) to check if the _dl_sysinfo is set (meaning a vDSO is present) and issuing the syscall with brk if not. It will most likely increase the code size and add some latency.
On Fri, 5 Jun 2020 15:44:24 -0300 Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote: > On 31/05/2020 18:40, Sergei Trofimovich wrote: > > On Sun, 31 May 2020 20:34:43 +0100 > > Sergei Trofimovich <slyich@gmail.com> wrote: > > > >> On Wed, 20 May 2020 16:45:03 -0300 > >> Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org> wrote: > >> > >>> On 16/05/2020 10:53, slyich--- via Libc-alpha wrote: > >>>> From: Sergei Trofimovich <slyfox@gentoo.org> > >>>> > >>>> gcc-10 enabled -fno-common by default. This caused glibc link failure: > >>>> > >>>> ``` > >>>> $ ia64-unknown-linux-gnu-gcc -pipe -O2 -nostdlib -nostartfiles \ > >>>> -static -o .../elf/sln ... > >>>> libc.a(dl-support.o): in function `setup_vdso': > >>>> glibc-2.31/elf/setup-vdso.h:116:(.text+0x1322): > >>>> relocation truncated to fit: GPREL22 against `.text' > >>>> collect2: error: ld returned 1 exit status > >>>> ``` > >>> > >>> I can't reproduce it with master (b6ad64b907ab00) with GCC 10.1.1 20200520. > >>> (built using build-many-glibcs.py). I tried to explicit use -fno-common on > >>> CFLAGS. Are you sing a non default compiler option? > >> > >> My apologies. Missed your email. > >> > >> The CFLAGS options should be default. Full command is: > >> > >> """ > >> ia64-unknown-linux-gnu-gcc -pipe -fdiagnostics-show-option -Wall -Wextra -Wstack-protector -O2 -Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu dl-support.c -c -std=gnu11 -fgnu89-inline -pipe -fdiagnostics-show-option -Wall -Wextra -Wstack-protector -O2 -Wall -Wwrite-strings -Wundef -fmerge-all-constants -frounding-math -fno-stack-protector -Wstrict-prototypes -Wold-style-definition -fmath-errno -fpie -ftls-model=initial-exec -U_FORTIFY_SOURCE -I../include -I/tmp/portage/cross-ia64-unknown-linux-gnu/glibc-2.31-r3/work/build-default-ia64-unknown-linux-gnu-nptl/elf -I/tmp/portage/cross-ia64-unknown-linux-gnu/glibc-2.31-r3/work/build-default-ia64-unknown-linux-gnu-nptl -I../sysdeps/unix/sysv/linux/ia64 -I../sysdeps/ia64/nptl -I../sysdeps/unix/sysv/linux/wordsize-64 -I../sysdeps/unix/sysv/linux/include -I../sysdeps/unix/sysv/linux -I../sysdeps/nptl -I../sysdeps/pthread -I../sysdeps/gnu -I../sysdeps/unix/inet -I../sysdeps/unix/sysv -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/ia64/fpu -I../sysdeps/ia64 -I../sysdeps/wordsize-64 -I../sysdeps/ieee754/float128 -I../sysdeps/ieee754/ldbl-96/include -I../sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754 -I../sysdeps/generic -I.. -I../libio -I. -nostdinc -isystem /usr/lib/gcc/ia64-unknown-linux-gnu/10.1.0/include -isystem /usr/lib/gcc/ia64-unknown-linux-gnu/10.1.0/include-fixed -isystem /usr/ia64-unknown-linux-gnu/usr/include -D_LIBC_REENTRANT -include /tmp/portage/cross-ia64-unknown-linux-gnu/glibc-2.31-r3/work/build-default-ia64-unknown-linux-gnu-nptl/libc-modules.h -DMODULE_NAME=libc -include ../include/libc-symbols.h -DPIC -DTOP_NAMESPACE=glibc -o /tmp/portage/cross-ia64-unknown-linux-gnu/glibc-2.31-r3/work/build-default-ia64-unknown-linux-gnu-nptl/elf/dl-support.o -MD -MP -MF /tmp/portage/cross-ia64-unknown-linux-gnu/glibc-2.31-r3/work/build-default-ia64-unknown-linux-gnu-nptl/elf/dl-support.o.dt -MT /tmp/portage/cross-ia64-unknown-linux-gnu/glibc-2.31-r3/work/build-default-ia64-unknown-linux-gnu-nptl/elf/dl-support.o > >> """ > >> > >> Might be an effect of default --enable-default-pie --enable-default-ssp. > >> Or an effect of applied GCC patch: https://gcc.gnu.org/PR84553 > >> > >> I can try to extract smaller .c example that generates unlinkable > >> GPREL22 against cross-section symbols if it's useful. > >> > >> $ LANG=C ia64-unknown-linux-gnu-gcc -v > >> # Using built-in specs. > >> COLLECT_GCC=/usr/bin/ia64-unknown-linux-gnu-gcc > >> COLLECT_LTO_WRAPPER=/usr/libexec/gcc/ia64-unknown-linux-gnu/10.1.0/lto-wrapper > >> Target: ia64-unknown-linux-gnu > >> Configured with: /tmp/portage-tmpdir/portage/cross-ia64-unknown-linux-gnu/gcc-10.1.0/work/gcc-10.1.0/configure --host=x86_64-pc-linux-gnu --target=ia64-unknown-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/ia64-unknown-linux-gnu/gcc-bin/10.1.0 --includedir=/usr/lib/gcc/ia64-unknown-linux-gnu/10.1.0/include --datadir=/usr/share/gcc-data/ia64-unknown-linux-gnu/10.1.0 --mandir=/usr/share/gcc-data/ia64-unknown-linux-gnu/10.1.0/man --infodir=/usr/share/gcc-data/ia64-unknown-linux-gnu/10.1.0/info --with-gxx-include-dir=/usr/lib/gcc/ia64-unknown-linux-gnu/10.1.0/include/g++-v10 --with-python-dir=/share/gcc-data/ia64-unknown-linux-gnu/10.1.0/python --enable-languages=c,c++,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 10.1.0 p1' --disable-esp --enable-libstdcxx-time --enable-poison-system-directories --with-sysroot=/usr/ia64-unknown-linux-gnu --disable-bootstrap --enable-__cxa_atexit --enable-clocale=gnu --disable-multilib --disable-altivec --disable-fixed-point --enable-libgomp --disable-libmudflap --disable-libssp --disable-libada --disable-systemtap --disable-vtable-verify --disable-libvtv --without-zstd --enable-lto --without-isl --disable-libsanitizer --enable-default-pie --enable-default-ssp > >> Thread model: posix > >> Supported LTO compression algorithms: zlib > >> gcc version 10.1.0 (Gentoo 10.1.0 p1) > > > > Tl;DR: > > > > I think I managed to write small reproducer, and I think it illustrates > > that my fix is not effective and still breaks in some setups :( > > In fact I think your testcase has a small typo below ;) Gah, so simple! Thank you! > > > > I hope that helps. > > > > Detailed example: > > > > $ cat a.c > > // code reference, avoids function descriptor > > #ifdef USE_TEXT > > extern int asm_f __attribute__((visibility("hidden"))) __attribute__((section(".text"))); > > #else > > extern int asm_f __attribute__((visibility("hidden"))); > > #endif > > > > long asm_f_ref; > > > > asm ( > > ".text\n\t" \ > > ".hidden asm_f\n\t" > > ".proc asm_f\n\t" > > "asm_f:\n\t" > > ".prologue\n\t" > > ".body\n\t" > > "br.ret.sptk.many b0;\n\t" > > ".endp asm_f\n\t" > > ".previous" > > ); > > > > void _start() { > > asm_f_ref = (unsigned long)&asm_f; > > } > > > > $ cat mk.bash > > #!/bin/bash > > > > local_cc_root=/home/slyfox/dev/git/gcc-ia64/gcc > > > > for define in "" "-DUSE_TEST"; do > > I think it should be USE_TEXT instead. > > > for static in "" "-static"; do > > for fpie in "" "-fPIE"; do > > for common in "-fcommon" "-fno-common"; do > > echo "" > > for cc in "ia64-unknown-linux-gnu-gcc" "${local_cc_root}/xgcc -B${local_cc_root}"; do > > echo "define=${define} static=${static} common=${common} fpie=${fpie} cc=${cc}" > > LANG=C $cc a.c -o a -O2 -nostdlib -nostartfiles ${static} ${define} ${fpie} ${common} > > done > > done > > done > > done > > done > > > > Running: > > > > $ LANG=C ./mk.bash > > > > define= static= common=-fcommon fpie= cc=ia64-unknown-linux-gnu-gcc > > define= static= common=-fcommon fpie= cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > > > > define= static= common=-fno-common fpie= cc=ia64-unknown-linux-gnu-gcc > > define= static= common=-fno-common fpie= cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > > /tmp/ccBYnt9X.o: in function `_start': > > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > > collect2: error: ld returned 1 exit status > > > > define= static= common=-fcommon fpie=-fPIE cc=ia64-unknown-linux-gnu-gcc > > define= static= common=-fcommon fpie=-fPIE cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > > > > define= static= common=-fno-common fpie=-fPIE cc=ia64-unknown-linux-gnu-gcc > > define= static= common=-fno-common fpie=-fPIE cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > > /tmp/ccH3sdkO.o: in function `_start': > > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > > collect2: error: ld returned 1 exit status > > > > define= static=-static common=-fcommon fpie= cc=ia64-unknown-linux-gnu-gcc > > define= static=-static common=-fcommon fpie= cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > > > > define= static=-static common=-fno-common fpie= cc=ia64-unknown-linux-gnu-gcc > > /tmp/ccUvQ1vf.o: in function `_start': > > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > > collect2: error: ld returned 1 exit status > > define= static=-static common=-fno-common fpie= cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > > /tmp/cc9epOsD.o: in function `_start': > > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > > collect2: error: ld returned 1 exit status > > > > define= static=-static common=-fcommon fpie=-fPIE cc=ia64-unknown-linux-gnu-gcc > > define= static=-static common=-fcommon fpie=-fPIE cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > > > > define= static=-static common=-fno-common fpie=-fPIE cc=ia64-unknown-linux-gnu-gcc > > /tmp/ccPXdLl4.o: in function `_start': > > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > > collect2: error: ld returned 1 exit status > > define= static=-static common=-fno-common fpie=-fPIE cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > > /tmp/cca5Gl7p.o: in function `_start': > > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > > collect2: error: ld returned 1 exit status > > > > define=-DUSE_TEST static= common=-fcommon fpie= cc=ia64-unknown-linux-gnu-gcc > > define=-DUSE_TEST static= common=-fcommon fpie= cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > > > > define=-DUSE_TEST static= common=-fno-common fpie= cc=ia64-unknown-linux-gnu-gcc > > define=-DUSE_TEST static= common=-fno-common fpie= cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > > /tmp/ccodz56d.o: in function `_start': > > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > > collect2: error: ld returned 1 exit status > > > > define=-DUSE_TEST static= common=-fcommon fpie=-fPIE cc=ia64-unknown-linux-gnu-gcc > > define=-DUSE_TEST static= common=-fcommon fpie=-fPIE cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > > > > define=-DUSE_TEST static= common=-fno-common fpie=-fPIE cc=ia64-unknown-linux-gnu-gcc > > define=-DUSE_TEST static= common=-fno-common fpie=-fPIE cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > > /tmp/cc7dWmZ3.o: in function `_start': > > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > > collect2: error: ld returned 1 exit status > > > > define=-DUSE_TEST static=-static common=-fcommon fpie= cc=ia64-unknown-linux-gnu-gcc > > define=-DUSE_TEST static=-static common=-fcommon fpie= cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > > > > define=-DUSE_TEST static=-static common=-fno-common fpie= cc=ia64-unknown-linux-gnu-gcc > > /tmp/ccJ2hnsw.o: in function `_start': > > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > > collect2: error: ld returned 1 exit status > > define=-DUSE_TEST static=-static common=-fno-common fpie= cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > > /tmp/ccko7sNT.o: in function `_start': > > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > > collect2: error: ld returned 1 exit status > > > > define=-DUSE_TEST static=-static common=-fcommon fpie=-fPIE cc=ia64-unknown-linux-gnu-gcc > > define=-DUSE_TEST static=-static common=-fcommon fpie=-fPIE cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > > > > define=-DUSE_TEST static=-static common=-fno-common fpie=-fPIE cc=ia64-unknown-linux-gnu-gcc > > /tmp/cchRq1Nl.o: in function `_start': > > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > > collect2: error: ld returned 1 exit status > > define=-DUSE_TEST static=-static common=-fno-common fpie=-fPIE cc=/home/slyfox/dev/git/gcc-ia64/gcc/xgcc -B/home/slyfox/dev/git/gcc-ia64/gcc > > /tmp/ccgQ5Y6G.o: in function `_start': > > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > > collect2: error: ld returned 1 exit status > > With the above fix I am seeing: > > --- > define= static= common=-fcommon fpie= cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc > > define= static= common=-fno-common fpie= cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc > /tmp/ccwUMGjK.o: in function `_start': > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > collect2: error: ld returned 1 exit status > > define= static= common=-fcommon fpie=-fPIE cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc > > define= static= common=-fno-common fpie=-fPIE cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc > /tmp/cc9nPVOO.o: in function `_start': > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > collect2: error: ld returned 1 exit status > > define= static=-static common=-fcommon fpie= cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc > > define= static=-static common=-fno-common fpie= cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc > /tmp/ccV4QyrT.o: in function `_start': > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > collect2: error: ld returned 1 exit status > > define= static=-static common=-fcommon fpie=-fPIE cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc > > define= static=-static common=-fno-common fpie=-fPIE cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc > /tmp/ccSgHDDW.o: in function `_start': > a.c:(.text+0x42): relocation truncated to fit: GPREL22 against `.text' > collect2: error: ld returned 1 exit status > > define=-DUSE_TEXT static= common=-fcommon fpie= cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc > > define=-DUSE_TEXT static= common=-fno-common fpie= cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc > > define=-DUSE_TEXT static= common=-fcommon fpie=-fPIE cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc > > define=-DUSE_TEXT static= common=-fno-common fpie=-fPIE cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc > > define=-DUSE_TEXT static=-static common=-fcommon fpie= cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc > > define=-DUSE_TEXT static=-static common=-fno-common fpie= cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc > > define=-DUSE_TEXT static=-static common=-fcommon fpie=-fPIE cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc > > define=-DUSE_TEXT static=-static common=-fno-common fpie=-fPIE cc=/home/azanella/toolchain/install/compilers/ia64-linux-gnu/bin/ia64-glibc-linux-gnu-gcc > --- > > So it does seem that using the __attribute__((section(".text"))) does help ia64 > in this case. Due the current status I think it should be a better and > simpler fix. I agree. > The alternative would be remove the _dl_sysinfo_break and rewrite the syscall > mechanism (in both ASM pre-processor and INTERNAL_SYSCALL macros) to check > if the _dl_sysinfo is set (meaning a vDSO is present) and issuing the syscall > with brk if not. It will most likely increase the code size and add some > latency. I volunteer to convert to asm call when it breaks next time :)
diff --git a/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h b/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h index 78fa6dd2c9..e526e02ff4 100644 --- a/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h +++ b/sysdeps/unix/sysv/linux/ia64/dl-sysdep.h @@ -32,7 +32,9 @@ #ifndef __ASSEMBLER__ /* Don't declare this as a function---we want it's entry-point, not it's function descriptor... */ -extern int _dl_sysinfo_break attribute_hidden; +/* Use section ".text" to force far GPREL64 relocation instead of + GPREL22 . */ +extern int _dl_sysinfo_break attribute_hidden __attribute__((section(".text"))); # define DL_SYSINFO_DEFAULT ((uintptr_t) &_dl_sysinfo_break) # define DL_SYSINFO_IMPLEMENTATION \ asm (".text\n\t" \