Downgrade linker error on protected symbols in .dynbss to a warning

H.J. Lu hjl.tools@gmail.com
Fri Apr 10 10:49:00 GMT 2015


On Fri, Apr 10, 2015 at 2:45 AM, Alan Modra <amodra@gmail.com> wrote:
> PR18222 has convinced me I ought to downgrade the linker error for
> "copy reloc against protected <symbol> is invalid" to a warning.
>
> The thing is that the protected visibility variable in libunwind is in
> fact a constant.  libunwind doesn't change it from its initial value,
> nor do any of the testsuite testcases.  Neither is the variable's
> address taken.  So there isn't a real problem here in use of protected
> variables, just a potential problem.
>
> Since I'm downgrading the error to a warning I'm also going to revert
> HJ's patch on master that turned off the error completely for x86.
> Something like HJ's patch might be appropriate to turn off the warning
> if the linker can be taught how to detect "safe" copying of protected
> visibility variables into .dynbss.  Or better, edit code to PIC so no
> copying into .dynbss is needed.
>
> The following shows the changelog for the reversion + patch, then the
> patch as I assume no one is particularly interested in the details of
> a reversion.
>
> bfd/
>         Revert 2015-03-05  H.J. Lu  <hongjiu.lu@intel.com>
>         PR ld/pr15228
>         PR ld/pr17709
>         * elf-bfd.h (elf_backend_data): Delete extern_protected_data.
>         * elf32-i386.c (elf_backend_extern_protected_data): Delete.
>         * elf64-x86-64.c (elf_backend_extern_protected_data): Likewise.
>         * elflink.c (_bfd_elf_adjust_dynamic_copy): Remove
>         extern_protected_data test.
>         (_bfd_elf_symbol_refs_local_p): Likewise.
>         * elfxx-target.h (elf_backend_extern_protected_data): Delete.
>         (elfNN_bed): Delete elf_backend_extern_protected_data init.
> /ld/testsuite/
>         Revert 2015-03-05  H.J. Lu  <hongjiu.lu@intel.com>
>         PR ld/pr15228
>         PR ld/pr17709
>         * ld-i386/i386.exp (i386tests): Remove test for PR ld/17709.
>         * ld-i386/pr17709-nacl.rd: Delete.
>         * ld-i386/pr17709.rd: Likewise.
>         * ld-i386/pr17709a.s: Likewise.
>         * ld-i386/pr17709b.s: Likewise.
>         * ld-i386/protected3.d: Updated.
>         * ld-i386/protected3.s: Likewise.
>         * ld-x86-64/pr17709-nacl.rd: Delete.
>         * ld-x86-64/pr17709.rd: Likewise.
>         * ld-x86-64/pr17709a.s: Likewise.
>         * ld-x86-64/pr17709b.s: Likewise.
>         * ld-x86-64/protected3.d: Updated.
>         * ld-x86-64/protected3.s: Likewise.
>         * ld-x86-64/x86-64.exp (x86_64tests): Remove test for PR ld/17709.
>
> bfd/
>         PR ld/18222
>         * elflink.c (_bfd_elf_adjust_dynamic_copy): Don't report an error
>         on adding a protected visibility variable to .dynbss.

Adding a warning is wrong since it is OK to have copy relocation against
protected symbol.  It works with glibc 2.22.  Totally revert my patch is
also wrong as indicated by tests I added since protected symbols
should reference globally on targets with copy relocation. It will also fail
the new protected symbol tests in glibc.

-- 
H.J.



More information about the Binutils mailing list