Bug 25506 - configure: broken detection of STT_GNU_IFUNC when GCC defaults to PIE
Summary: configure: broken detection of STT_GNU_IFUNC when GCC defaults to PIE
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: build (show other bugs)
Version: 2.31
: P2 normal
Target Milestone: 2.32
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 22634 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-02-04 21:58 UTC by Aurelien Jarno
Modified: 2024-01-08 20:36 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
Project(s) to access:
ssh public key:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aurelien Jarno 2020-02-04 21:58:47 UTC
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' at offset 0x268 contains 1 entry:
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
000000002000  000000000003 R_RISCV_RELATIVE                     280
configure:4040: result: yes

And with a toolchain not default to PIE:

configure:4009: checking for assembler and linker STT_GNU_IFUNC support

There are no relocations in this file.
configure:4040: result: no


The same is reproducible on MIPS.
Comment 1 Fangrui Song 2020-02-05 06:16:14 UTC
R_MIPS_IRELATIVE is not defined (no non-preemptible IFUNC support)
and
no libc supports preemptible IFUNC...

RISC-V is in the same boat..
Comment 2 Sourceware Commits 2020-03-05 20:06:37 UTC
The master branch has been updated by Adhemerval Zanella <azanella@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=87a698a21646b7ee620923ef5ffa9735471a8ddd

commit 87a698a21646b7ee620923ef5ffa9735471a8ddd
Author: Fangrui Song <maskray@google.com>
Date:   Tue Feb 4 21:55:44 2020 -0800

    Improve IFUNC check [BZ #25506]
    
    GNU ld's RISCV port does not support IFUNC. ld -no-pie produces no
    relocation and the test passed incorrectly. Be more rigid by testing
    IRELATIVE explicitly.
    
    Tested-by: Aurelien Jarno <aurelien@aurel32.net>
    Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Comment 3 Adhemerval Zanella 2020-03-05 20:07:07 UTC
Fixed on 2.32.
Comment 4 Sergei Trofimovich 2024-01-08 20:36:04 UTC
*** Bug 22634 has been marked as a duplicate of this bug. ***