[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/23169] IFUNC pointer should be allowed in executable
From: |
i at maskray dot me |
Subject: |
[Bug ld/23169] IFUNC pointer should be allowed in executable |
Date: |
Mon, 18 Jan 2021 19:44:23 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=23169
--- Comment #11 from Fangrui Song <i at maskray dot me> ---
(In reply to H.J. Lu from comment #9)
> (In reply to Fangrui Song from comment #8)
> > Can https://sourceware.org/glibc/wiki/GNU_IFUNC to updated to document what
> > is supported and what isn't supported?
> >
>
> IFUNC documentation needs improvements.
>
> >
> > Is the idea that
> > (1) the main executable is relocated the last.
> > (2) by making the main executable STT_GNU_IFUNC STT_FUNC, ifunc resolver
> > will not be called while the main executable is unresolved
>
> Correct.
>
> > (3) How does an ifunc resolver defined in another DSO work? Let the user
> > ensures DT_NEEDED BFS order or the ld.so itself does topological sorting?
>
> Current ld.so issues an error with a suggestion when it detects it.
I currently cannot find a straightforward rule to explain the GNU ld behavior
and what is supported in glibc.
cat > ./a.s <<eof
resolver:
ret
.globl ifunc, _start
.type ifunc, @gnu_indirect_function
.set ifunc, resolver
_start:
movq ifunc@GOTPCREL(%rip), %rax
call ifunc
eof
echo 'call ifunc' > ./b.s
gcc -shared -fpic b.s -o b.so
~/Dev/binutils-gdb/Debug/ld/ld-new is a top-of-tree ld.
% ~/Dev/binutils-gdb/Debug/ld/ld-new --export-dynamic a.o -o a && readelf -W -s
a | grep ifunc
7: 0000000000401008 0 IFUNC GLOBAL DEFAULT 3 ifunc
% ~/Dev/binutils-gdb/Debug/ld/ld-new --export-dynamic a.o ./b.so -o a &&
readelf -W -s a | grep ifunc
5: 0000000000401010 0 FUNC GLOBAL DEFAULT 7 ifunc
8: 0000000000401010 0 FUNC GLOBAL DEFAULT 7 ifunc
% ~/Dev/binutils-gdb/Debug/ld/ld-new --export-dynamic -pie a.o -o a && readelf
-W --dyn-syms a | grep ifunc
5: 0000000000001020 0 IFUNC GLOBAL DEFAULT 8 ifunc
% ~/Dev/binutils-gdb/Debug/ld/ld-new --export-dynamic -pie a.o ./b.so -o a &&
readelf -W --dyn-syms a | grep ifunc
5: 0000000000001020 0 IFUNC GLOBAL DEFAULT 8 ifunc
Is this a -no-pie only behavior?
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug ld/23169] IFUNC pointer should be allowed in executable, cvs-commit at gcc dot gnu.org, 2021/01/16
- [Bug ld/23169] IFUNC pointer should be allowed in executable, i at maskray dot me, 2021/01/16
- [Bug ld/23169] IFUNC pointer should be allowed in executable, hjl.tools at gmail dot com, 2021/01/17
- [Bug ld/23169] IFUNC pointer should be allowed in executable, cvs-commit at gcc dot gnu.org, 2021/01/18
- [Bug ld/23169] IFUNC pointer should be allowed in executable,
i at maskray dot me <=
- [Bug ld/23169] IFUNC pointer should be allowed in executable, hjl.tools at gmail dot com, 2021/01/18
- [Bug ld/23169] IFUNC pointer should be allowed in executable, hjl.tools at gmail dot com, 2021/01/18