aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf-m10300.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2003-08-20 08:37:19 +0000
committerNick Clifton <nickc@redhat.com>2003-08-20 08:37:19 +0000
commit560e09e9cc912370081be5cccb8d3179a78928b2 (patch)
tree9191f0c21af30761875fd1741d540eacdea7b88f /bfd/elf-m10300.c
parent04d1ab347d16d701221fa1b49185d096e3158138 (diff)
downloadgdb-560e09e9cc912370081be5cccb8d3179a78928b2.zip
gdb-560e09e9cc912370081be5cccb8d3179a78928b2.tar.gz
gdb-560e09e9cc912370081be5cccb8d3179a78928b2.tar.bz2
Better handking for unresolved symbols
Diffstat (limited to 'bfd/elf-m10300.c')
-rw-r--r--bfd/elf-m10300.c94
1 files changed, 37 insertions, 57 deletions
diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c
index 212fde7..dc25c38 100644
--- a/bfd/elf-m10300.c
+++ b/bfd/elf-m10300.c
@@ -1158,9 +1158,8 @@ mn10300_elf_final_link_relocate (howto, input_bfd, output_bfd,
}
bfd_elf32_swap_reloca_out (output_bfd, &outrel,
- (((Elf32_External_Rela *)
- sreloc->contents)
- + sreloc->reloc_count));
+ (bfd_byte *) (((Elf32_External_Rela *) sreloc->contents)
+ + sreloc->reloc_count));
++sreloc->reloc_count;
/* If this reloc is against an external symbol, we do
@@ -1295,9 +1294,9 @@ mn10300_elf_final_link_relocate (howto, input_bfd, output_bfd,
}
bfd_elf32_swap_reloca_out (output_bfd, &outrel,
- (((Elf32_External_Rela *)
- sreloc->contents)
- + sreloc->reloc_count));
+ (bfd_byte *) (((Elf32_External_Rela *)
+ sreloc->contents)
+ + sreloc->reloc_count));
++sreloc->reloc_count;
return bfd_reloc_ok;
@@ -1480,9 +1479,9 @@ mn10300_elf_final_link_relocate (howto, input_bfd, output_bfd,
outrel.r_info = ELF32_R_INFO (0, R_MN10300_RELATIVE);
outrel.r_addend = value;
bfd_elf32_swap_reloca_out (output_bfd, &outrel,
- (((Elf32_External_Rela *)
- srelgot->contents)
- + srelgot->reloc_count));
+ (bfd_byte *) (((Elf32_External_Rela *)
+ srelgot->contents)
+ + srelgot->reloc_count));
++ srelgot->reloc_count;
}
@@ -1579,15 +1578,20 @@ mn10300_elf_relocate_section (output_bfd, info, input_bfd, input_section,
}
else
{
- h = sym_hashes[r_symndx - symtab_hdr->sh_info];
- while (h->root.root.type == bfd_link_hash_indirect
- || h->root.root.type == bfd_link_hash_warning)
- h = (struct elf32_mn10300_link_hash_entry *) h->root.root.u.i.link;
- if (h->root.root.type == bfd_link_hash_defined
+ bfd_boolean unresolved_reloc;
+ bfd_boolean warned;
+ struct elf_link_hash_entry *hh;
+
+ RELOC_FOR_GLOBAL_SYMBOL (hh, (struct elf_link_hash_entry *) sym_hashes,
+ r_symndx, symtab_hdr, relocation,
+ sec, unresolved_reloc, info,
+ warned);
+
+ h = (struct elf32_mn10300_link_hash_entry *) hh;
+
+ if ((h->root.root.type == bfd_link_hash_defined
|| h->root.root.type == bfd_link_hash_defweak)
- {
- sec = h->root.root.u.def.section;
- if ( r_type == R_MN10300_GOTPC32
+ && ( r_type == R_MN10300_GOTPC32
|| r_type == R_MN10300_GOTPC16
|| (( r_type == R_MN10300_PLT32
|| r_type == R_MN10300_PLT16)
@@ -1615,41 +1619,17 @@ mn10300_elf_relocate_section (output_bfd, info, input_bfd, input_section,
do anything with them here. */
|| ((input_section->flags & SEC_DEBUGGING) != 0
&& (h->root.elf_link_hash_flags
- & ELF_LINK_HASH_DEF_DYNAMIC) != 0))))
- {
- /* In these cases, we don't need the relocation
- value. We check specially because in some
- obscure cases sec->output_section will be NULL. */
- relocation = 0;
- }
- else if (sec->output_section == NULL)
- {
- (*_bfd_error_handler)
- (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"),
- bfd_get_filename (input_bfd), h->root.root.root.string,
- bfd_get_section_name (input_bfd, input_section));
- relocation = 0;
- }
- else
- relocation = (h->root.root.u.def.value
- + sec->output_section->vma
- + sec->output_offset);
- }
- else if (h->root.root.type == bfd_link_hash_undefweak)
- relocation = 0;
- else if (info->shared && !info->symbolic && !info->no_undefined
- && ELF_ST_VISIBILITY (h->root.other) == STV_DEFAULT)
+ & ELF_LINK_HASH_DEF_DYNAMIC) != 0)))))
+ /* In these cases, we don't need the relocation
+ value. We check specially because in some
+ obscure cases sec->output_section will be NULL. */
relocation = 0;
- else
- {
- if (! ((*info->callbacks->undefined_symbol)
- (info, h->root.root.root.string, input_bfd,
- input_section, rel->r_offset,
- (!info->shared || info->no_undefined
- || ELF_ST_VISIBILITY (h->root.other)))))
- return FALSE;
- relocation = 0;
- }
+
+ else if (unresolved_reloc)
+ (*_bfd_error_handler)
+ (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"),
+ bfd_get_filename (input_bfd), h->root.root.root.string,
+ bfd_get_section_name (input_bfd, input_section));
}
r = mn10300_elf_final_link_relocate (howto, input_bfd, output_bfd,
@@ -4626,8 +4606,8 @@ _bfd_mn10300_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
rel.r_info = ELF32_R_INFO (h->dynindx, R_MN10300_JMP_SLOT);
rel.r_addend = 0;
bfd_elf32_swap_reloca_out (output_bfd, &rel,
- ((Elf32_External_Rela *) srel->contents
- + plt_index));
+ (bfd_byte *) ((Elf32_External_Rela *) srel->contents
+ + plt_index));
if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
/* Mark the symbol as undefined, rather than as defined in
@@ -4673,8 +4653,8 @@ _bfd_mn10300_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
}
bfd_elf32_swap_reloca_out (output_bfd, &rel,
- ((Elf32_External_Rela *) srel->contents
- + srel->reloc_count));
+ (bfd_byte *) ((Elf32_External_Rela *) srel->contents
+ + srel->reloc_count));
++ srel->reloc_count;
}
@@ -4698,8 +4678,8 @@ _bfd_mn10300_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
rel.r_info = ELF32_R_INFO (h->dynindx, R_MN10300_COPY);
rel.r_addend = 0;
bfd_elf32_swap_reloca_out (output_bfd, &rel,
- ((Elf32_External_Rela *) s->contents
- + s->reloc_count));
+ (bfd_byte *) ((Elf32_External_Rela *) s->contents
+ + s->reloc_count));
++ s->reloc_count;
}