aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1995-03-13 20:39:36 +0000
committerIan Lance Taylor <ian@airs.com>1995-03-13 20:39:36 +0000
commitf786a73f081f978bc9e5f8be1e93d0be8a7d967c (patch)
treeba21d1095b80a35b12fbc93cebf1c00a87ca5359
parentc4299ed83a1fd495c1b163aeaf5272bd4cdddedd (diff)
downloadfsf-binutils-gdb-f786a73f081f978bc9e5f8be1e93d0be8a7d967c.zip
fsf-binutils-gdb-f786a73f081f978bc9e5f8be1e93d0be8a7d967c.tar.gz
fsf-binutils-gdb-f786a73f081f978bc9e5f8be1e93d0be8a7d967c.tar.bz2
* elf32-sparc.c (elf32_sparc_size_dynamic_sections): Only write
out PLTRELSZ, PLTREL and JMPREL relocs if there is a .rela.plt section. Solaris 2.4 apparently does not handle empty reloc information correctly.
-rw-r--r--bfd/ChangeLog5
-rw-r--r--bfd/elf32-sparc.c39
2 files changed, 32 insertions, 12 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 5a76b47..d87bd60 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,10 @@
Mon Mar 13 13:48:49 1995 Ian Lance Taylor <ian@cygnus.com>
+ * elf32-sparc.c (elf32_sparc_size_dynamic_sections): Only write
+ out PLTRELSZ, PLTREL and JMPREL relocs if there is a .rela.plt
+ section. Solaris 2.4 apparently does not handle empty reloc
+ information correctly.
+
* archive.c (bsd_write_armap): Cast getuid and getgid results to
long, and print with %ld.
diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c
index fdb19f1..3d007c4 100644
--- a/bfd/elf32-sparc.c
+++ b/bfd/elf32-sparc.c
@@ -1,5 +1,5 @@
/* SPARC-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 *bfd_elf32_bfd_reloc_type_lookup
+static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
PARAMS ((bfd *, bfd_reloc_code_real_type));
static void elf_info_to_howto
PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
@@ -147,7 +147,7 @@ static CONST struct elf_reloc_map sparc_reloc_map[] =
/*{ BFD_RELOC_SPARC_UA32, R_SPARC_UA32 }, not used?? */
};
-static CONST struct reloc_howto_struct *
+static reloc_howto_type *
bfd_elf32_bfd_reloc_type_lookup (abfd, code)
bfd *abfd;
bfd_reloc_code_real_type code;
@@ -581,7 +581,8 @@ elf32_sparc_adjust_dynamic_symbol (info, h)
& 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_defined
+ || h->root.type == bfd_link_hash_defweak)
&& (bfd_get_flavour (h->root.u.def.section->owner)
== bfd_target_elf_flavour)
&& (elf_elfheader (h->root.u.def.section->owner)->e_type
@@ -650,7 +651,8 @@ elf32_sparc_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;
@@ -731,6 +733,7 @@ elf32_sparc_size_dynamic_sections (output_bfd, info)
bfd *dynobj;
asection *s;
boolean reltext;
+ boolean relplt;
dynobj = elf_hash_table (info)->dynobj;
BFD_ASSERT (dynobj != NULL);
@@ -768,6 +771,7 @@ elf32_sparc_size_dynamic_sections (output_bfd, info)
determined the sizes of the various dynamic sections. Allocate
memory for them. */
reltext = false;
+ relplt = false;
for (s = dynobj->sections; s != NULL; s = s->next)
{
const char *name;
@@ -808,6 +812,9 @@ elf32_sparc_size_dynamic_sections (output_bfd, info)
&& (target->flags & SEC_READONLY) != 0)
reltext = true;
+ if (strcmp (name, ".rela.plt") == 0)
+ relplt = true;
+
/* We use the reloc_count field as a counter if we need
to copy relocs into the output file. */
s->reloc_count = 0;
@@ -856,11 +863,18 @@ elf32_sparc_size_dynamic_sections (output_bfd, info)
return false;
}
- if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
- || ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0)
- || ! bfd_elf32_add_dynamic_entry (info, DT_RELA, 0)
+ if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0))
+ return false;
+
+ if (relplt)
+ {
+ if (! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
+ || ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
+ || ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
+ return false;
+ }
+
+ if (! bfd_elf32_add_dynamic_entry (info, DT_RELA, 0)
|| ! bfd_elf32_add_dynamic_entry (info, DT_RELASZ, 0)
|| ! bfd_elf32_add_dynamic_entry (info, DT_RELAENT,
sizeof (Elf32_External_Rela)))
@@ -1004,7 +1018,8 @@ elf32_sparc_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_SPARC_WPLT30
@@ -1043,7 +1058,7 @@ elf32_sparc_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;