aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-i386.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1995-07-03 17:05:56 +0000
committerIan Lance Taylor <ian@airs.com>1995-07-03 17:05:56 +0000
commit30dc85f1b88df0735816442a23fee5bc601c64a0 (patch)
tree013feb46e2981f6bd402a95f4ac2df48ddc3f9f0 /bfd/elf32-i386.c
parentd7ace3071e7139d242713cf0bcee19c8c283157a (diff)
downloadgdb-30dc85f1b88df0735816442a23fee5bc601c64a0.zip
gdb-30dc85f1b88df0735816442a23fee5bc601c64a0.tar.gz
gdb-30dc85f1b88df0735816442a23fee5bc601c64a0.tar.bz2
* elf32-i386.c (elf_i386_adjust_dynamic_symbol): Correct
BFD_ASSERT to handle __start_SECNAME symbols automatically defined by the linker. * elf32-sparc.c (elf32_sparc_adjust_dynamic_symbol): Likewise. * elf32-m68k.c (elf_m68k_adjust_dynamic_symbol): Likewise.
Diffstat (limited to 'bfd/elf32-i386.c')
-rw-r--r--bfd/elf32-i386.c76
1 files changed, 46 insertions, 30 deletions
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 844138f..3d56995 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -1,5 +1,5 @@
/* Intel 80386/80486-specific support for 32-bit ELF
- Copyright 1993 Free Software Foundation, Inc.
+ Copyright 1993, 1994, 1995 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
@@ -23,7 +23,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "libbfd.h"
#include "libelf.h"
-static CONST struct reloc_howto_struct *elf_i386_reloc_type_lookup
+static reloc_howto_type *elf_i386_reloc_type_lookup
PARAMS ((bfd *, bfd_reloc_code_real_type));
static void elf_i386_info_to_howto
PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
@@ -105,7 +105,7 @@ static reloc_howto_type elf_howto_table[]=
#define TRACE(str)
#endif
-static CONST struct reloc_howto_struct *
+static reloc_howto_type *
elf_i386_reloc_type_lookup (abfd, code)
bfd *abfd;
bfd_reloc_code_real_type code;
@@ -607,20 +607,22 @@ elf_i386_adjust_dynamic_symbol (info, h)
dynobj = elf_hash_table (info)->dynobj;
/* Make sure we know what is going on here. */
- BFD_ASSERT (dynobj != NULL
- && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)
- || ((h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_DYNAMIC) != 0
- && (h->elf_link_hash_flags
- & ELF_LINK_HASH_REF_REGULAR) != 0
- && (h->elf_link_hash_flags
- & ELF_LINK_HASH_DEF_REGULAR) == 0
- && (elf_elfheader (h->root.u.def.section->owner)->e_type
- == ET_DYN)
- && h->root.type == bfd_link_hash_defined
- && (bfd_get_flavour (h->root.u.def.section->owner)
- == bfd_target_elf_flavour)
- && h->root.u.def.section->output_section == NULL)));
+ BFD_ASSERT (dynobj != NULL);
+ BFD_ASSERT ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)
+ || ((h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_DYNAMIC) != 0
+ && (h->elf_link_hash_flags
+ & ELF_LINK_HASH_REF_REGULAR) != 0
+ && (h->elf_link_hash_flags
+ & ELF_LINK_HASH_DEF_REGULAR) == 0
+ && (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ && (h->root.u.def.section->owner == NULL
+ || ((elf_elfheader (h->root.u.def.section->owner)->e_type
+ == ET_DYN)
+ && (bfd_get_flavour (h->root.u.def.section->owner)
+ == bfd_target_elf_flavour)
+ && h->root.u.def.section->output_section == NULL))));
/* If this is a function, put it in the procedure linkage table. We
will fill in the contents of the procedure linkage table later,
@@ -685,7 +687,8 @@ elf_i386_adjust_dynamic_symbol (info, h)
real definition first, and we can just use the same value. */
if (h->weakdef != NULL)
{
- BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined);
+ BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
+ || h->weakdef->root.type == bfd_link_hash_defweak);
h->root.u.def.section = h->weakdef->root.u.def.section;
h->root.u.def.value = h->weakdef->root.u.def.value;
return true;
@@ -980,6 +983,7 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section,
asection *sec;
bfd_vma relocation;
bfd_reloc_status_type r;
+ char *shared_name;
r_type = ELF32_R_TYPE (rel->r_info);
if (r_type < 0 || r_type >= (int) R_386_max)
@@ -1018,6 +1022,8 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section,
h = NULL;
sym = NULL;
sec = NULL;
+ shared_name = NULL;
+
if (r_symndx < symtab_hdr->sh_info)
{
sym = local_syms + r_symndx;
@@ -1029,7 +1035,8 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section,
else
{
h = sym_hashes[r_symndx - symtab_hdr->sh_info];
- if (h->root.type == bfd_link_hash_defined)
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
{
sec = h->root.u.def.section;
if (r_type == R_386_GOTPC
@@ -1052,7 +1059,7 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section,
+ sec->output_section->vma
+ sec->output_offset);
}
- else if (h->root.type == bfd_link_hash_weak)
+ else if (h->root.type == bfd_link_hash_undefweak)
relocation = 0;
else if (info->shared)
relocation = 0;
@@ -1225,21 +1232,19 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section,
if (sreloc == NULL)
{
- const char *name;
-
- name = (elf_string_from_elf_section
+ shared_name = (elf_string_from_elf_section
(input_bfd,
elf_elfheader (input_bfd)->e_shstrndx,
elf_section_data (input_section)->rel_hdr.sh_name));
- if (name == NULL)
+ if (shared_name == NULL)
return false;
- BFD_ASSERT (strncmp (name, ".rel", 4) == 0
+ BFD_ASSERT (strncmp (shared_name, ".rel", 4) == 0
&& strcmp (bfd_get_section_name (input_bfd,
input_section),
- name + 4) == 0);
+ shared_name + 4) == 0);
- sreloc = bfd_get_section_by_name (dynobj, name);
+ sreloc = bfd_get_section_by_name (dynobj, shared_name);
BFD_ASSERT (sreloc != NULL);
}
@@ -1248,8 +1253,18 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section,
+ input_section->output_offset);
if (r_type == R_386_PC32)
{
- BFD_ASSERT (h != NULL && h->dynindx != -1);
- outrel.r_info = ELF32_R_INFO (h->dynindx, R_386_PC32);
+ if (!h)
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, shared_name ? shared_name : sec->name, input_bfd,
+ input_section, rel->r_offset)))
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
+ else {
+ BFD_ASSERT (h->dynindx != -1);
+ outrel.r_info = ELF32_R_INFO (h->dynindx, R_386_PC32);
+ }
}
else
{
@@ -1450,7 +1465,8 @@ elf_i386_finish_dynamic_symbol (output_bfd, info, h, sym)
/* This symbol needs a copy reloc. Set it up. */
BFD_ASSERT (h->dynindx != -1
- && h->root.type == bfd_link_hash_defined);
+ && (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak));
s = bfd_get_section_by_name (h->root.u.def.section->owner,
".rel.bss");