This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] VAX/BFD: Correct the clearing of GOT/PLT reservation
- From: "Maciej W. Rozycki" <macro at linux-mips dot org>
- To: binutils at sourceware dot org
- Cc: Matt Thomas <matt at netbsd dot org>, Jan-Benedict Glaw <jbglaw at lug-owl dot de>
- Date: Sun, 19 May 2013 23:01:23 +0100 (BST)
- Subject: [PATCH] VAX/BFD: Correct the clearing of GOT/PLT reservation
Hi,
In elf_vax_instantiate_got_entries we clear a GOT or PLT entry
reservation if we are creating a static object or a -Bsymbolic shared
object or the symbol has been forced local. At this point we're using the
refcount member of the relevant hash entry's got and plt members as we
haven't finished figuring out which symbols will need a GOT or PLT entry
yet and therefore have not started assigning offsets yet. These members
are of the gotplt_union type and just as the name suggests are unions.
Therefore there is no need to initialise both their refcount and offset
members as the fields overlap and are of the same size (bfd_signed_vma
type vs bfd_vma).
The change below removes redundant and somewhat confusing code while
preserving the current semantics of the function. It also adjusts the
comment to match the implementation (the mention of GOT/PLT reservation
removal for symbols that have been forced local is missing).
No regressions in vax-linux or vax-netbsdelf testing. OK to apply?
2013-05-19 Maciej W. Rozycki <macro@linux-mips.org>
* elf32-vax.c (elf_vax_instantiate_got_entries): Only set the
refcount member of the gotplt_union when resetting the reference
count. Adjust comment.
Maciej
binutils-2.23.1-vax-got-refcount.patch
Index: binutils-2.23.1/bfd/elf32-vax.c
===================================================================
--- binutils-2.23.1.orig/bfd/elf32-vax.c
+++ binutils-2.23.1/bfd/elf32-vax.c
@@ -1258,10 +1258,10 @@ elf_vax_discard_copies (struct elf_vax_l
/* This function is called via elf_link_hash_traverse. It looks for entries
that have GOT or PLT (.GOT) references. If creating a static object or a
- shared object with -Bsymbolic, it resets the reference count back to 0
- and sets the offset to -1 so normal PC32 relocation will be done. If
- creating a shared object or executable, space in the .got and .rela.got
- will be reserved for the symbol. */
+ shared object with -Bsymbolic, or the symbol has been forced local, then
+ it resets the reference count back to -1 so normal PC32 relocation will
+ be done. Otherwise space in the .got and .rela.got will be reserved for
+ the symbol. */
static bfd_boolean
elf_vax_instantiate_got_entries (struct elf_link_hash_entry *h, void * infoptr)
@@ -1286,10 +1286,8 @@ elf_vax_instantiate_got_entries (struct
|| (info->shared && info->symbolic)
|| h->forced_local)
{
- h->got.refcount = 0;
- h->got.offset = (bfd_vma) -1;
- h->plt.refcount = 0;
- h->plt.offset = (bfd_vma) -1;
+ h->got.refcount = -1;
+ h->plt.refcount = -1;
}
else if (h->got.refcount > 0)
{