Questions about elf/tst-prelink-cmp

Matheus Castanho msc@linux.ibm.com
Tue Nov 24 15:03:58 GMT 2020


Hi,

I noticed elf/tst-prelink-cmp is failing when glibc is compiled with -mcpu=power10, but I'm
not sure if the failure indicates something is wrong or if the test should not be run for powerpc.

The test is conditionally enabled by the configure script if a GLOB_DAT relocation is used for a
global variable in the test prog. Before POWER10, R_PPC64_ADDR64 was the relocation used in
these situations, while in P10 R_PPC64_GLOB_DAT started to be generated instead (CC Alan as
he may have more info about that). Note these two relocs are handled the same way by the dl
(sysdeps/powerpc/powerpc64/dl-machine.h).

The test expects a conflict on the symbol 'stdout' when running elf/tst-prelink with
LD_TRACE_PRELINKING=1, which does not happen on powerpc, so the test fails. Still, it does
not look like an issue with generated code, as the program is able to access the global var
correctly. 

If I run elf/tst-prelink with LD_TRACE_PRELINKING=1 and LD_DEBUG=all I see that on
powerpc the dl is able to resolve to the symbol provided by libc.so, while on x86-64 it resolves
to the symbol in elf/tst-prelink and later the extra lookup done by _dl_debug_bindings resolves to
the one in libc.so, causing the conflict.

On x86-64:
   15536:     symbol=stdout;  lookup in file=elf/tst-prelink [0]
   15536:     binding file ./libc.so.6 [0] to elf/tst-prelink [0]: normal symbol `stdout' [GLIBC_2.2.5]
   15536:     symbol=stdout;  lookup in file=./libc.so.6 [0]
   conflict 0x00007f0a1b793000 0x000000000000dfd0 -> 0x0000000000400000 0x0000000000407180 x 0x00007f0a1b793000 0x00000000001b97c8 /0 stdout

On ppc64le:
   3568038:     symbol=stdout;  lookup in file=elf/tst-prelink [0]
   3568038:     symbol=stdout;  lookup in file=./libc.so.6 [0]
   3568038:     binding file ./libc.so.6 [0] to ./libc.so.6 [0]: normal symbol `stdout' [GLIBC_2.17]
   3568038:     symbol=stdout;  lookup in file=./libc.so.6 [0]
   lookup 0x00007fffa5fa0000 0x000000000000eb60 -> 0x00007fffa5fa0000 0x00000000001f1830 /0 stdout

The original commit adding this test applied it only to x86-64 and i386:

commit fe534fe8980fa214c410e3661a4216e781073353
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Nov 10 12:27:24 2015 -0800

    Add a test for prelink output
        This test applies to i386 and x86_64 which set R_386_GLOB_DAT and
    R_X86_64_GLOB_DAT to ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA.

It later was applied to all archs with GLOB_DAT relocations (commit 89569c8bb6). 

powerpc does not treat R_PPC64_GLOB_DAT as ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA
(see elf_machine_type_class in sysdeps/powerpc/powerpc64/dl-machine.h), and that
relocation type class is set to 0 as DL_EXTERN_PROTECTED_DATA is not set for powerpc.

So I have a few questions:
1) What exactly is this test checking?
2) In what situations should the conflict be expected?
3) Should elf/tst-prelink-cmp only be enabled for archs that set DL_EXTERN_PROTECTED_DATA?
4) Is there something wrong with the way R_PPC64_GLOB_DATA is being handled on powerpc?

Thanks,
Matheus Castanho


More information about the Libc-alpha mailing list