/* V850-specific support for 32-bit ELF
- Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+ Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
static void v850_elf_symbol_processing
PARAMS ((bfd *, asymbol *));
static bfd_boolean v850_elf_add_symbol_hook
- PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
+ PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Sym *,
const char **, flagword *, asection **, bfd_vma *));
static bfd_boolean v850_elf_link_output_symbol_hook
- PARAMS ((bfd *, struct bfd_link_info *, const char *,
- Elf_Internal_Sym *, asection *));
+ PARAMS ((struct bfd_link_info *, const char *, Elf_Internal_Sym *,
+ asection *, struct elf_link_hash_entry *));
static bfd_boolean v850_elf_section_from_shdr
PARAMS ((bfd *, Elf_Internal_Shdr *, const char *));
static bfd_boolean v850_elf_gc_sweep_hook
return TRUE;
#ifdef DEBUG
- fprintf (stderr, "v850_elf_check_relocs called for section %s in %s\n",
- bfd_get_section_name (abfd, sec),
- bfd_archive_filename (abfd));
+ _bfd_error_handler ("v850_elf_check_relocs called for section %A in %B",
+ sec, abfd);
#endif
dynobj = elf_hash_table (info)->dynobj;
/* This relocation describes the C++ object vtable hierarchy.
Reconstruct it for later use during GC. */
case R_V850_GNU_VTINHERIT:
- if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
+ if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
return FALSE;
break;
/* This relocation describes which C++ vtable entries
are actually used. Record for later use during GC. */
case R_V850_GNU_VTENTRY:
- if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+ if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
return FALSE;
break;
/* Extract the address. */
addr = match->address;
- /* Remeber if this entry has already been used before. */
+ /* Remember if this entry has already been used before. */
if (already_found)
* already_found = match->found;
}
/* FIXME: The code here probably ought to be removed and the code in reloc.c
- allowed to do its stuff instead. At least for most of the relocs, anwyay. */
+ allowed to do its stuff instead. At least for most of the relocs, anyway. */
static bfd_reloc_status_type
v850_elf_perform_relocation (abfd, r_type, addend, address)
/* We handle final linking of some relocs ourselves. */
/* Is the address of the relocation really within the section? */
- if (reloc->address > isection->_cooked_size)
+ if (reloc->address > bfd_get_section_limit (abfd, isection))
return bfd_reloc_outofrange;
- /* Work out which section the relocation is targetted at and the
+ /* Work out which section the relocation is targeted at and the
initial relocation command value. */
if (reloc->howto->pc_relative)
}
else
{
- h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+ bfd_boolean unresolved_reloc, warned;
- 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;
-
- if (h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- {
- sec = h->root.u.def.section;
- relocation = (h->root.u.def.value
- + sec->output_section->vma
- + sec->output_offset);
-#if 0
- fprintf (stderr, "defined: sec: %s, name: %s, value: %x + %x + %x gives: %x\n",
- sec->name, h->root.root.string, h->root.u.def.value, sec->output_section->vma, sec->output_offset, relocation);
-#endif
- }
- else if (h->root.type == bfd_link_hash_undefweak)
- {
-#if 0
- fprintf (stderr, "undefined: sec: %s, name: %s\n",
- sec->name, h->root.root.string);
-#endif
- relocation = 0;
- }
- else
- {
- if (! ((*info->callbacks->undefined_symbol)
- (info, h->root.root.string, input_bfd,
- input_section, rel->r_offset, TRUE)))
- return FALSE;
-#if 0
- fprintf (stderr, "unknown: name: %s\n", h->root.root.string);
-#endif
- relocation = 0;
- }
+ RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
+ r_symndx, symtab_hdr, sym_hashes,
+ h, sec, relocation,
+ unresolved_reloc, warned);
}
/* FIXME: We should use the addend, but the COFF relocations don't. */
{
case bfd_reloc_overflow:
if (! ((*info->callbacks->reloc_overflow)
- (info, name, howto->name, (bfd_vma) 0,
- input_bfd, input_section, rel->r_offset)))
+ (info, (h ? &h->root : NULL), name, howto->name,
+ (bfd_vma) 0, input_bfd, input_section,
+ rel->r_offset)))
return FALSE;
break;
return TRUE;
}
- _bfd_error_handler (_("%s: Architecture mismatch with previous modules"),
- bfd_archive_filename (ibfd));
+ _bfd_error_handler (_("%B: Architecture mismatch with previous modules"),
+ ibfd);
}
return TRUE;
v850_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
bfd *abfd;
struct bfd_link_info *info ATTRIBUTE_UNUSED;
- const Elf_Internal_Sym *sym;
+ Elf_Internal_Sym *sym;
const char **namep ATTRIBUTE_UNUSED;
flagword *flagsp ATTRIBUTE_UNUSED;
asection **secp;
}
static bfd_boolean
-v850_elf_link_output_symbol_hook (abfd, info, name, sym, input_sec)
- bfd *abfd ATTRIBUTE_UNUSED;
+v850_elf_link_output_symbol_hook (info, name, sym, input_sec, h)
struct bfd_link_info *info ATTRIBUTE_UNUSED;
const char *name ATTRIBUTE_UNUSED;
Elf_Internal_Sym *sym;
asection *input_sec;
+ struct elf_link_hash_entry *h ATTRIBUTE_UNUSED;
{
/* If we see a common symbol, which implies a relocatable link, then
if a symbol was in a special common section in an input file, mark
|| sec->reloc_count == 0)
return TRUE;
- /* If this is the first time we have been called
- for this section, initialize the cooked size. */
- if (sec->_cooked_size == 0)
- sec->_cooked_size = sec->_raw_size;
-
symtab_hdr = & elf_tdata (abfd)->symtab_hdr;
internal_relocs = (_bfd_elf_link_read_relocs
irelend = internal_relocs + sec->reloc_count;
- while (addr < sec->_cooked_size)
+ while (addr < sec->size)
{
- toaddr = sec->_cooked_size;
+ toaddr = sec->size;
for (irel = internal_relocs; irel < irelend; irel ++)
if (ELF32_R_TYPE (irel->r_info) == (int) R_V850_ALIGN
contents = elf_section_data (sec)->this_hdr.contents;
else
{
- contents = (bfd_byte *) bfd_malloc (sec->_raw_size);
- if (contents == NULL)
- goto error_return;
-
- if (! bfd_get_section_contents (abfd, sec, contents,
- (file_ptr) 0, sec->_raw_size))
+ if (!bfd_malloc_and_get_section (abfd, sec, &contents))
goto error_return;
}
}
if (ELF32_R_TYPE (irel->r_info) == (int) R_V850_LONGCALL)
{
/* Check code for -mlong-calls output. */
- if (laddr + 16 <= (bfd_vma) sec->_raw_size)
+ if (laddr + 16 <= (bfd_vma) sec->size)
{
insn[0] = bfd_get_16 (abfd, contents + laddr);
insn[1] = bfd_get_16 (abfd, contents + laddr + 4);
else if (ELF32_R_TYPE (irel->r_info) == (int) R_V850_LONGJUMP)
{
/* Check code for -mlong-jumps output. */
- if (laddr + 10 <= (bfd_vma) sec->_raw_size)
+ if (laddr + 10 <= (bfd_vma) sec->size)
{
insn[0] = bfd_get_16 (abfd, contents + laddr);
insn[1] = bfd_get_16 (abfd, contents + laddr + 4);
#ifdef DEBUG_RELAX
fprintf (stderr, "relax pad %d shorten %d -> %d\n",
align_pad_size,
- sec->_cooked_size,
- sec->_cooked_size - align_pad_size);
+ sec->size,
+ sec->size - align_pad_size);
#endif
- sec->_cooked_size -= align_pad_size;
+ sec->size -= align_pad_size;
}
finish: