This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [RFA:] Fix ld/13990, ARM BFD_ASSERT with --shared and --gc-sections
- From: Hans-Peter Nilsson <hans-peter dot nilsson at axis dot com>
- To: binutils at sourceware dot org
- Date: Tue, 24 Apr 2012 03:07:58 +0200
- Subject: Re: [RFA:] Fix ld/13990, ARM BFD_ASSERT with --shared and --gc-sections
> From: Richard Sandiford <rdsandiford@googlemail.com>
> CC: "binutils@sourceware.org" <binutils@sourceware.org>
> Date: Thu, 19 Apr 2012 22:38:17 +0200
> Information for removed relocs shouldn't be left lying
> around to trip up later code. Your refcount fix sticks to that
> principle because for refcount < 0 the precise count has already,
> deliberately, been dropped. The other counts are still meaningful
> though, whether or not they are used for refcount < 0 at present.
Yah... I'll call that a thinko; their *update* increments are
independent even though their current meaning is tied to the
existence of a non-IPLT PLT.
Here's an update, instead of a ping, tested arm-eabi and
arm-linux-gnueabi. ld/testsuite as in previous message.
Ok to commit?
bfd:
PR ld/13990
* elf32-arm.c (elf32_arm_gc_sweep_hook): Handle a forced-local
symbol, where PLT refcount is set to -1.
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index f5b5c4d..e2fb62d 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -12256,8 +12256,19 @@ elf32_arm_gc_sweep_hook (bfd * abfd,
if (may_need_local_target_p
&& elf32_arm_get_plt_info (abfd, eh, r_symndx, &root_plt, &arm_plt))
{
- BFD_ASSERT (root_plt->refcount > 0);
- root_plt->refcount -= 1;
+ /* If PLT refcount book-keeping is wrong and too low, we'll
+ see a zero value (going to -1) for the root PLT reference
+ count. */
+ if (root_plt->refcount >= 0)
+ {
+ BFD_ASSERT (root_plt->refcount != 0);
+ root_plt->refcount -= 1;
+ }
+ else
+ /* A value of -1 means the symbol has become local, forced
+ or seeing a hidden definition. Any other negative value
+ is an error. */
+ BFD_ASSERT (root_plt->refcount == -1);
if (!call_reloc_p)
arm_plt->noncall_refcount--;
brgds, H-P