static void m32r_info_to_howto_rel
PARAMS ((bfd *, arelent *, Elf32_Internal_Rel *));
boolean _bfd_m32r_elf_section_from_bfd_section
- PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *, int *));
+ PARAMS ((bfd *, asection *, int *));
void _bfd_m32r_elf_symbol_processing
PARAMS ((bfd *, asymbol *));
static boolean m32r_elf_add_symbol_hook
PARAMS ((bfd *, boolean));
static boolean m32r_elf_set_private_flags
PARAMS ((bfd *, flagword));
-static boolean m32r_elf_copy_private_bfd_data
- PARAMS ((bfd *, bfd *));
static boolean m32r_elf_merge_private_bfd_data
PARAMS ((bfd *, bfd *));
static boolean m32r_elf_print_private_bfd_data
return bfd_reloc_ok;
}
- /* Now do the the reloc in the usual way.
+ /* Now do the reloc in the usual way.
??? It would be nice to call bfd_elf_generic_reloc here,
but we have partial_inplace == TRUE. bfd_elf_generic_reloc will
pass the handling back to bfd_install_relocation which will install
index. */
boolean
-_bfd_m32r_elf_section_from_bfd_section (abfd, hdr, sec, retval)
+_bfd_m32r_elf_section_from_bfd_section (abfd, sec, retval)
bfd *abfd ATTRIBUTE_UNUSED;
- Elf32_Internal_Shdr *hdr ATTRIBUTE_UNUSED;
asection *sec;
int *retval;
{
{
if (! info->relocateable
&& (*namep)[0] == '_' && (*namep)[1] == 'S'
- && strcmp (*namep, "_SDA_BASE_") == 0)
+ && strcmp (*namep, "_SDA_BASE_") == 0
+ && info->hash->creator->flavour == bfd_target_elf_flavour)
{
/* This is simpler than using _bfd_elf_create_linker_section
(our needs are simpler than ppc's needs). Also
/* Assume success. */
boolean ret = true;
+#ifndef USE_REL
+ if (info->relocateable)
+ return true;
+#endif
+
rel = relocs;
relend = relocs + input_section->reloc_count;
for (; rel < relend; rel++)
if (r_type < 0 || r_type >= (int) R_M32R_max)
{
(*_bfd_error_handler) (_("%s: unknown relocation type %d"),
- bfd_get_filename (input_bfd),
+ bfd_archive_filename (input_bfd),
(int) r_type);
bfd_set_error (bfd_error_bad_value);
ret = false;
howto = m32r_elf_howto_table + r_type;
r_symndx = ELF32_R_SYM (rel->r_info);
+#ifdef USE_REL
if (info->relocateable)
{
/* This is a relocateable link. We don't have to change
sec = local_sections[r_symndx];
addend += sec->output_offset + sym->st_value;
-#ifndef USE_REL
- /* This can't be done for USE_REL because it doesn't mean anything
- and elf_link_input_bfd asserts this stays zero. */
- rel->r_addend = addend;
-#endif
-#ifndef USE_REL
- /* Addends are stored with relocs. We're done. */
- continue;
-#else /* USE_REL */
/* If partial_inplace, we need to store any additional addend
back in the section. */
if (! howto->partial_inplace)
r = _bfd_relocate_contents (howto, input_bfd,
addend, contents + offset);
}
-#endif /* USE_REL */
}
else
+#endif /* USE_REL */
{
bfd_vma relocation;
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
+ /* FIXME: This won't handle local relocations against SEC_MERGE
+ symbols. See elf32-i386.c for how to do this. */
relocation = (sec->output_section->vma
+ sec->output_offset
+ sym->st_value);
+#endif
}
else
{
}
else
{
- (*_bfd_error_handler) (_("%s: The target (%s) of an %s relocation is in the wrong section (%s)"),
- bfd_get_filename (input_bfd),
- sym_name,
- m32r_elf_howto_table[(int) r_type].name,
- bfd_get_section_name (abfd, sec));
+ (*_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));
/*bfd_set_error (bfd_error_bad_value); ??? why? */
ret = false;
continue;
if (isymp->st_shndx == SHN_UNDEF)
isec = bfd_und_section_ptr;
- else if (isymp->st_shndx > 0 && isymp->st_shndx < SHN_LORESERVE)
- isec = bfd_section_from_elf_index (input_bfd, isymp->st_shndx);
else if (isymp->st_shndx == SHN_ABS)
isec = bfd_abs_section_ptr;
else if (isymp->st_shndx == SHN_COMMON)
else if (isymp->st_shndx == SHN_M32R_SCOMMON)
isec = &m32r_elf_scom_section;
else
- {
- /* Who knows? */
- isec = NULL;
- }
+ isec = bfd_section_from_elf_index (input_bfd, isymp->st_shndx);
*secpp = isec;
}
return true;
}
-/* Copy backend specific data from one object module to another */
-static boolean
-m32r_elf_copy_private_bfd_data (ibfd, obfd)
- bfd * ibfd;
- bfd * obfd;
-{
- if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour
- || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
- return true;
-
- BFD_ASSERT (!elf_flags_init (obfd)
- || (elf_elfheader (obfd)->e_flags
- == elf_elfheader (ibfd)->e_flags));
-
- elf_gp (obfd) = elf_gp (ibfd);
- elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags;
- elf_flags_init (obfd) = true;
- return true;
-}
-
/* Merge backend specific data from an object file to the output
object file when linking. */
static boolean
{
if ((in_flags & EF_M32R_ARCH) != E_M32R_ARCH)
{
- _bfd_error_handler (_("%s: Instruction set mismatch with previous modules"),
- bfd_get_filename (ibfd));
+ (*_bfd_error_handler)
+ (_("%s: Instruction set mismatch with previous modules"),
+ bfd_archive_filename (ibfd));
bfd_set_error (bfd_error_bad_value);
return false;
}
else
{
- if (!(elf_bad_symtab (abfd)
- && ELF_ST_BIND (sym->st_info) != STB_LOCAL)
- && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE)
- && sym->st_shndx != SHN_COMMON))
- {
- return bfd_section_from_elf_index (abfd, sym->st_shndx);
- }
- }
+ return bfd_section_from_elf_index (abfd, sym->st_shndx);
+ }
return NULL;
}
#define elf_backend_check_relocs m32r_elf_check_relocs
#define elf_backend_can_gc_sections 1
+#ifndef USE_REL
+#define elf_backend_rela_normal 1
+#endif
#if 0 /* not yet */
/* relax support */
#define bfd_elf32_bfd_relax_section m32r_elf_relax_section
#define elf_backend_object_p m32r_elf_object_p
#define elf_backend_final_write_processing m32r_elf_final_write_processing
-#define bfd_elf32_bfd_copy_private_bfd_data m32r_elf_copy_private_bfd_data
#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