/* M32R-specific support for 32-bit ELF.
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
- 2006, 2007, 2008 Free Software Foundation, Inc.
+ 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
/* Get the m32r ELF linker hash table from a link_info structure. */
-
#define m32r_elf_hash_table(p) \
- ((struct elf_m32r_link_hash_table *) ((p)->hash))
+ (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
+ == M32R_ELF_DATA ? ((struct elf_m32r_link_hash_table *) ((p)->hash)) : NULL)
/* Create an entry in an m32r ELF linker hash table. */
if (!_bfd_elf_link_hash_table_init (&ret->root, abfd,
m32r_elf_link_hash_newfunc,
- sizeof (struct elf_m32r_link_hash_entry)))
+ sizeof (struct elf_m32r_link_hash_entry),
+ M32R_ELF_DATA))
{
free (ret);
return NULL;
return FALSE;
htab = m32r_elf_hash_table (info);
+ if (htab == NULL)
+ return FALSE;
+
htab->sgot = bfd_get_section_by_name (dynobj, ".got");
htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
htab->srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
int ptralign = 2; /* 32bit */
htab = m32r_elf_hash_table (info);
+ if (htab == NULL)
+ return FALSE;
/* We need to create .plt, .rel[a].plt, .got, .got.plt, .dynbss, and
.rel[a].bss sections. */
same memory location for the variable. */
htab = m32r_elf_hash_table (info);
+ if (htab == NULL)
+ return FALSE;
+
s = htab->sdynbss;
BFD_ASSERT (s != NULL);
info = (struct bfd_link_info *) inf;
htab = m32r_elf_hash_table (info);
+ if (htab == NULL)
+ return FALSE;
eh = (struct elf_m32r_link_hash_entry *) h;
#endif
htab = m32r_elf_hash_table (info);
+ if (htab == NULL)
+ return FALSE;
+
dynobj = htab->root.dynobj;
BFD_ASSERT (dynobj != NULL);
Elf_Internal_Rela *rel, *relend;
/* Assume success. */
bfd_boolean ret = TRUE;
-
struct elf_m32r_link_hash_table *htab = m32r_elf_hash_table (info);
bfd *dynobj;
bfd_vma *local_got_offsets;
asection *sgot, *splt, *sreloc;
bfd_vma high_address = bfd_get_section_limit (input_bfd, input_section);
+ if (htab == NULL)
+ return FALSE;
+
dynobj = htab->root.dynobj;
local_got_offsets = elf_local_got_offsets (input_bfd);
}
if (sec != NULL && elf_discarded_section (sec))
- {
- /* For relocs against symbols from removed linkonce sections,
- or sections discarded by a linker script, we just want the
- section contents zeroed. Avoid any special processing. */
- _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
- rel->r_info = 0;
- rel->r_addend = 0;
- continue;
- }
+ RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+ rel, relend, howto, contents);
if (info->relocatable && !use_rel)
{
case R_M32R_HI16_ULO_RELA:
case R_M32R_LO16_RELA:
if (info->shared
- && r_symndx != 0
+ && r_symndx != STN_UNDEF
&& (input_section->flags & SEC_ALLOC) != 0
&& (( r_type != R_M32R_10_PCREL_RELA
&& r_type != R_M32R_18_PCREL_RELA
Elf_Internal_Sym *sym)
{
struct elf_m32r_link_hash_table *htab;
- bfd *dynobj;
bfd_byte *loc;
#ifdef DEBUG_PIC
#endif
htab = m32r_elf_hash_table (info);
- dynobj = htab->root.dynobj;
+ if (htab == NULL)
+ return FALSE;
if (h->plt.offset != (bfd_vma) -1)
{
#endif
htab = m32r_elf_hash_table (info);
+ if (htab == NULL)
+ return FALSE;
+
dynobj = htab->root.dynobj;
sgot = htab->sgotplt;
for (; dyncon < dynconend; dyncon++)
{
Elf_Internal_Dyn dyn;
- const char *name;
asection *s;
bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
break;
case DT_PLTGOT:
- name = ".got";
s = htab->sgot->output_section;
goto get_vma;
case DT_JMPREL:
- name = ".rela.plt";
s = htab->srelplt->output_section;
get_vma:
BFD_ASSERT (s != NULL);
const Elf_Internal_Rela *rel_end;
struct elf_m32r_link_hash_table *htab;
bfd *dynobj;
- bfd_vma *local_got_offsets;
- asection *sgot, *srelgot, *sreloc;
+ asection *sreloc;
if (info->relocatable)
return TRUE;
- sgot = srelgot = sreloc = NULL;
-
+ sreloc = NULL;
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
sym_hashes = elf_sym_hashes (abfd);
htab = m32r_elf_hash_table (info);
+ if (htab == NULL)
+ return FALSE;
+
dynobj = htab->root.dynobj;
- local_got_offsets = elf_local_got_offsets (abfd);
rel_end = relocs + sec->reloc_count;
for (rel = relocs; rel < rel_end; rel++)
{ NULL, 0, 0, 0, 0 }
};
-static bfd_boolean
-m32r_elf_fake_sections (bfd *abfd,
- Elf_Internal_Shdr *hdr ATTRIBUTE_UNUSED,
- asection *sec)
-{
- const char *name;
-
- name = bfd_get_section_name (abfd, sec);
-
- /* The generic elf_fake_sections will set up REL_HDR using the
- default kind of relocations. But, we may actually need both
- kinds of relocations, so we set up the second header here.
-
- This is not necessary for the O32 ABI since that only uses Elf32_Rel
- relocations (cf. System V ABI, MIPS RISC Processor Supplement,
- 3rd Edition, p. 4-17). It breaks the IRIX 5/6 32-bit ld, since one
- of the resulting empty .rela.<section> sections starts with
- sh_offset == object size, and ld doesn't allow that. While the check
- is arguably bogus for empty or SHT_NOBITS sections, it can easily be
- avoided by not emitting those useless sections in the first place. */
- if ((sec->flags & SEC_RELOC) != 0)
- {
- struct bfd_elf_section_data *esd;
- bfd_size_type amt = sizeof (Elf_Internal_Shdr);
-
- esd = elf_section_data (sec);
- BFD_ASSERT (esd->rel_hdr2 == NULL);
- esd->rel_hdr2 = bfd_zalloc (abfd, amt);
- if (!esd->rel_hdr2)
- return FALSE;
- _bfd_elf_init_reloc_shdr (abfd, esd->rel_hdr2, sec,
- !sec->use_rela_p);
- }
-
- return TRUE;
-}
-
static enum elf_reloc_type_class
m32r_elf_reloc_type_class (const Elf_Internal_Rela *rela)
{
}
\f
#define ELF_ARCH bfd_arch_m32r
+#define ELF_TARGET_ID M32R_ELF_DATA
#define ELF_MACHINE_CODE EM_M32R
#define ELF_MACHINE_ALT1 EM_CYGNUS_M32R
#define ELF_MAXPAGESIZE 0x1 /* Explicitly requested by Mitsubishi. */
#else
#define elf_backend_default_use_rela_p 1
#define elf_backend_may_use_rela_p 1
-#define elf_backend_fake_sections m32r_elf_fake_sections
#endif
#define elf_backend_object_p m32r_elf_object_p