This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: PATCH: Fix ia64 ld bootstrap test
On Thu, Dec 05, 2002 at 08:38:07AM +1030, Alan Modra wrote:
> On Wed, Dec 04, 2002 at 01:55:13PM -0800, H. J. Lu wrote:
> > I was wondering the same thing. Shouldn't
> >
> > len = sizeof (sec->id)*2 + 1 + sizeof (bfd_vma)*2 + 1;
> >
> > be enough for
> >
> > sprintf (addr_name, "%x:%lx",
>
> Yes, but since the sprintf is printing an unsigned long, I'd be
> inclined to use sizeof (unsigned long) * 2 rather than
That won't be right for ia64 cross linker hosted on x86.
> sizeof (bfd_vma)*2. Note spaces around multiply operator.
> OK with those changes.
>
Here is the new one.
H.J.
---
2002-12-04 H.J. Lu <hjl@gnu.org>
* elfxx-ia64.c (get_local_sym_hash): Use section ID instead of
BFD address when constructing local name.
--- bfd/elfxx-ia64.c.hash Wed Dec 4 09:44:58 2002
+++ bfd/elfxx-ia64.c Wed Dec 4 13:41:27 2002
@@ -1834,26 +1834,22 @@ get_local_sym_hash (ia64_info, abfd, rel
const Elf_Internal_Rela *rel;
bfd_boolean create;
{
- char *addr_name;
- size_t len;
struct elfNN_ia64_local_hash_entry *ret;
+ asection *sec = abfd->sections;
+ char addr_name [34];
+
+ BFD_ASSERT ((sizeof (sec->id)*2 + 1 + sizeof (bfd_vma)*2 + 1) <= 34);
+ BFD_ASSERT (sec);
/* Construct a string for use in the elfNN_ia64_local_hash_table.
name describes what was once anonymous memory. */
- len = sizeof (void*)*2 + 1 + sizeof (bfd_vma)*4 + 1 + 1;
- len += 10; /* %p slop */
-
- addr_name = bfd_malloc (len);
- if (addr_name == NULL)
- return 0;
- sprintf (addr_name, "%p:%lx",
- (void *) abfd, (unsigned long) ELFNN_R_SYM (rel->r_info));
+ sprintf (addr_name, "%x:%lx",
+ sec->id, (unsigned long) ELFNN_R_SYM (rel->r_info));
/* Collect the canonical entry data for this address. */
ret = elfNN_ia64_local_hash_lookup (&ia64_info->loc_hash_table,
addr_name, create, create);
- free (addr_name);
return ret;
}