This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Proposal for STT_GNU_IFUNC and R_*_IRELATIVE


Let me see if I understand the problem.

PIC non-jump uses (i.e. &func) generate a vanilla SHN_UNDEF symbol in the
GOT reloc.  Non-PIC non-jump uses resolve statically in the executable to
its own PLT slot.  Non-PLT refs resolve to the prevailing (first object's)
definition.  When the executable itself used a non-jump reference, it has a
st_value!=0 SHN_UNDEF symbol "func" pointing at its PLT slot, which will be
what all non-PLT lookups match first.  If there is no such symbol in the
executable, all the non-PLT PIC refs from DSOs will match the first real
(non-SHN_UNDEF) "func" symbol (in some DSO).

All of the above goes for STT_GNU_IFUNC too except for the last sentence.
All non-jump references resolved to an STT_GNU_IFUNC symbol need to yield
the address of a jump target that leads to executing at the actual PC that
an already-resolved PLT slot jumps to (not the STT_GNU_IFUNC st_value,
which is the PC of code to compute that PC).  

All non-jump PIC references have to be resolved at load time, when the GOT
non-PLT slots get filled in.  So this means that the dynamic linker calls
the st_value function to return the address for the GOT slot.

So, what's the problem?

If there is a non-PIC PLT slot (i.e. in the executable), then the &func GOT
slot will be that.  If not, then the &func GOT slot will be what the ifunc
st_value call returned.  This goes for the defining DSO as well as others.
Each call will return the same value, so all these GOT slots will match.
(Or else each object's PLT calls would jump to different places, so &func
not matching is no new problem.)

The linker must make sure that all references to "func" in the defining DSO
remain PIC-style even if it's STV_HIDDEN.


Thanks,
Roland


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]