mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-20 09:58:19 +08:00
bfd/
* elfxx-mips.c (mips_elf_create_local_got_entry): Tidy. Avoid aliasing violation. Check for htab allocation failures.
This commit is contained in:
@ -1,3 +1,8 @@
|
|||||||
|
2013-02-11 Richard Sandiford <rdsandiford@googlemail.com>
|
||||||
|
|
||||||
|
* elfxx-mips.c (mips_elf_create_local_got_entry): Tidy. Avoid
|
||||||
|
aliasing violation. Check for htab allocation failures.
|
||||||
|
|
||||||
2013-02-11 Richard Sandiford <rdsandiford@googlemail.com>
|
2013-02-11 Richard Sandiford <rdsandiford@googlemail.com>
|
||||||
|
|
||||||
* elfxx-mips.c (mips_elf_primary_global_got_index): New function,
|
* elfxx-mips.c (mips_elf_primary_global_got_index): New function,
|
||||||
|
@ -3521,18 +3521,14 @@ mips_elf_create_local_got_entry (bfd *abfd, struct bfd_link_info *info,
|
|||||||
struct mips_elf_link_hash_entry *h,
|
struct mips_elf_link_hash_entry *h,
|
||||||
int r_type)
|
int r_type)
|
||||||
{
|
{
|
||||||
struct mips_got_entry entry, **loc;
|
struct mips_got_entry lookup, *entry;
|
||||||
|
void **loc;
|
||||||
struct mips_got_info *g;
|
struct mips_got_info *g;
|
||||||
struct mips_elf_link_hash_table *htab;
|
struct mips_elf_link_hash_table *htab;
|
||||||
|
|
||||||
htab = mips_elf_hash_table (info);
|
htab = mips_elf_hash_table (info);
|
||||||
BFD_ASSERT (htab != NULL);
|
BFD_ASSERT (htab != NULL);
|
||||||
|
|
||||||
entry.abfd = NULL;
|
|
||||||
entry.symndx = -1;
|
|
||||||
entry.d.address = value;
|
|
||||||
entry.tls_type = mips_elf_reloc_tls_type (r_type);
|
|
||||||
|
|
||||||
g = mips_elf_bfd_got (ibfd, FALSE);
|
g = mips_elf_bfd_got (ibfd, FALSE);
|
||||||
if (g == NULL)
|
if (g == NULL)
|
||||||
{
|
{
|
||||||
@ -3543,48 +3539,46 @@ mips_elf_create_local_got_entry (bfd *abfd, struct bfd_link_info *info,
|
|||||||
/* This function shouldn't be called for symbols that live in the global
|
/* This function shouldn't be called for symbols that live in the global
|
||||||
area of the GOT. */
|
area of the GOT. */
|
||||||
BFD_ASSERT (h == NULL || h->global_got_area == GGA_NONE);
|
BFD_ASSERT (h == NULL || h->global_got_area == GGA_NONE);
|
||||||
if (entry.tls_type)
|
|
||||||
{
|
|
||||||
struct mips_got_entry *p;
|
|
||||||
|
|
||||||
entry.abfd = ibfd;
|
lookup.tls_type = mips_elf_reloc_tls_type (r_type);
|
||||||
|
if (lookup.tls_type)
|
||||||
|
{
|
||||||
|
lookup.abfd = ibfd;
|
||||||
if (tls_ldm_reloc_p (r_type))
|
if (tls_ldm_reloc_p (r_type))
|
||||||
{
|
{
|
||||||
entry.symndx = 0;
|
lookup.symndx = 0;
|
||||||
entry.d.addend = 0;
|
lookup.d.addend = 0;
|
||||||
}
|
}
|
||||||
else if (h == NULL)
|
else if (h == NULL)
|
||||||
{
|
{
|
||||||
entry.symndx = r_symndx;
|
lookup.symndx = r_symndx;
|
||||||
entry.d.addend = 0;
|
lookup.d.addend = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
entry.d.h = h;
|
{
|
||||||
|
lookup.symndx = -1;
|
||||||
|
lookup.d.h = h;
|
||||||
|
}
|
||||||
|
|
||||||
p = (struct mips_got_entry *)
|
entry = (struct mips_got_entry *) htab_find (g->got_entries, &lookup);
|
||||||
htab_find (g->got_entries, &entry);
|
BFD_ASSERT (entry);
|
||||||
|
|
||||||
BFD_ASSERT (p);
|
return entry;
|
||||||
return p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loc = (struct mips_got_entry **) htab_find_slot (g->got_entries, &entry,
|
lookup.abfd = NULL;
|
||||||
INSERT);
|
lookup.symndx = -1;
|
||||||
if (*loc)
|
lookup.d.address = value;
|
||||||
return *loc;
|
loc = htab_find_slot (g->got_entries, &lookup, INSERT);
|
||||||
|
if (!loc)
|
||||||
entry.gotidx = MIPS_ELF_GOT_SIZE (abfd) * g->assigned_gotno++;
|
|
||||||
|
|
||||||
*loc = (struct mips_got_entry *)bfd_alloc (abfd, sizeof entry);
|
|
||||||
|
|
||||||
if (! *loc)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
memcpy (*loc, &entry, sizeof entry);
|
entry = (struct mips_got_entry *) *loc;
|
||||||
|
if (entry)
|
||||||
|
return entry;
|
||||||
|
|
||||||
if (g->assigned_gotno > g->local_gotno)
|
if (g->assigned_gotno >= g->local_gotno)
|
||||||
{
|
{
|
||||||
(*loc)->gotidx = -1;
|
|
||||||
/* We didn't allocate enough space in the GOT. */
|
/* We didn't allocate enough space in the GOT. */
|
||||||
(*_bfd_error_handler)
|
(*_bfd_error_handler)
|
||||||
(_("not enough GOT space for local GOT entries"));
|
(_("not enough GOT space for local GOT entries"));
|
||||||
@ -3592,8 +3586,15 @@ mips_elf_create_local_got_entry (bfd *abfd, struct bfd_link_info *info,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
MIPS_ELF_PUT_WORD (abfd, value,
|
entry = (struct mips_got_entry *) bfd_alloc (abfd, sizeof (*entry));
|
||||||
(htab->sgot->contents + entry.gotidx));
|
if (!entry)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
lookup.gotidx = MIPS_ELF_GOT_SIZE (abfd) * g->assigned_gotno++;
|
||||||
|
*entry = lookup;
|
||||||
|
*loc = entry;
|
||||||
|
|
||||||
|
MIPS_ELF_PUT_WORD (abfd, value, htab->sgot->contents + entry->gotidx);
|
||||||
|
|
||||||
/* These GOT entries need a dynamic relocation on VxWorks. */
|
/* These GOT entries need a dynamic relocation on VxWorks. */
|
||||||
if (htab->is_vxworks)
|
if (htab->is_vxworks)
|
||||||
@ -3606,7 +3607,7 @@ mips_elf_create_local_got_entry (bfd *abfd, struct bfd_link_info *info,
|
|||||||
s = mips_elf_rel_dyn_section (info, FALSE);
|
s = mips_elf_rel_dyn_section (info, FALSE);
|
||||||
got_address = (htab->sgot->output_section->vma
|
got_address = (htab->sgot->output_section->vma
|
||||||
+ htab->sgot->output_offset
|
+ htab->sgot->output_offset
|
||||||
+ entry.gotidx);
|
+ entry->gotidx);
|
||||||
|
|
||||||
rloc = s->contents + (s->reloc_count++ * sizeof (Elf32_External_Rela));
|
rloc = s->contents + (s->reloc_count++ * sizeof (Elf32_External_Rela));
|
||||||
outrel.r_offset = got_address;
|
outrel.r_offset = got_address;
|
||||||
@ -3615,7 +3616,7 @@ mips_elf_create_local_got_entry (bfd *abfd, struct bfd_link_info *info,
|
|||||||
bfd_elf32_swap_reloca_out (abfd, &outrel, rloc);
|
bfd_elf32_swap_reloca_out (abfd, &outrel, rloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
return *loc;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the number of dynamic section symbols required by OUTPUT_BFD.
|
/* Return the number of dynamic section symbols required by OUTPUT_BFD.
|
||||||
|
Reference in New Issue
Block a user