static boolean elf32_m68k_set_private_flags
PARAMS ((bfd *, flagword));
-static boolean elf32_m68k_copy_private_bfd_data
- PARAMS ((bfd *, bfd *));
static boolean elf32_m68k_merge_private_bfd_data
PARAMS ((bfd *, bfd *));
static boolean elf32_m68k_print_private_bfd_data
return true;
}
-/* Copy m68k-specific data from one module to another */
-static boolean
-elf32_m68k_copy_private_bfd_data (ibfd, obfd)
- bfd *ibfd;
- bfd *obfd;
-{
- 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;
-
- elf_elfheader (obfd)->e_flags = in_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
/* Ignore init flag - it may not be set, despite the flags field containing valid data. */
/* xgettext:c-format */
- fprintf (file, _ ("private flags = %lx:"), elf_elfheader (abfd)->e_flags);
+ fprintf (file, _("private flags = %lx:"), elf_elfheader (abfd)->e_flags);
if (elf_elfheader (abfd)->e_flags & EF_CPU32)
- fprintf (file, _ (" [cpu32]"));
+ fprintf (file, _(" [cpu32]"));
+
+ if (elf_elfheader (abfd)->e_flags & EF_M68000)
+ fprintf (file, _ (" [m68000]"));
fputc ('\n', file);
}
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;
char **errmsg;
{
Elf_Internal_Shdr *symtab_hdr;
+ Elf_Internal_Shdr *shndx_hdr;
Elf32_External_Sym *extsyms;
Elf32_External_Sym *free_extsyms = NULL;
+ Elf_External_Sym_Shndx *shndx_buf = NULL;
Elf_Internal_Rela *internal_relocs;
Elf_Internal_Rela *free_relocs = NULL;
Elf_Internal_Rela *irel, *irelend;
else
{
/* Go get them off disk. */
+ amt = symtab_hdr->sh_info * sizeof (Elf32_External_Sym);
if (info->keep_memory)
- extsyms = (Elf32_External_Sym *) bfd_alloc (abfd, symtab_hdr->sh_size);
+ extsyms = (Elf32_External_Sym *) bfd_alloc (abfd, amt);
else
- extsyms = (Elf32_External_Sym *) bfd_malloc (symtab_hdr->sh_size);
+ extsyms = (Elf32_External_Sym *) bfd_malloc (amt);
if (extsyms == NULL)
goto error_return;
if (! info->keep_memory)
free_extsyms = extsyms;
if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_bread (extsyms, symtab_hdr->sh_size, abfd)
- != symtab_hdr->sh_size))
+ || bfd_bread (extsyms, amt, abfd) != amt)
goto error_return;
if (info->keep_memory)
symtab_hdr->contents = (unsigned char *) extsyms;
}
+ shndx_hdr = &elf_tdata (abfd)->symtab_shndx_hdr;
+ if (shndx_hdr->sh_size != 0)
+ {
+ amt = symtab_hdr->sh_info * sizeof (Elf_External_Sym_Shndx);
+ shndx_buf = (Elf_External_Sym_Shndx *) bfd_malloc (amt);
+ if (shndx_buf == NULL)
+ goto error_return;
+ if (bfd_seek (abfd, shndx_hdr->sh_offset, SEEK_SET) != 0
+ || bfd_bread ((PTR) shndx_buf, amt, abfd) != amt)
+ goto error_return;
+ }
+
/* Get a copy of the native relocations. */
internal_relocs = (_bfd_elf32_link_read_relocs
(abfd, datasec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
/* Get the target section referred to by the reloc. */
if (ELF32_R_SYM (irel->r_info) < symtab_hdr->sh_info)
{
+ Elf32_External_Sym *esym;
+ Elf_External_Sym_Shndx *shndx;
Elf_Internal_Sym isym;
/* A local symbol. */
- bfd_elf32_swap_symbol_in (abfd,
- extsyms + ELF32_R_SYM (irel->r_info),
- &isym);
+ esym = extsyms + ELF32_R_SYM (irel->r_info);
+ shndx = shndx_buf + (shndx_buf ? ELF32_R_SYM (irel->r_info) : 0);
+ bfd_elf32_swap_symbol_in (abfd, esym, shndx, &isym);
targetsec = bfd_section_from_elf_index (abfd, isym.st_shndx);
}
strncpy (p + 4, targetsec->output_section->name, 8);
}
+ if (shndx_buf != NULL)
+ free (shndx_buf);
if (free_extsyms != NULL)
free (free_extsyms);
if (free_relocs != NULL)
return true;
error_return:
+ if (shndx_buf != NULL)
+ free (shndx_buf);
if (free_extsyms != NULL)
free (free_extsyms);
if (free_relocs != NULL)
elf_m68k_finish_dynamic_sections
#define elf_backend_gc_mark_hook elf_m68k_gc_mark_hook
#define elf_backend_gc_sweep_hook elf_m68k_gc_sweep_hook
-#define bfd_elf32_bfd_copy_private_bfd_data \
- elf32_m68k_copy_private_bfd_data
#define bfd_elf32_bfd_merge_private_bfd_data \
elf32_m68k_merge_private_bfd_data
#define bfd_elf32_bfd_set_private_flags \