build failure on ia64 (+ patch), "relocation truncated to fit: GPREL22 against `.text'"

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Sun Jul 30 00:08:34 GMT 2023



On 29/07/23 15:34, Andreas K. Huettel via Libc-alpha wrote:
> When testing a manual build on ia64 we ran (on two different Gentoo machines) into
> https://bugs.gentoo.org/723268
> https://sourceware.org/pipermail/libc-alpha/2020-May/114028.html
> 
> gcc -o /home/dilfridge/glibc_build/support/test-run-command -nostdlib -nostartfiles -static      /home/dilfridge/glibc_build/csu/crt1.o /home/dilfridge/glibc_build/csu/crti.o `gcc  --print-file-name=crtbegin.o` /home/dilfridge/glibc_build/support/test-run-command.o /home/dilfridge/glibc_build/elf/static-stubs.o /home/dilfridge/glibc_build/support/libsupport_nonshared.a  -Wl,--start-group /home/dilfridge/glibc_build/libc.a -lgcc  -Wl,--end-group `gcc  --print-file-name=crtend.o` /home/dilfridge/glibc_build/csu/crtn.o
> /usr/lib/gcc/ia64-unknown-linux-gnu/13/../../../../ia64-unknown-linux-gnu/bin/ld: warning: -z relro ignored
> /home/dilfridge/glibc_build/libc.a(dl-support.o): in function `_dl_aux_init':
> /home/dilfridge/glibc/elf/dl-support.c:239:(.text+0x51): relocation truncated to fit: GPREL22 against `.text'
> /home/dilfridge/glibc_build/libc.a(dl-support.o): in function `setup_vdso':
> /home/dilfridge/glibc/elf/setup-vdso.h:108:(.text+0xea2): relocation truncated to fit: GPREL22 against `.text'
> collect2: error: ld returned 1 exit status
> make[2]: *** [../Rules:290: /home/dilfridge/glibc_build/support/test-run-command] Error 1
> make[2]: *** Waiting for unfinished jobs....
> make[2]: Leaving directory '/home/dilfridge/glibc/support'
> make[1]: *** [Makefile:484: support/others] Error 2
> make[1]: Leaving directory '/home/dilfridge/glibc'
> make: *** [Makefile:9: all] Error 2
> 
> Turns out we have a fix for this in our Gentoo patchset since glibc-2.31, pasted below.
> 
> Since this fixes a clear build failure, is localized to sysdeps/unix/sysv/linux/ia64,
> and there are no positive test results without it anywhere, I'd like to pull it in for 2.38.
> 
> Any objections?
> 
> From ed428afb4c6353692fba6cedaa2f9db7bc9fb551 Mon Sep 17 00:00:00 2001
> From: Sergei Trofimovich <slyfox@gentoo.org>
> Date: Sat, 11 Jul 2020 20:06:51 +0300
> Subject: [PATCH 4/9] Fix miscompilation on ia64's gcc-10
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
> 
> Bug: https://bugs.gentoo.org/723268
> Signed-off-by: Andreas K. Hüttel <dilfridge@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 3e4d5da820..eb7681b704 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"				\


It has been proposed before [1] and it seems that it is not really the right
fix. I can't not reproduce it with the gcc built with build-many-glibc.py,
but I don't really expect it to that different from Gentoo.

I think it might be possible to code this in C and obtain its entry-point
directly instead of the ODP for the syscall redirection (I recall I did
something similar for ppc64).

[1] https://sourceware.org/pipermail/libc-alpha/2020-May/114493.html


More information about the Libc-alpha mailing list