[PATCH] Allow direct access relocations referencing a protected function symbol

Michael Matz matz@suse.de
Wed Jun 16 14:06:44 GMT 2021


Hello,

On Wed, 16 Jun 2021, Fangrui Song wrote:

> >I already told you exactly what was wrong with your patch in my first
> >email in this thread.  _bfd_elf_symbol_refs_local_p is a function used
> >by many ELF targets.  You cannot lightly make a change to this
> >function.  A change that even ignores comments in the function!  That
> >was your first mistake.
> 
> I think you mean
> 
> "What you are doing here will disable dynamic relocations on protected
> function symbols in shared libraries.  That will break function pointer
> comparison for architectures that implement non-pic executables, where a
> function that is undefined in the executable is given a fixed address in
> the executable, that of its plt call code."
> 
> [Some folks call this a "canonical PLT entry". I know it is not a widely used
> term.]
> 
> Both Michael and H.J. have replied. I think their replies match Cary's/my
> thought:

Sure, but I wasn't talking about the specific patch, only the overall 
effects it has on some targets (and what I think would or would not be 
desirable).

If you look again at the function you changed you will see that it already 
contains handling for protected symbols, basically the whole second half 
of that function deals with that.  And it does so based on command line 
and target settings; your change will effectively make the function ignore 
these settings, which cannot be simply done; certainly not without 
explicitely removing the then dead handling and adjusting all comments to 
those effects.  (But some targets will probably want to continue having 
their canonical plt-slot handling, so all that code really can't just be 
removed)


Ciao,
Michael.


More information about the Binutils mailing list