[PATCH] ld/elf: Don't take IFUNC address in the shared object

H.J. Lu hjl.tools@gmail.com
Sat Jan 16 21:21:37 GMT 2021


On Sat, Jan 16, 2021 at 12:53 PM Fangrui Song <i@maskray.me> wrote:
>
> On 2021-01-16, H.J. Lu via Binutils wrote:
> >On x86, glibc 2.33 starts to issue a fatal error message when calling
> >IFUNC function defined in the unrelocated executable from a shared
> >library.
> >
> >1. Update x86 ELF linker to always convert IFUNC function defined in
> >position-dependent executable (PDE) to the normal function.  GOT in PDE
> >will be updated by R_*_IRELATIVE at run-time.
> >2. Update PR ld/23169 tests not to compare function address of external
> >IFUNC function in the shared object to avoid calling the IFUNC function
> >defined in the unrelocated executable.
>
> I think the description is less clear.
> If the declaration (defined as ifunc in another translation unit) is always
> referenced via GOT-generating or PLT-generating relocation types,
> there is no need converting it to STT_FUNC.
>
> I guess the original instructions in
> https://sourceware.org/bugzilla/show_bug.cgi?id=23169#c0 missed -fno-pic
> because many x86-64 Linux distributions default to -fpie now.
>
> -fpie uses R_X86_64_REX_GOTPCRELX to take a function pointer. It likely
> worked before PR23169.
> -fno-pic uses R_X86_64_32S which needed a fix in PR23169.
>
> It is unclear whether something regressed the PR23169 fix or the PR23169 fix was incomplete.

See:

https://sourceware.org/bugzilla/show_bug.cgi?id=20019

for details.

-- 
H.J.


More information about the Binutils mailing list