xtensa: don't emit dynamic relocation for weak undefined symbol
authorMax Filippov <jcmvbkbc@gmail.com>
Mon, 2 Jul 2018 18:12:44 +0000 (11:12 -0700)
committerMax Filippov <jcmvbkbc@gmail.com>
Fri, 6 Jul 2018 23:05:49 +0000 (16:05 -0700)
commitc451bb34ae8bd2d0669bd563366883cfbcf0de9b
tree97de881e2081b7b1d734d18687b15dd27e26fa15
parentad1cc4e492e51ff334df81b5e8610f91b50e373a
xtensa: don't emit dynamic relocation for weak undefined symbol

Resolved reference to a weak undefined symbol in PIE must not have
a dynamic relative relocation against itself, otherwise the value of a
reference will be changed from 0 to the base of executable, breaking
code like the following:

  void weak_function (void);
  if (weak_function)
    weak_function ();

This fixes tests for PR ld/22269 and a number of PIE tests in xtensa gcc
testsuite.

bfd/
2018-07-06  Max Filippov  <jcmvbkbc@gmail.com>

* elf32-xtensa.c (elf_xtensa_allocate_dynrelocs): Don't allocate
space for dynamic relocation for undefined weak symbol.
(elf_xtensa_relocate_section): Don't emit R_XTENSA_RELATIVE
relocation for undefined weak symbols.
(shrink_dynamic_reloc_sections): Don't shrink dynamic relocation
section for relocations against undefined weak symbols.
bfd/ChangeLog
bfd/elf32-xtensa.c
This page took 0.025728 seconds and 4 git commands to generate.