[PATCH] configure: fix STT_GNU_IFUNC support detection with PIE toolchains [BZ #25506]

Aurelien Jarno aurelien@aurel32.net
Wed Feb 5 06:15:00 GMT 2020


On 2020-02-04 20:13, Fangrui Song wrote:
> On 2020-02-04, Aurelien Jarno wrote:
> > When GCC defaults to PIE, compiling the conftest.S that is used to
> > detect for assembler and linker STT_GNU_IFUNC support emits a
> > relocation. This causes a false positive in the detection.
> > 
> > Example on riscv64 with a toolchain defaulting to PIE:
> > 
> > | configure:4009: checking for assembler and linker STT_GNU_IFUNC support
> > |
> > | Relocation section '.rela.dyn'@offset 0x268 contains 1 entry:
> > |    Offset          Info           Type           Sym. Value    Sym. Name + Addend
> > | 000000002000  000000000003 R_RISCV_RELATIVE                     280
> > | configure:4040: result: yes
> 
> This patch is incorrect.
> 
>   .type foo,%gnu_indirect_function
>   foo:
>   .globl _start
>   _start:
>   .globl __start
>   __start:
>   .data
>   .quad foo
> 
> The conftest tests a non-GOT-non-PLT relocation referencing a non-preemptible symbol causes the creation of R_*_IRELATIVE.
> 
> A better test is to check R_*_IRELATIVE, instead of expecting "no relocations".

This is not something possible for two reasons:
- when building with PIE, the output is actually "no relocations".
- this test is not RISC-V specific

I realized in the meantime this bug is actually the reason why we have
been forcing -no-pie when building GNU libc on Debian MIPS. With -pie
the output is:

Relocation section '.rel.dyn' at offset 0x2fc contains 2 entries:
 Offset     Info    Type            Sym.Value  Sym. Name
 00000000  00000000 R_MIPS_NONE      
 00010310  00000003 R_MIPS_REL32  

Aurelien

-- 
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien@aurel32.net                 http://www.aurel32.net



More information about the Libc-alpha mailing list