lld status with powerpc64

Fangrui Song maskray@google.com
Fri Nov 5 07:45:18 GMT 2021


On 2021-11-05, Fangrui Song wrote:
>
>On 2021-10-27, Tulio Magno Quites Machado Filho wrote:
>>Tulio Magno Quites Machado Filho via Libc-alpha <libc-alpha@sourceware.org> writes:
>>
>>>Fangrui Song via Libc-alpha <libc-alpha@sourceware.org> writes:
>>>
>>>>On 2021-10-26, Adhemerval Zanella wrote:
>>>>> #2  0x00007ffff7d7ae90 in __libc_start_main_impl ()
>>>>>    from
>>>>> /home/azanella/glibc/build/powerpc64le-linux-gnu-power9-lld/libc.so.6
>>>>> #3  0x0000000000000000 in ?? ()
>>>>> (gdb) disas
>>>>> Dump of assembler code for function __gep_setup___vmx__sigjmp_save:
>>>>> => 0x00007ffff7f2a980 <+0>:     .long 0x613ffe6
>>>>>    0x00007ffff7f2a984 <+4>:     li      r12,-1280
>>>
>>>This is a pla, but this GDB isn't able to disassemble it.  This instruction
>>>shouldn't be used unless when configuring glibc using --with-cpu=power10.
>>
>>I can reproduce this issue even when configuring glibc with
>>--with-cpu=power9 --disable-multi-arch, which means the build should not have
>>any Power10 instructions.
>>
>>-- 
>>Tulio Magno
>
>__gep_setup___vmx__sigjmp_save means a r12 setup stub in ld.lld and is
>used with R_PPC64_REL24_NOTOC for a non-PLT branch.
>
>Clang only emits `bl foo@notoc` with -mcpu=power10.
>However, sysdeps/powerpc/powerpc64/configure.ac enables USE_PPC64_NOTOC
>when the assembler (gas) supports it.
>
>
>Adhemerval noticed that ld.lld has a behavior difference from GNU ld:
>ld.lld defaults to PC-relative paddi stub while GNU ld doesn't (like
>--power10-stubs=no).
>Is USE_PPC64_NOTOC supposed to be used when targeting POWER9 and below?
>If yes, the ld.lld default should be fixed.
>
>
>In my testing environment (POWER9), ld.bfd doesn't support @notoc, so
>USE_PPC64_NOTOC is undefined.
>
>% gcc --version
>gcc (Debian 8.3.0-6) 8.3.0
>...
>% ld.bfd --version
>GNU ld (GNU Binutils for Debian) 2.31.1
>...
>
>I only see 8 more FAILs with ld.lld than ld.bfd
>
>
>% diff -u 0 1
>--- 0   2021-11-05 00:11:43.218731302 -0700
>+++ 1   2021-11-05 00:11:37.659286448 -0700
>@@ -9,6 +9,14 @@
> FAIL: debug/tst-lfschk6
> FAIL: dlfcn/bug-atexit3
> FAIL: elf/check-abi-libc
>+FAIL: elf/ifuncmain1pic
>+FAIL: elf/ifuncmain1pie
>+FAIL: elf/ifuncmain1vis
>+FAIL: elf/ifuncmain1vispic
>+FAIL: elf/ifuncmain1vispie
>+FAIL: elf/ifuncmain3
>+FAIL: elf/ifuncmain6pie
>+FAIL: elf/tst-tlsopt-powerpc
> FAIL: nptl/tst-cancel24
> FAIL: nptl/tst-minstack-throw
> FAIL: nptl/tst-once5
>
>
>I suspect ifuncmain1* is again related to the order of R_*_IRELATIVE with
>regard to R_*_JUMP_SLOT referencing a STT_GNU_IFUNC symbol.
>(something like https://maskray.me/blog/2021-01-18-gnu-indirect-function#relocation-resolving-order)
>But perhaps Adhemerval can look a look at it.
>
>
>For elf/tst-tlsopt-powerpc, it is simply because ld.lld doesn't implement the GNU ld powerpc64's
>__tls_get_addr_opt (pseudo-TLSDESC): https://maskray.me/blog/2021-02-14-all-about-thread-local-storage#powerpc-__tls_get_addr_opt
>Let me send a configure patch to disable it...

Actually I do not know how to disable tst-tlsopt-powerpc properly.

Perhaps add sysdeps/powerpc/configure.ac and move the
sysdeps/unix/sysv/linux/powerpc/configure.ac --no-tls-get-addr-optimize
to sysdeps/powerpc/configure.ac?
sysdeps/powerpc/preconfigure.ac exists (I don't know how it is used).

The patch requires some non-trivial configure.ac change, so I'd hope
that an expert can do it :)

>
>
>Hey, so lld linked glibc powerpc64 is in a pretty good status!


More information about the Libc-alpha mailing list