unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] ia64: fix dl-sysdep miscompilation on gcc-10
@ 2020-05-16 13:53 slyich--- via Libc-alpha
  2020-05-20 19:45 ` Adhemerval Zanella via Libc-alpha
  0 siblings, 1 reply; 6+ messages in thread
From: slyich--- via Libc-alpha @ 2020-05-16 13:53 UTC (permalink / raw)
  To: libc-alpha; +Cc: Sergei Trofimovich

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(-)

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"				\
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-06-05 21:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-16 13:53 [PATCH] ia64: fix dl-sysdep miscompilation on gcc-10 slyich--- via Libc-alpha
2020-05-20 19:45 ` Adhemerval Zanella via Libc-alpha
2020-05-31 19:34   ` Sergei Trofimovich via Libc-alpha
2020-05-31 21:40     ` Sergei Trofimovich via Libc-alpha
2020-06-05 18:44       ` Adhemerval Zanella via Libc-alpha
2020-06-05 21:31         ` Sergei Trofimovich via Libc-alpha

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).