binutils: fix xtensa ld bug triggered by --gc-sections
authorMax Filippov <jcmvbkbc@gmail.com>
Thu, 14 May 2015 04:38:59 +0000 (07:38 +0300)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Sat, 16 May 2015 16:28:06 +0000 (18:28 +0200)
commit384c919321a53bdb74539cd1c8e0f098e49e8f8e
tree3774ebd6fccf1144da333da95e1bc3e600869368
parentb9f709e4200c8e2e1c2d34a010897601f7e5c808
binutils: fix xtensa ld bug triggered by --gc-sections

elf_xtensa_gc_sweep_hook doesn't correctly unreference symbols that were
made local, that results in link failure with the following message:

  BFD (GNU Binutils) 2.24 internal error, aborting at elf32-xtensa.c line
  3372 in elf_xtensa_finish_dynamic_sections

elf_xtensa_gc_sweep_hook determines symbol reference type (PLT or GOT) by
relocation type. Relocation types are not changed when symbol becomes
local, but its PLT references are added to GOT references and
plt.refcount is set to 0. Such symbol cannot be unreferences in the
elf_xtensa_gc_sweep_hook and its extra references make calculated GOT
relocations section size not match number of GOT relocations.

Fix it by treating PLT reference as GOT reference when plt.refcount is
not positive.

Fixes:
  http://autobuild.buildroot.net/results/3e2e24f697e26c93d4d95782b1cb7799fa620a7a/
  http://autobuild.buildroot.org/results/97d4c96d6f6cdc1ed4007456f4ab70be9dfa41b5/

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
package/binutils/2.22/911-xtensa-fix-localized-symbol-refcounting-with-gc-sect.patch [new file with mode: 0644]
package/binutils/2.23.2/911-xtensa-fix-localized-symbol-refcounting-with-gc-sect.patch [new file with mode: 0644]
package/binutils/2.24/911-xtensa-fix-localized-symbol-refcounting-with-gc-sect.patch [new file with mode: 0644]
package/binutils/2.25/911-xtensa-fix-localized-symbol-refcounting-with-gc-sect.patch [new file with mode: 0644]