1 diff --git a/bfd/ChangeLog b/bfd/ChangeLog
2 index 1f6c1a0..0c81318 100644
6 +2012-06-29 Nick Clifton <nickc@redhat.com>
9 + * elf32-arm.c (elf32_arm_check_relocs): Do not increment refcount
10 + for locally bound symbols.
12 +2012-04-24 Hans-Peter Nilsson <hp@axis.com>
15 + * elf32-arm.c (elf32_arm_gc_sweep_hook): Handle a forced-local
16 + symbol, where PLT refcount is set to -1.
18 2011-12-10 David Daney <david.daney@cavium.com>
20 Backport from mainline:
21 diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
22 index 1f6c1a0..8daebe5 100644
25 @@ -12046,9 +12046,19 @@ elf32_arm_gc_sweep_hook (bfd * abfd,
26 if (may_need_local_target_p
27 && elf32_arm_get_plt_info (abfd, eh, r_symndx, &root_plt, &arm_plt))
29 - BFD_ASSERT (root_plt->refcount > 0);
30 - root_plt->refcount -= 1;
32 + /* If PLT refcount book-keeping is wrong and too low, we'll
33 + see a zero value (going to -1) for the root PLT reference
35 + if (root_plt->refcount >= 0)
37 + BFD_ASSERT (root_plt->refcount != 0);
38 + root_plt->refcount -= 1;
41 + /* A value of -1 means the symbol has become local, forced
42 + or seeing a hidden definition. Any other negative value
44 + BFD_ASSERT (root_plt->refcount == -1);
46 arm_plt->noncall_refcount--;
48 @@ -12408,7 +12418,8 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info,
50 /* If the symbol is a function that doesn't bind locally,
51 this relocation will need a PLT entry. */
52 - root_plt->refcount += 1;
53 + if (root_plt->refcount != -1)
54 + root_plt->refcount += 1;
57 arm_plt->noncall_refcount++;
58 diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp
59 index c7a0b2c..8631466 100644
60 --- a/ld/testsuite/ld-arm/arm-elf.exp
61 +++ b/ld/testsuite/ld-arm/arm-elf.exp
62 @@ -733,3 +733,4 @@ run_dump_test "attr-merge-vfp-6r"
63 run_dump_test "attr-merge-incompatible"
64 run_dump_test "unresolved-1"
65 run_dump_test "unresolved-1-dyn"
66 +run_dump_test "gc-hidden-1"
67 diff --git a/ld/testsuite/ld-arm/gc-hidden-1.d b/ld/testsuite/ld-arm/gc-hidden-1.d
69 index 0000000..80c7e9e
71 +++ b/ld/testsuite/ld-arm/gc-hidden-1.d
73 +#target: arm*-*-*eabi
77 +#ld: --gc-sections --shared --version-script hideall.ld
80 +# See PR ld/13990: a forced-local PLT reference to a
81 +# forced-local symbol is GC'ed, trigging a BFD_ASSERT.
83 +.*: file format elf32-.*
85 +DYNAMIC SYMBOL TABLE:
86 +0+124 l d .text 0+ .text
87 +0+ g DO \*ABS\* 0+ NS NS
89 +Disassembly of section .text:
92 + 124: e52de004 push {lr} ; \(str lr, \[sp, #-4\]!\)
93 + 128: eb000000 bl 130 <hidfn>
94 + 12c: e8bd8000 pop {pc}
97 + 130: e8bd8000 pop {pc}
98 diff --git a/ld/testsuite/ld-arm/gcdfn.s b/ld/testsuite/ld-arm/gcdfn.s
100 index 0000000..f2afae7
102 +++ b/ld/testsuite/ld-arm/gcdfn.s
106 + .type gcdfn, %function
111 + .size gcdfn, . - gcdfn
112 diff --git a/ld/testsuite/ld-arm/hideall.ld b/ld/testsuite/ld-arm/hideall.ld
114 index 0000000..077d6b5
116 +++ b/ld/testsuite/ld-arm/hideall.ld
119 diff --git a/ld/testsuite/ld-arm/hidfn.s b/ld/testsuite/ld-arm/hidfn.s
121 index 0000000..a66b558
123 +++ b/ld/testsuite/ld-arm/hidfn.s
128 + .type hidfn, %function
131 + .size hidfn, . - hidfn
132 diff --git a/ld/testsuite/ld-arm/main.s b/ld/testsuite/ld-arm/main.s
134 index 0000000..046d19d
136 +++ b/ld/testsuite/ld-arm/main.s
140 + .type _start, %function
145 + .size _start, . - _start