This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

ld.so segfaults when built with GCC 4.8 on IA64


Hi all,

On IA64 and when GLIBC is built with GCC 4.8, ld.so segfaults very early
in elf_get_dynamic_info which is inlined from _dl_start. The problem is
that GCC does some optimizations, and instead of loading constants and
adding them to the _rtld_local address, it delegates that to the dynamic
linker using a relocation:

    a540:       19 c8 c0 12 c5 24       [MMB]       addl r25=156336,r1
    a546:       70 81 25 8a c9 03                   addl r23=156336,r1
    a54c:       e0 ff ff 49                   (p07) br.cond.spnt.few a520 <_dl_start+0x20>;;
...
    a630:       09 c8 00 32 18 10       [MMI]       ld8 r25=[r25]
    a636:       70 01 5c 30 20 00                   ld8 r23=[r23]
    a63c:       00 00 04 00                         nop.i 0x0;;
    a640:       09 00 00 00 01 00       [MMI]       nop.m 0x0
    a646:       90 01 67 0e 42 e0                   adds r25=992,r25
    a64c:       02 b8 dc 8c                         adds r23=-1152,r23;;

$ readelf -d ./elf/ld.so | grep PLTGOT
 0x0000000000000003 (PLTGOT)             0x29dd0

Considering that 0x29dd0 + 156336 = 0x50080, this corresponds to this
relocation:

000000050080  00000000006f R_IA64_REL64LSB                      3800501d0

Of course given it's too early in ld.so to do such relocations, the
wrong value is loaded, leading to a crash when accessing the address
later.

When doing the relocation "by hand" with GDB, everything works as
expected, at least for simple programs. Do you have an idea how to teach
GCC to not emit such a relocation? So far the only way I have found is
to compile rtld.c with "-O1 -fno-tree-copy-prop -fno-tree-dominator-opts
-fno-tree-ccp".

>From my point of view it seems that GCC 4.7 code is actually more
optimized, doing a relocation to avoid doing an (extended) constant load
and an addition seems to be a bad idea, especially given an addition is
still done later while it could have been folded into the relocation.

Thanks,
Aurelien

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]