#include "bfd.h"
#include "sysdep.h"
#include "libbfd.h"
#include "elf-bfd.h"
#include "elf/m32r.h"
static bfd_reloc_status_type m32r_elf_10_pcrel_reloc
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
static bfd_reloc_status_type m32r_elf_do_10_pcrel_reloc
PARAMS ((bfd *, reloc_howto_type *, asection *,
bfd_byte *, bfd_vma, asection *, bfd_vma, bfd_vma));
static bfd_reloc_status_type m32r_elf_hi16_reloc
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
static void m32r_elf_relocate_hi16
PARAMS ((bfd *, int, Elf_Internal_Rela *, Elf_Internal_Rela *,
bfd_byte *, bfd_vma));
bfd_reloc_status_type m32r_elf_lo16_reloc
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
bfd_reloc_status_type m32r_elf_generic_reloc
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
static bfd_reloc_status_type m32r_elf_sda16_reloc
PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
static void m32r_info_to_howto_rel
PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
boolean _bfd_m32r_elf_section_from_bfd_section
PARAMS ((bfd *, asection *, int *));
void _bfd_m32r_elf_symbol_processing
PARAMS ((bfd *, asymbol *));
static boolean m32r_elf_add_symbol_hook
PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
const char **, flagword *, asection **, bfd_vma *));
static boolean m32r_elf_relocate_section
PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
#if 0
static boolean m32r_elf_relax_delete_bytes
PARAMS ((bfd *, asection *, bfd_vma, int));
#endif
static bfd_reloc_status_type m32r_elf_final_sda_base
PARAMS ((bfd *, struct bfd_link_info *, const char **, bfd_vma *));
static boolean m32r_elf_object_p
PARAMS ((bfd *));
static void m32r_elf_final_write_processing
PARAMS ((bfd *, boolean));
static boolean m32r_elf_set_private_flags
PARAMS ((bfd *, flagword));
static boolean m32r_elf_merge_private_bfd_data
PARAMS ((bfd *, bfd *));
static boolean m32r_elf_print_private_bfd_data
PARAMS ((bfd *, PTR));
static boolean m32r_elf_gc_sweep_hook
PARAMS ((bfd *, struct bfd_link_info *, asection *,
const Elf_Internal_Rela *));
static boolean m32r_elf_check_relocs
PARAMS ((bfd *, struct bfd_link_info *, asection *,
const Elf_Internal_Rela *));
asection * m32r_elf_gc_mark_hook
PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *,
struct elf_link_hash_entry *, Elf_Internal_Sym *));
#define NOP_INSN 0x7000
#define MAKE_PARALLEL(insn) ((insn) | 0x8000)
#define USE_REL
static reloc_howto_type m32r_elf_howto_table[] =
{
HOWTO (R_M32R_NONE,
0,
2,
32,
false,
0,
complain_overflow_bitfield,
bfd_elf_generic_reloc,
"R_M32R_NONE",
false,
0,
0,
false),
HOWTO (R_M32R_16,
0,
1,
16,
false,
0,
complain_overflow_bitfield,
m32r_elf_generic_reloc,
"R_M32R_16",
true,
0xffff,
0xffff,
false),
HOWTO (R_M32R_32,
0,
2,
32,
false,
0,
complain_overflow_bitfield,
m32r_elf_generic_reloc,
"R_M32R_32",
true,
0xffffffff,
0xffffffff,
false),
HOWTO (R_M32R_24,
0,
2,
24,
false,
0,
complain_overflow_unsigned,
m32r_elf_generic_reloc,
"R_M32R_24",
true,
0xffffff,
0xffffff,
false),
HOWTO (R_M32R_10_PCREL,
2,
1,
10,
true,
0,
complain_overflow_signed,
m32r_elf_10_pcrel_reloc,
"R_M32R_10_PCREL",
false,
0xff,
0xff,
true),
HOWTO (R_M32R_18_PCREL,
2,
2,
16,
true,
0,
complain_overflow_signed,
bfd_elf_generic_reloc,
"R_M32R_18_PCREL",
false,
0xffff,
0xffff,
true),
HOWTO (R_M32R_26_PCREL,
2,
2,
26,
true,
0,
complain_overflow_signed,
bfd_elf_generic_reloc,
"R_M32R_26_PCREL",
false,
0xffffff,
0xffffff,
true),
HOWTO (R_M32R_HI16_ULO,
16,
2,
16,
false,
0,
complain_overflow_dont,
m32r_elf_hi16_reloc,
"R_M32R_HI16_ULO",
true,
0x0000ffff,
0x0000ffff,
false),
HOWTO (R_M32R_HI16_SLO,
16,
2,
16,
false,
0,
complain_overflow_dont,
m32r_elf_hi16_reloc,
"R_M32R_HI16_SLO",
true,
0x0000ffff,
0x0000ffff,
false),
HOWTO (R_M32R_LO16,
0,
2,
16,
false,
0,
complain_overflow_dont,
m32r_elf_lo16_reloc,
"R_M32R_LO16",
true,
0x0000ffff,
0x0000ffff,
false),
HOWTO (R_M32R_SDA16,
0,
2,
16,
false,
0,
complain_overflow_signed,
m32r_elf_sda16_reloc,
"R_M32R_SDA16",
true,
0x0000ffff,
0x0000ffff,
false),
HOWTO (R_M32R_GNU_VTINHERIT,
0,
2,
0,
false,
0,
complain_overflow_dont,
NULL,
"R_M32R_GNU_VTINHERIT",
false,
0,
0,
false),
HOWTO (R_M32R_GNU_VTENTRY,
0,
2,
0,
false,
0,
complain_overflow_dont,
_bfd_elf_rel_vtable_reloc_fn,
"R_M32R_GNU_VTENTRY",
false,
0,
0,
false),
};
static bfd_reloc_status_type
m32r_elf_10_pcrel_reloc (abfd, reloc_entry, symbol, data,
input_section, output_bfd, error_message)
bfd * abfd;
arelent * reloc_entry;
asymbol * symbol;
PTR data;
asection * input_section;
bfd * output_bfd;
char ** error_message ATTRIBUTE_UNUSED;
{
if (output_bfd != (bfd *) NULL
&& (symbol->flags & BSF_SECTION_SYM) == 0
&& (! reloc_entry->howto->partial_inplace
|| reloc_entry->addend == 0))
{
reloc_entry->address += input_section->output_offset;
return bfd_reloc_ok;
}
if (output_bfd != NULL)
{
return bfd_reloc_continue;
}
return m32r_elf_do_10_pcrel_reloc (abfd, reloc_entry->howto,
input_section,
data, reloc_entry->address,
symbol->section,
(symbol->value
+ symbol->section->output_section->vma
+ symbol->section->output_offset),
reloc_entry->addend);
}
static bfd_reloc_status_type
m32r_elf_do_10_pcrel_reloc (abfd, howto, input_section, data, offset,
symbol_section, symbol_value, addend)
bfd *abfd;
reloc_howto_type *howto;
asection *input_section;
bfd_byte *data;
bfd_vma offset;
asection *symbol_section ATTRIBUTE_UNUSED;
bfd_vma symbol_value;
bfd_vma addend;
{
bfd_signed_vma relocation;
unsigned long x;
bfd_reloc_status_type status;
if (offset > input_section->_cooked_size)
return bfd_reloc_outofrange;
relocation = symbol_value + addend;
relocation -= (input_section->output_section->vma
+ input_section->output_offset);
relocation -= (offset & -(bfd_vma) 4);
if (relocation < -0x200 || relocation > 0x1ff)
status = bfd_reloc_overflow;
else
status = bfd_reloc_ok;
x = bfd_get_16 (abfd, data + offset);
relocation >>= howto->rightshift;
relocation <<= howto->bitpos;
x = (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask);
bfd_put_16 (abfd, (bfd_vma) x, data + offset);
return status;
}
struct m32r_hi16
{
struct m32r_hi16 *next;
bfd_byte *addr;
bfd_vma addend;
};
static struct m32r_hi16 *m32r_hi16_list;
static bfd_reloc_status_type
m32r_elf_hi16_reloc (abfd, reloc_entry, symbol, data,
input_section, output_bfd, error_message)
bfd *abfd ATTRIBUTE_UNUSED;
arelent *reloc_entry;
asymbol *symbol;
PTR data;
asection *input_section;
bfd *output_bfd;
char **error_message ATTRIBUTE_UNUSED;
{
bfd_reloc_status_type ret;
bfd_vma relocation;
struct m32r_hi16 *n;
if (output_bfd != (bfd *) NULL
&& (symbol->flags & BSF_SECTION_SYM) == 0
&& reloc_entry->addend == 0)
{
reloc_entry->address += input_section->output_offset;
return bfd_reloc_ok;
}
if (reloc_entry->address > input_section->_cooked_size)
return bfd_reloc_outofrange;
ret = bfd_reloc_ok;
if (bfd_is_und_section (symbol->section)
&& output_bfd == (bfd *) NULL)
ret = bfd_reloc_undefined;
if (bfd_is_com_section (symbol->section))
relocation = 0;
else
relocation = symbol->value;
relocation += symbol->section->output_section->vma;
relocation += symbol->section->output_offset;
relocation += reloc_entry->addend;
n = (struct m32r_hi16 *) bfd_malloc ((bfd_size_type) sizeof *n);
if (n == NULL)
return bfd_reloc_outofrange;
n->addr = (bfd_byte *) data + reloc_entry->address;
n->addend = relocation;
n->next = m32r_hi16_list;
m32r_hi16_list = n;
if (output_bfd != (bfd *) NULL)
reloc_entry->address += input_section->output_offset;
return ret;
}
static void
m32r_elf_relocate_hi16 (input_bfd, type, relhi, rello, contents, addend)
bfd *input_bfd;
int type;
Elf_Internal_Rela *relhi;
Elf_Internal_Rela *rello;
bfd_byte *contents;
bfd_vma addend;
{
unsigned long insn;
bfd_vma addlo;
insn = bfd_get_32 (input_bfd, contents + relhi->r_offset);
addlo = bfd_get_32 (input_bfd, contents + rello->r_offset);
if (type == R_M32R_HI16_SLO)
addlo = ((addlo & 0xffff) ^ 0x8000) - 0x8000;
else
addlo &= 0xffff;
addend += ((insn & 0xffff) << 16) + addlo;
if (type == R_M32R_HI16_SLO
&& (addend & 0x8000) != 0)
addend += 0x10000;
bfd_put_32 (input_bfd,
(insn & 0xffff0000) | ((addend >> 16) & 0xffff),
contents + relhi->r_offset);
}
bfd_reloc_status_type
m32r_elf_lo16_reloc (input_bfd, reloc_entry, symbol, data,
input_section, output_bfd, error_message)
bfd *input_bfd;
arelent *reloc_entry;
asymbol *symbol;
PTR data;
asection *input_section;
bfd *output_bfd;
char **error_message;
{
if (output_bfd != (bfd *) NULL
&& (symbol->flags & BSF_SECTION_SYM) == 0
&& reloc_entry->addend == 0)
{
reloc_entry->address += input_section->output_offset;
return bfd_reloc_ok;
}
if (m32r_hi16_list != NULL)
{
struct m32r_hi16 *l;
l = m32r_hi16_list;
while (l != NULL)
{
unsigned long insn;
unsigned long val;
unsigned long vallo;
struct m32r_hi16 *next;
insn = bfd_get_32 (input_bfd, l->addr);
vallo = ((bfd_get_32 (input_bfd, (bfd_byte *) data + reloc_entry->address)
& 0xffff) ^ 0x8000) - 0x8000;
val = ((insn & 0xffff) << 16) + vallo;
val += l->addend;
if ((val & 0x8000) != 0)
val += 0x10000;
insn = (insn &~ (bfd_vma) 0xffff) | ((val >> 16) & 0xffff);
bfd_put_32 (input_bfd, (bfd_vma) insn, l->addr);
next = l->next;
free (l);
l = next;
}
m32r_hi16_list = NULL;
}
return m32r_elf_generic_reloc (input_bfd, reloc_entry, symbol, data,
input_section, output_bfd, error_message);
}
bfd_reloc_status_type
m32r_elf_generic_reloc (input_bfd, reloc_entry, symbol, data,
input_section, output_bfd, error_message)
bfd *input_bfd;
arelent *reloc_entry;
asymbol *symbol;
PTR data;
asection *input_section;
bfd *output_bfd;
char **error_message ATTRIBUTE_UNUSED;
{
bfd_reloc_status_type ret;
bfd_vma relocation;
bfd_byte *inplace_address;
if (output_bfd != (bfd *) NULL
&& (symbol->flags & BSF_SECTION_SYM) == 0
&& reloc_entry->addend == 0)
{
reloc_entry->address += input_section->output_offset;
return bfd_reloc_ok;
}
if (reloc_entry->address > input_section->_cooked_size)
return bfd_reloc_outofrange;
ret = bfd_reloc_ok;
if (bfd_is_und_section (symbol->section)
&& output_bfd == (bfd *) NULL)
ret = bfd_reloc_undefined;
if (bfd_is_com_section (symbol->section)
|| output_bfd != (bfd *) NULL)
relocation = 0;
else
relocation = symbol->value;
if (output_bfd == (bfd *) NULL)
{
relocation += symbol->section->output_section->vma;
relocation += symbol->section->output_offset;
}
relocation += reloc_entry->addend;
inplace_address = (bfd_byte *) data + reloc_entry->address;
#define DOIT(x) \
x = ( (x & ~reloc_entry->howto->dst_mask) | \
(((x & reloc_entry->howto->src_mask) + relocation) & \
reloc_entry->howto->dst_mask))
switch (reloc_entry->howto->size)
{
case 1:
{
short x = bfd_get_16 (input_bfd, inplace_address);
DOIT (x);
bfd_put_16 (input_bfd, (bfd_vma) x, inplace_address);
}
break;
case 2:
{
unsigned long x = bfd_get_32 (input_bfd, inplace_address);
DOIT (x);
bfd_put_32 (input_bfd, (bfd_vma)x , inplace_address);
}
break;
default:
BFD_ASSERT (0);
}
if (output_bfd != (bfd *) NULL)
reloc_entry->address += input_section->output_offset;
return ret;
}
static bfd_reloc_status_type
m32r_elf_sda16_reloc (abfd, reloc_entry, symbol, data,
input_section, output_bfd, error_message)
bfd *abfd ATTRIBUTE_UNUSED;
arelent *reloc_entry;
asymbol *symbol;
PTR data ATTRIBUTE_UNUSED;
asection *input_section;
bfd *output_bfd;
char **error_message ATTRIBUTE_UNUSED;
{
if (output_bfd != (bfd *) NULL
&& (symbol->flags & BSF_SECTION_SYM) == 0
&& (! reloc_entry->howto->partial_inplace
|| reloc_entry->addend == 0))
{
reloc_entry->address += input_section->output_offset;
return bfd_reloc_ok;
}
if (output_bfd != NULL)
{
return bfd_reloc_continue;
}
abort ();
}
struct m32r_reloc_map
{
bfd_reloc_code_real_type bfd_reloc_val;
unsigned char elf_reloc_val;
};
static const struct m32r_reloc_map m32r_reloc_map[] =
{
{ BFD_RELOC_NONE, R_M32R_NONE },
{ BFD_RELOC_16, R_M32R_16 },
{ BFD_RELOC_32, R_M32R_32 },
{ BFD_RELOC_M32R_24, R_M32R_24 },
{ BFD_RELOC_M32R_10_PCREL, R_M32R_10_PCREL },
{ BFD_RELOC_M32R_18_PCREL, R_M32R_18_PCREL },
{ BFD_RELOC_M32R_26_PCREL, R_M32R_26_PCREL },
{ BFD_RELOC_M32R_HI16_ULO, R_M32R_HI16_ULO },
{ BFD_RELOC_M32R_HI16_SLO, R_M32R_HI16_SLO },
{ BFD_RELOC_M32R_LO16, R_M32R_LO16 },
{ BFD_RELOC_M32R_SDA16, R_M32R_SDA16 },
{ BFD_RELOC_VTABLE_INHERIT, R_M32R_GNU_VTINHERIT },
{ BFD_RELOC_VTABLE_ENTRY, R_M32R_GNU_VTENTRY },
};
static reloc_howto_type *
bfd_elf32_bfd_reloc_type_lookup (abfd, code)
bfd *abfd ATTRIBUTE_UNUSED;
bfd_reloc_code_real_type code;
{
unsigned int i;
for (i = 0;
i < sizeof (m32r_reloc_map) / sizeof (struct m32r_reloc_map);
i++)
{
if (m32r_reloc_map[i].bfd_reloc_val == code)
return &m32r_elf_howto_table[m32r_reloc_map[i].elf_reloc_val];
}
return NULL;
}
static void
m32r_info_to_howto_rel (abfd, cache_ptr, dst)
bfd *abfd ATTRIBUTE_UNUSED;
arelent *cache_ptr;
Elf32_Internal_Rel *dst;
{
unsigned int r_type;
r_type = ELF32_R_TYPE (dst->r_info);
BFD_ASSERT (r_type < (unsigned int) R_M32R_max);
cache_ptr->howto = &m32r_elf_howto_table[r_type];
}
boolean
_bfd_m32r_elf_section_from_bfd_section (abfd, sec, retval)
bfd *abfd ATTRIBUTE_UNUSED;
asection *sec;
int *retval;
{
if (strcmp (bfd_get_section_name (abfd, sec), ".scommon") == 0)
{
*retval = SHN_M32R_SCOMMON;
return true;
}
return false;
}
static asection m32r_elf_scom_section;
static asymbol m32r_elf_scom_symbol;
static asymbol *m32r_elf_scom_symbol_ptr;
void
_bfd_m32r_elf_symbol_processing (abfd, asym)
bfd *abfd ATTRIBUTE_UNUSED;
asymbol *asym;
{
elf_symbol_type *elfsym;
elfsym = (elf_symbol_type *) asym;
switch (elfsym->internal_elf_sym.st_shndx)
{
case SHN_M32R_SCOMMON:
if (m32r_elf_scom_section.name == NULL)
{
m32r_elf_scom_section.name = ".scommon";
m32r_elf_scom_section.flags = SEC_IS_COMMON;
m32r_elf_scom_section.output_section = &m32r_elf_scom_section;
m32r_elf_scom_section.symbol = &m32r_elf_scom_symbol;
m32r_elf_scom_section.symbol_ptr_ptr = &m32r_elf_scom_symbol_ptr;
m32r_elf_scom_symbol.name = ".scommon";
m32r_elf_scom_symbol.flags = BSF_SECTION_SYM;
m32r_elf_scom_symbol.section = &m32r_elf_scom_section;
m32r_elf_scom_symbol_ptr = &m32r_elf_scom_symbol;
}
asym->section = &m32r_elf_scom_section;
asym->value = elfsym->internal_elf_sym.st_size;
break;
}
}
static boolean
m32r_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
bfd *abfd;
struct bfd_link_info *info;
const Elf_Internal_Sym *sym;
const char **namep;
flagword *flagsp ATTRIBUTE_UNUSED;
asection **secp;
bfd_vma *valp;
{
if (! info->relocateable
&& (*namep)[0] == '_' && (*namep)[1] == 'S'
&& strcmp (*namep, "_SDA_BASE_") == 0)
{
struct elf_link_hash_entry *h;
asection *s = bfd_get_section_by_name (abfd, ".sdata");
if (s == NULL)
{
flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
| SEC_IN_MEMORY | SEC_LINKER_CREATED);
s = bfd_make_section_anyway (abfd, ".sdata");
if (s == NULL)
return false;
bfd_set_section_flags (abfd, s, flags);
bfd_set_section_alignment (abfd, s, 2);
}
h = (struct elf_link_hash_entry *)
bfd_link_hash_lookup (info->hash, "_SDA_BASE_", false, false, false);
if ((h == NULL || h->root.type == bfd_link_hash_undefined)
&& !(_bfd_generic_link_add_one_symbol (info,
abfd,
"_SDA_BASE_",
BSF_GLOBAL,
s,
(bfd_vma) 32768,
(const char *) NULL,
false,
get_elf_backend_data (abfd)->collect,
(struct bfd_link_hash_entry **) &h)))
return false;
h->type = STT_OBJECT;
}
switch (sym->st_shndx)
{
case SHN_M32R_SCOMMON:
*secp = bfd_make_section_old_way (abfd, ".scommon");
(*secp)->flags |= SEC_IS_COMMON;
*valp = sym->st_size;
break;
}
return true;
}
static bfd_reloc_status_type
m32r_elf_final_sda_base (output_bfd, info, error_message, psb)
bfd *output_bfd;
struct bfd_link_info *info;
const char **error_message;
bfd_vma *psb;
{
if (elf_gp (output_bfd) == 0)
{
struct bfd_link_hash_entry *h;
h = bfd_link_hash_lookup (info->hash, "_SDA_BASE_", false, false, true);
if (h != (struct bfd_link_hash_entry *) NULL
&& h->type == bfd_link_hash_defined)
elf_gp (output_bfd) = (h->u.def.value
+ h->u.def.section->output_section->vma
+ h->u.def.section->output_offset);
else
{
*psb = elf_gp (output_bfd) = 4;
*error_message =
(const char *) _("SDA relocation when _SDA_BASE_ not defined");
return bfd_reloc_dangerous;
}
}
*psb = elf_gp (output_bfd);
return bfd_reloc_ok;
}
static boolean
m32r_elf_relocate_section (output_bfd, info, input_bfd, input_section,
contents, relocs, local_syms, local_sections)
bfd *output_bfd ATTRIBUTE_UNUSED;
struct bfd_link_info *info;
bfd *input_bfd;
asection *input_section;
bfd_byte *contents;
Elf_Internal_Rela *relocs;
Elf_Internal_Sym *local_syms;
asection **local_sections;
{
Elf_Internal_Shdr *symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd);
Elf_Internal_Rela *rel, *relend;
boolean ret = true;
rel = relocs;
relend = relocs + input_section->reloc_count;
for (; rel < relend; rel++)
{
int r_type;
reloc_howto_type *howto;
unsigned long r_symndx;
bfd_vma addend = rel->r_addend;
bfd_vma offset = rel->r_offset;
struct elf_link_hash_entry *h;
Elf_Internal_Sym *sym;
asection *sec;
const char *sym_name;
bfd_reloc_status_type r;
const char *errmsg = NULL;
h = NULL;
r_type = ELF32_R_TYPE (rel->r_info);
if (r_type < 0 || r_type >= (int) R_M32R_max)
{
(*_bfd_error_handler) (_("%s: unknown relocation type %d"),
bfd_archive_filename (input_bfd),
(int) r_type);
bfd_set_error (bfd_error_bad_value);
ret = false;
continue;
}
if (r_type == R_M32R_GNU_VTENTRY
|| r_type == R_M32R_GNU_VTINHERIT)
continue;
howto = m32r_elf_howto_table + r_type;
r_symndx = ELF32_R_SYM (rel->r_info);
if (info->relocateable)
{
sec = NULL;
if (r_symndx >= symtab_hdr->sh_info)
{
continue;
}
sym = local_syms + r_symndx;
sym_name = "<local symbol>";
if (ELF_ST_TYPE (sym->st_info) != STT_SECTION)
{
continue;
}
sec = local_sections[r_symndx];
addend += sec->output_offset + sym->st_value;
#ifndef USE_REL
rel->r_addend = addend;
#endif
#ifndef USE_REL
continue;
#else
if (! howto->partial_inplace)
continue;
if (r_type != R_M32R_HI16_SLO && r_type != R_M32R_HI16_ULO)
r = _bfd_relocate_contents (howto, input_bfd,
addend, contents + offset);
else
{
Elf_Internal_Rela *lorel;
for (lorel = rel + 1;
(lorel < relend
&& (ELF32_R_TYPE (lorel->r_info) == R_M32R_HI16_SLO
|| ELF32_R_TYPE (lorel->r_info) == R_M32R_HI16_ULO));
lorel++)
continue;
if (lorel < relend
&& ELF32_R_TYPE (lorel->r_info) == R_M32R_LO16)
{
m32r_elf_relocate_hi16 (input_bfd, r_type, rel, lorel,
contents, addend);
r = bfd_reloc_ok;
}
else
r = _bfd_relocate_contents (howto, input_bfd,
addend, contents + offset);
}
#endif
}
else
{
bfd_vma relocation;
sym = NULL;
sec = NULL;
if (r_symndx < symtab_hdr->sh_info)
{
sym = local_syms + r_symndx;
sec = local_sections[r_symndx];
sym_name = "<local symbol>";
#ifndef USE_REL
relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
addend = rel->r_addend;
#else
relocation = (sec->output_section->vma
+ sec->output_offset
+ sym->st_value);
#endif
}
else
{
h = sym_hashes[r_symndx - symtab_hdr->sh_info];
while (h->root.type == bfd_link_hash_indirect
|| h->root.type == bfd_link_hash_warning)
h = (struct elf_link_hash_entry *) h->root.u.i.link;
sym_name = h->root.root.string;
if (h->root.type == bfd_link_hash_defined
|| h->root.type == bfd_link_hash_defweak)
{
sec = h->root.u.def.section;
if (sec->output_section == NULL)
relocation = 0;
else
relocation = (h->root.u.def.value
+ sec->output_section->vma
+ sec->output_offset);
}
else if (h->root.type == bfd_link_hash_undefweak)
relocation = 0;
else
{
if (! ((*info->callbacks->undefined_symbol)
(info, h->root.root.string, input_bfd,
input_section, offset, true)))
return false;
relocation = 0;
}
}
if (offset > input_section->_raw_size)
{
r = bfd_reloc_outofrange;
goto check_reloc;
}
switch ((int) r_type)
{
case (int) R_M32R_10_PCREL :
r = m32r_elf_do_10_pcrel_reloc (input_bfd, howto, input_section,
contents, offset,
sec, relocation, addend);
break;
case (int) R_M32R_HI16_SLO :
case (int) R_M32R_HI16_ULO :
{
Elf_Internal_Rela *lorel;
for (lorel = rel + 1;
(lorel < relend
&& (ELF32_R_TYPE (lorel->r_info) == R_M32R_HI16_SLO
|| ELF32_R_TYPE (lorel->r_info) == R_M32R_HI16_ULO));
lorel++)
continue;
if (lorel < relend
&& ELF32_R_TYPE (lorel->r_info) == R_M32R_LO16)
{
m32r_elf_relocate_hi16 (input_bfd, r_type, rel, lorel,
contents, relocation + addend);
r = bfd_reloc_ok;
}
else
r = _bfd_final_link_relocate (howto, input_bfd, input_section,
contents, offset,
relocation, addend);
}
break;
case (int) R_M32R_SDA16 :
{
const char *name;
BFD_ASSERT (sec != NULL);
name = bfd_get_section_name (abfd, sec);
if (strcmp (name, ".sdata") == 0
|| strcmp (name, ".sbss") == 0
|| strcmp (name, ".scommon") == 0)
{
bfd_vma sda_base;
bfd *out_bfd = sec->output_section->owner;
r = m32r_elf_final_sda_base (out_bfd, info,
&errmsg,
&sda_base);
if (r != bfd_reloc_ok)
{
ret = false;
goto check_reloc;
}
relocation -= sda_base;
}
else
{
(*_bfd_error_handler)
(_("%s: The target (%s) of an %s relocation is in the wrong section (%s)"),
bfd_archive_filename (input_bfd),
sym_name,
m32r_elf_howto_table[(int) r_type].name,
bfd_get_section_name (abfd, sec));
ret = false;
continue;
}
}
default :
r = _bfd_final_link_relocate (howto, input_bfd, input_section,
contents, offset,
relocation, addend);
break;
}
}
check_reloc:
if (r != bfd_reloc_ok)
{
const char *name;
if (h != NULL)
name = h->root.root.string;
else
{
name = (bfd_elf_string_from_elf_section
(input_bfd, symtab_hdr->sh_link, sym->st_name));
if (name == NULL || *name == '\0')
name = bfd_section_name (input_bfd, sec);
}
if (errmsg != NULL)
goto common_error;
switch (r)
{
case bfd_reloc_overflow:
if (! ((*info->callbacks->reloc_overflow)
(info, name, howto->name, (bfd_vma) 0,
input_bfd, input_section, offset)))
return false;
break;
case bfd_reloc_undefined:
if (! ((*info->callbacks->undefined_symbol)
(info, name, input_bfd, input_section,
offset, true)))
return false;
break;
case bfd_reloc_outofrange:
errmsg = _("internal error: out of range error");
goto common_error;
case bfd_reloc_notsupported:
errmsg = _("internal error: unsupported relocation error");
goto common_error;
case bfd_reloc_dangerous:
errmsg = _("internal error: dangerous error");
goto common_error;
default:
errmsg = _("internal error: unknown error");
common_error:
if (!((*info->callbacks->warning)
(info, errmsg, name, input_bfd, input_section,
offset)))
return false;
break;
}
}
}
return ret;
}
#if 0
static boolean
m32r_elf_relax_section (abfd, sec, link_info, again)
bfd *abfd;
asection *sec;
struct bfd_link_info *link_info;
boolean *again;
{
Elf_Internal_Shdr *symtab_hdr;
Elf_Internal_Rela *internal_relocs;
Elf_Internal_Rela *free_relocs = NULL;
Elf_Internal_Rela *irel, *irelend;
bfd_byte *contents = NULL;
bfd_byte *free_contents = NULL;
Elf32_External_Sym *extsyms = NULL;
Elf32_External_Sym *free_extsyms = NULL;
*again = false;
if (link_info->relocateable
|| (sec->flags & SEC_RELOC) == 0
|| sec->reloc_count == 0
|| (sec->flags & SEC_CODE) == 0
|| 0 )
return true;
if (sec->_cooked_size == 0)
sec->_cooked_size = sec->_raw_size;
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
internal_relocs = (_bfd_elf32_link_read_relocs
(abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
link_info->keep_memory));
if (internal_relocs == NULL)
goto error_return;
if (! link_info->keep_memory)
free_relocs = internal_relocs;
irelend = internal_relocs + sec->reloc_count;
for (irel = internal_relocs; irel < irelend; irel++)
{
bfd_vma symval;
if (ELF32_R_TYPE (irel->r_info) != (int) R_M32R_HI16_SLO)
continue;
if (contents == NULL)
{
if (elf_section_data (sec)->this_hdr.contents != NULL)
contents = elf_section_data (sec)->this_hdr.contents;
else
{
contents = (bfd_byte *) bfd_malloc (sec->_raw_size);
if (contents == NULL)
goto error_return;
free_contents = contents;
if (! bfd_get_section_contents (abfd, sec, contents,
(file_ptr) 0, sec->_raw_size))
goto error_return;
}
}
if (extsyms == NULL)
{
if (symtab_hdr->contents != NULL)
extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
else
{
bfd_size_type amt = symtab_hdr->sh_size;
extsyms = (Elf32_External_Sym *) bfd_malloc (amt);
if (extsyms == NULL)
goto error_return;
free_extsyms = extsyms;
if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0
|| bfd_bread (extsyms, amt, abfd) != amt)
goto error_return;
}
}
if (ELF32_R_SYM (irel->r_info) < symtab_hdr->sh_info)
{
Elf_Internal_Sym isym;
asection *sym_sec;
bfd_elf32_swap_symbol_in (abfd,
extsyms + ELF32_R_SYM (irel->r_info),
&isym);
sym_sec = bfd_section_from_elf_index (abfd, isym.st_shndx);
symval = (isym.st_value
+ sym_sec->output_section->vma
+ sym_sec->output_offset);
}
else
{
unsigned long indx;
struct elf_link_hash_entry *h;
indx = ELF32_R_SYM (irel->r_info) - symtab_hdr->sh_info;
h = elf_sym_hashes (abfd)[indx];
BFD_ASSERT (h != NULL);
if (h->root.type != bfd_link_hash_defined
&& h->root.type != bfd_link_hash_defweak)
{
continue;
}
symval = (h->root.u.def.value
+ h->root.u.def.section->output_section->vma
+ h->root.u.def.section->output_offset);
}
if (ELF32_R_TYPE (irel->r_info) == (int) R_M32R_HI16_SLO)
{
Elf_Internal_Rela *nrel;
bfd_vma pc = (sec->output_section->vma + sec->output_offset
+ irel->r_offset);
bfd_signed_vma pcrel_value = symval - pc;
unsigned int code,reg;
int addend,nop_p,bl8_p,to_delete;
if (irel->r_offset > sec->_cooked_size - 8)
continue;
nrel = irel + 1;
if (nrel == irelend
|| irel->r_offset + 4 != nrel->r_offset
|| ELF32_R_TYPE (nrel->r_info) != (int) R_M32R_LO16)
continue;
code = bfd_get_16 (abfd, contents + irel->r_offset + 0);
if ((code & 0xf0ff) != 0xd0c0)
continue;
reg = (code & 0x0f00) >> 8;
code = bfd_get_16 (abfd, contents + irel->r_offset + 4);
if (code != (0x80a0 | reg | (reg << 8)))
continue;
#ifndef USE_REL
pcrel_value += irel->r_addend;
#else
addend = bfd_get_signed_16 (abfd, contents + irel->r_offset + 2);
pcrel_value += addend;
#endif
if (pcrel_value >= -(1 << 25) && pcrel_value < (1 << 25) + 4
&& (irel->r_offset <= sec->_cooked_size - 12)
&& ((code = bfd_get_16 (abfd, contents + irel->r_offset + 8)),
code != (0x1ec0 | reg)))
{
code = bfd_get_16 (abfd, contents + irel->r_offset + 10);
nop_p = (code & 0x7fff) == NOP_INSN;
bl8_p = pcrel_value >= -0x200 && pcrel_value < 0x200;
if (bl8_p)
{
#ifndef USE_REL
code = 0x7e000000 | MAKE_PARALLEL (code);
#else
code = (0x7e000000 + (((addend >> 2) & 0xff) << 16)) | MAKE_PARALLEL (code);
#endif
to_delete = 8;
}
else
{
#ifndef USE_REL
code = 0xfe000000;
#else
code = 0xfe000000 + ((addend >> 2) & 0xffffff);
#endif
to_delete = nop_p ? 8 : 4;
}
bfd_put_32 (abfd, code, contents + irel->r_offset);
irel->r_info = ELF32_R_INFO (ELF32_R_SYM (nrel->r_info),
bl8_p ? R_M32R_10_PCREL : R_M32R_26_PCREL);
nrel->r_info = ELF32_R_INFO (ELF32_R_SYM (nrel->r_info),
R_M32R_NONE);
}
else if (addend >= 0
&& symval + addend <= 0xffffff)
{
code = 0xe0000000 | (reg << 24) | (addend & 0xffffff);
bfd_put_32 (abfd, code, contents + irel->r_offset);
to_delete = 4;
nop_p = 1;
}
else
{
continue;
}
elf_section_data (sec)->relocs = internal_relocs;
free_relocs = NULL;
elf_section_data (sec)->this_hdr.contents = contents;
free_contents = NULL;
symtab_hdr->contents = (bfd_byte *) extsyms;
free_extsyms = NULL;
if (!m32r_elf_relax_delete_bytes (abfd, sec,
irel->r_offset + 4, to_delete))
goto error_return;
if (! nop_p && to_delete == 4)
bfd_put_16 (abfd, NOP_INSN, contents + irel->r_offset + 4);
*again = true;
continue;
}
}
if (free_relocs != NULL)
{
free (free_relocs);
free_relocs = NULL;
}
if (free_contents != NULL)
{
if (! link_info->keep_memory)
free (free_contents);
else
{
elf_section_data (sec)->this_hdr.contents = contents;
}
free_contents = NULL;
}
if (free_extsyms != NULL)
{
if (! link_info->keep_memory)
free (free_extsyms);
else
{
symtab_hdr->contents = extsyms;
}
free_extsyms = NULL;
}
return true;
error_return:
if (free_relocs != NULL)
free (free_relocs);
if (free_contents != NULL)
free (free_contents);
if (free_extsyms != NULL)
free (free_extsyms);
return false;
}
static boolean
m32r_elf_relax_delete_bytes (abfd, sec, addr, count)
bfd *abfd;
asection *sec;
bfd_vma addr;
int count;
{
Elf_Internal_Shdr *symtab_hdr;
Elf32_External_Sym *extsyms;
int shndx, index;
bfd_byte *contents;
Elf_Internal_Rela *irel, *irelend;
Elf_Internal_Rela *irelalign;
bfd_vma toaddr;
Elf32_External_Sym *esym, *esymend;
struct elf_link_hash_entry *sym_hash;
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
shndx = _bfd_elf_section_from_bfd_section (abfd, sec);
contents = elf_section_data (sec)->this_hdr.contents;
irelalign = NULL;
toaddr = sec->_cooked_size;
irel = elf_section_data (sec)->relocs;
irelend = irel + sec->reloc_count;
memmove (contents + addr, contents + addr + count, toaddr - addr - count);
sec->_cooked_size -= count;
for (irel = elf_section_data (sec)->relocs; irel < irelend; irel++)
{
if ((irel->r_offset > addr
&& irel->r_offset < toaddr))
irel->r_offset -= count;
}
esym = extsyms;
esymend = esym + symtab_hdr->sh_info;
for (; esym < esymend; esym++)
{
Elf_Internal_Sym isym;
bfd_elf32_swap_symbol_in (abfd, esym, &isym);
if (isym.st_shndx == shndx
&& isym.st_value > addr
&& isym.st_value < toaddr)
{
isym.st_value -= count;
bfd_elf32_swap_symbol_out (abfd, &isym, esym);
}
}
esym = extsyms + symtab_hdr->sh_info;
esymend = extsyms + (symtab_hdr->sh_size / sizeof (Elf32_External_Sym));
for (index = 0; esym < esymend; esym++, index++)
{
Elf_Internal_Sym isym;
bfd_elf32_swap_symbol_in (abfd, esym, &isym);
sym_hash = elf_sym_hashes (abfd)[index];
if (isym.st_shndx == shndx
&& ((sym_hash)->root.type == bfd_link_hash_defined
|| (sym_hash)->root.type == bfd_link_hash_defweak)
&& (sym_hash)->root.u.def.section == sec
&& (sym_hash)->root.u.def.value > addr
&& (sym_hash)->root.u.def.value < toaddr)
{
(sym_hash)->root.u.def.value -= count;
}
}
return true;
}
static bfd_byte *
m32r_elf_get_relocated_section_contents (output_bfd, link_info, link_order,
data, relocateable, symbols)
bfd *output_bfd;
struct bfd_link_info *link_info;
struct bfd_link_order *link_order;
bfd_byte *data;
boolean relocateable;
asymbol **symbols;
{
Elf_Internal_Shdr *symtab_hdr;
asection *input_section = link_order->u.indirect.section;
bfd *input_bfd = input_section->owner;
asection **sections = NULL;
Elf_Internal_Rela *internal_relocs = NULL;
Elf32_External_Sym *external_syms = NULL;
Elf_Internal_Sym *internal_syms = NULL;
bfd_size_type amt;
if (relocateable
|| elf_section_data (input_section)->this_hdr.contents == NULL)
return bfd_generic_get_relocated_section_contents (output_bfd, link_info,
link_order, data,
relocateable,
symbols);
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
memcpy (data, elf_section_data (input_section)->this_hdr.contents,
input_section->_raw_size);
if ((input_section->flags & SEC_RELOC) != 0
&& input_section->reloc_count > 0)
{
Elf_Internal_Sym *isymp;
asection **secpp;
Elf32_External_Sym *esym, *esymend;
if (symtab_hdr->contents != NULL)
external_syms = (Elf32_External_Sym *) symtab_hdr->contents;
else
{
amt = symtab_hdr->sh_info;
amt *= sizeof (Elf32_External_Sym);
external_syms = (Elf32_External_Sym *) bfd_malloc (amt);
if (external_syms == NULL && symtab_hdr->sh_info > 0)
goto error_return;
if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
|| bfd_bread (external_syms, amt, input_bfd) != amt)
goto error_return;
}
internal_relocs = (_bfd_elf32_link_read_relocs
(input_bfd, input_section, (PTR) NULL,
(Elf_Internal_Rela *) NULL, false));
if (internal_relocs == NULL)
goto error_return;
amt = symtab_hdr->sh_info;
amt *= sizeof (Elf_Internal_Sym);
internal_syms = (Elf_Internal_Sym *) bfd_malloc (amt);
if (internal_syms == NULL && symtab_hdr->sh_info > 0)
goto error_return;
amt = symtab_hdr->sh_info;
amt *= sizeof (asection *);
sections = (asection **) bfd_malloc (amt);
if (sections == NULL && symtab_hdr->sh_info > 0)
goto error_return;
isymp = internal_syms;
secpp = sections;
esym = external_syms;
esymend = esym + symtab_hdr->sh_info;
for (; esym < esymend; ++esym, ++isymp, ++secpp)
{
asection *isec;
bfd_elf32_swap_symbol_in (input_bfd, esym, isymp);
if (isymp->st_shndx == SHN_UNDEF)
isec = bfd_und_section_ptr;
else if (isymp->st_shndx == SHN_ABS)
isec = bfd_abs_section_ptr;
else if (isymp->st_shndx == SHN_COMMON)
isec = bfd_com_section_ptr;
else if (isymp->st_shndx == SHN_M32R_SCOMMON)
isec = &m32r_elf_scom_section;
else
isec = bfd_section_from_elf_index (input_bfd, isymp->st_shndx);
*secpp = isec;
}
if (! m32r_elf_relocate_section (output_bfd, link_info, input_bfd,
input_section, data, internal_relocs,
internal_syms, sections))
goto error_return;
if (sections != NULL)
free (sections);
sections = NULL;
if (internal_syms != NULL)
free (internal_syms);
internal_syms = NULL;
if (external_syms != NULL && symtab_hdr->contents == NULL)
free (external_syms);
external_syms = NULL;
if (internal_relocs != elf_section_data (input_section)->relocs)
free (internal_relocs);
internal_relocs = NULL;
}
return data;
error_return:
if (internal_relocs != NULL
&& internal_relocs != elf_section_data (input_section)->relocs)
free (internal_relocs);
if (external_syms != NULL && symtab_hdr->contents == NULL)
free (external_syms);
if (internal_syms != NULL)
free (internal_syms);
if (sections != NULL)
free (sections);
return NULL;
}
#endif
static boolean
m32r_elf_object_p (abfd)
bfd *abfd;
{
switch (elf_elfheader (abfd)->e_flags & EF_M32R_ARCH)
{
default:
case E_M32R_ARCH: (void) bfd_default_set_arch_mach (abfd, bfd_arch_m32r, bfd_mach_m32r); break;
case E_M32RX_ARCH: (void) bfd_default_set_arch_mach (abfd, bfd_arch_m32r, bfd_mach_m32rx); break;
}
return true;
}
static void
m32r_elf_final_write_processing (abfd, linker)
bfd * abfd;
boolean linker ATTRIBUTE_UNUSED;
{
unsigned long val;
switch (bfd_get_mach (abfd))
{
default:
case bfd_mach_m32r: val = E_M32R_ARCH; break;
case bfd_mach_m32rx: val = E_M32RX_ARCH; break;
}
elf_elfheader (abfd)->e_flags &=~ EF_M32R_ARCH;
elf_elfheader (abfd)->e_flags |= val;
}
static boolean
m32r_elf_set_private_flags (abfd, flags)
bfd * abfd;
flagword flags;
{
BFD_ASSERT (!elf_flags_init (abfd)
|| elf_elfheader (abfd)->e_flags == flags);
elf_elfheader (abfd)->e_flags = flags;
elf_flags_init (abfd) = true;
return true;
}
static boolean
m32r_elf_merge_private_bfd_data (ibfd, obfd)
bfd * ibfd;
bfd * obfd;
{
flagword out_flags;
flagword in_flags;
if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour
|| bfd_get_flavour (obfd) != bfd_target_elf_flavour)
return true;
in_flags = elf_elfheader (ibfd)->e_flags;
out_flags = elf_elfheader (obfd)->e_flags;
if (! elf_flags_init (obfd))
{
if (bfd_get_arch_info (ibfd)->the_default)
return true;
elf_flags_init (obfd) = true;
elf_elfheader (obfd)->e_flags = in_flags;
if (bfd_get_arch (obfd) == bfd_get_arch (ibfd)
&& bfd_get_arch_info (obfd)->the_default)
{
return bfd_set_arch_mach (obfd, bfd_get_arch (ibfd), bfd_get_mach (ibfd));
}
return true;
}
if (in_flags == out_flags)
return true;
if ((in_flags & EF_M32R_ARCH) != (out_flags & EF_M32R_ARCH))
{
if ((in_flags & EF_M32R_ARCH) != E_M32R_ARCH)
{
(*_bfd_error_handler)
(_("%s: Instruction set mismatch with previous modules"),
bfd_archive_filename (ibfd));
bfd_set_error (bfd_error_bad_value);
return false;
}
}
return true;
}
static boolean
m32r_elf_print_private_bfd_data (abfd, ptr)
bfd * abfd;
PTR ptr;
{
FILE * file = (FILE *) ptr;
BFD_ASSERT (abfd != NULL && ptr != NULL)
_bfd_elf_print_private_bfd_data (abfd, ptr);
fprintf (file, _("private flags = %lx"), elf_elfheader (abfd)->e_flags);
switch (elf_elfheader (abfd)->e_flags & EF_M32R_ARCH)
{
default:
case E_M32R_ARCH: fprintf (file, _(": m32r instructions")); break;
case E_M32RX_ARCH: fprintf (file, _(": m32rx instructions")); break;
}
fputc ('\n', file);
return true;
}
asection *
m32r_elf_gc_mark_hook (abfd, info, rel, h, sym)
bfd *abfd;
struct bfd_link_info *info ATTRIBUTE_UNUSED;
Elf_Internal_Rela *rel;
struct elf_link_hash_entry *h;
Elf_Internal_Sym *sym;
{
if (h != NULL)
{
switch (ELF32_R_TYPE (rel->r_info))
{
case R_M32R_GNU_VTINHERIT:
case R_M32R_GNU_VTENTRY:
break;
default:
switch (h->root.type)
{
case bfd_link_hash_defined:
case bfd_link_hash_defweak:
return h->root.u.def.section;
case bfd_link_hash_common:
return h->root.u.c.p->section;
default:
break;
}
}
}
else
{
return bfd_section_from_elf_index (abfd, sym->st_shndx);
}
return NULL;
}
static boolean
m32r_elf_gc_sweep_hook (abfd, info, sec, relocs)
bfd *abfd ATTRIBUTE_UNUSED;
struct bfd_link_info *info ATTRIBUTE_UNUSED;
asection *sec ATTRIBUTE_UNUSED;
const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED;
{
return true;
}
static boolean
m32r_elf_check_relocs (abfd, info, sec, relocs)
bfd *abfd;
struct bfd_link_info *info;
asection *sec;
const Elf_Internal_Rela *relocs;
{
Elf_Internal_Shdr *symtab_hdr;
struct elf_link_hash_entry **sym_hashes, **sym_hashes_end;
const Elf_Internal_Rela *rel;
const Elf_Internal_Rela *rel_end;
if (info->relocateable)
return true;
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
sym_hashes = elf_sym_hashes (abfd);
sym_hashes_end = sym_hashes + symtab_hdr->sh_size/sizeof (Elf32_External_Sym);
if (!elf_bad_symtab (abfd))
sym_hashes_end -= symtab_hdr->sh_info;
rel_end = relocs + sec->reloc_count;
for (rel = relocs; rel < rel_end; rel++)
{
struct elf_link_hash_entry *h;
unsigned long r_symndx;
r_symndx = ELF32_R_SYM (rel->r_info);
if (r_symndx < symtab_hdr->sh_info)
h = NULL;
else
h = sym_hashes[r_symndx - symtab_hdr->sh_info];
switch (ELF32_R_TYPE (rel->r_info))
{
case R_M32R_GNU_VTINHERIT:
if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
return false;
break;
case R_M32R_GNU_VTENTRY:
if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_offset))
return false;
break;
}
}
return true;
}
#define ELF_ARCH bfd_arch_m32r
#define ELF_MACHINE_CODE EM_M32R
#define ELF_MACHINE_ALT1 EM_CYGNUS_M32R
#define ELF_MAXPAGESIZE 0x1
#define TARGET_BIG_SYM bfd_elf32_m32r_vec
#define TARGET_BIG_NAME "elf32-m32r"
#define elf_info_to_howto 0
#define elf_info_to_howto_rel m32r_info_to_howto_rel
#define elf_backend_section_from_bfd_section _bfd_m32r_elf_section_from_bfd_section
#define elf_backend_symbol_processing _bfd_m32r_elf_symbol_processing
#define elf_backend_add_symbol_hook m32r_elf_add_symbol_hook
#define elf_backend_relocate_section m32r_elf_relocate_section
#define elf_backend_gc_mark_hook m32r_elf_gc_mark_hook
#define elf_backend_gc_sweep_hook m32r_elf_gc_sweep_hook
#define elf_backend_check_relocs m32r_elf_check_relocs
#define elf_backend_can_gc_sections 1
#if 0
#define bfd_elf32_bfd_relax_section m32r_elf_relax_section
#define bfd_elf32_bfd_get_relocated_section_contents \
m32r_elf_get_relocated_section_contents
#endif
#define elf_backend_object_p m32r_elf_object_p
#define elf_backend_final_write_processing m32r_elf_final_write_processing
#define bfd_elf32_bfd_merge_private_bfd_data m32r_elf_merge_private_bfd_data
#define bfd_elf32_bfd_set_private_flags m32r_elf_set_private_flags
#define bfd_elf32_bfd_print_private_bfd_data m32r_elf_print_private_bfd_data
#include "elf32-target.h"