aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAndreas Jaeger <aj@suse.de>2001-08-27 08:59:08 +0000
committerAndreas Jaeger <aj@suse.de>2001-08-27 08:59:08 +0000
commit29c2fb7c2b10c63eb2cf01e6c9a3a7c787581fee (patch)
tree89fac937f6f461d1c4d0b225bf2eccb62a6004a3 /bfd
parent081310158f46d3f33b6ea5dde29d10818eaeb0b3 (diff)
downloadgdb-29c2fb7c2b10c63eb2cf01e6c9a3a7c787581fee.zip
gdb-29c2fb7c2b10c63eb2cf01e6c9a3a7c787581fee.tar.gz
gdb-29c2fb7c2b10c63eb2cf01e6c9a3a7c787581fee.tar.bz2
* elf64-s390.c (elf_s390_check_relocs): Set DF_TEXTREL if the
reloc is against read-only section. (elf_s390_size_dynamic_sections): Use DF_TEXTREL flag instead of looking up section names for DT_TEXTREL. (elf_s390_reloc_type_class): New. (elf_backend_reloc_type_class): Define. * elf32-s390.c (elf_s390_check_relocs): Set DF_TEXTREL if the reloc is against read-only section. (elf_s390_size_dynamic_sections): Use DF_TEXTREL flag instead of looking up section names for DT_TEXTREL. (elf_s390_reloc_type_class): New. (elf_backend_reloc_type_class): Define. * elf32-ppc.c (ppc_elf_check_relocs): Set DF_TEXTREL if the reloc is against read-only section. (ppc_elf_size_dynamic_sections): Use DF_TEXTREL flag instead of looking up section names for DT_TEXTREL. (ppc_elf_reloc_type_class): New. (elf_backend_reloc_type_class): Define.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog23
-rw-r--r--bfd/elf32-ppc.c42
-rw-r--r--bfd/elf32-s390.c48
-rw-r--r--bfd/elf64-s390.c49
4 files changed, 97 insertions, 65 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 2d21d8a..07ef1f5 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,26 @@
+2001-08-27 Andreas Jaeger <aj@suse.de>
+
+ * elf64-s390.c (elf_s390_check_relocs): Set DF_TEXTREL if the
+ reloc is against read-only section.
+ (elf_s390_size_dynamic_sections): Use DF_TEXTREL flag instead of
+ looking up section names for DT_TEXTREL.
+ (elf_s390_reloc_type_class): New.
+ (elf_backend_reloc_type_class): Define.
+
+ * elf32-s390.c (elf_s390_check_relocs): Set DF_TEXTREL if the
+ reloc is against read-only section.
+ (elf_s390_size_dynamic_sections): Use DF_TEXTREL flag instead of
+ looking up section names for DT_TEXTREL.
+ (elf_s390_reloc_type_class): New.
+ (elf_backend_reloc_type_class): Define.
+
+ * elf32-ppc.c (ppc_elf_check_relocs): Set DF_TEXTREL if the reloc
+ is against read-only section.
+ (ppc_elf_size_dynamic_sections): Use DF_TEXTREL flag instead of
+ looking up section names for DT_TEXTREL.
+ (ppc_elf_reloc_type_class): New.
+ (elf_backend_reloc_type_class): Define.
+
2001-08-26 Andreas Jaeger <aj@suse.de>
* elf32-cris.c (cris_elf_check_relocs): Set DF_TEXTREL if the
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index 413a769..cefe8ca 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -108,6 +108,7 @@ static boolean ppc_elf_finish_dynamic_symbol PARAMS ((bfd *,
Elf_Internal_Sym *));
static boolean ppc_elf_finish_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *));
+static enum elf_reloc_type_class ppc_elf_reloc_type_class PARAMS ((int));
#define BRANCH_PREDICT_BIT 0x200000 /* branch prediction bit for branch taken relocs */
#define RA_REGISTER_MASK 0x001f0000 /* mask to set RA in memory instructions */
@@ -1878,14 +1879,13 @@ ppc_elf_adjust_dynamic_symbol (info, h)
static boolean
ppc_elf_size_dynamic_sections (output_bfd, info)
- bfd *output_bfd;
+ bfd *output_bfd ATTRIBUTE_UNUSED;
struct bfd_link_info *info;
{
bfd *dynobj;
asection *s;
boolean plt;
boolean relocs;
- boolean reltext;
#ifdef DEBUG
fprintf (stderr, "ppc_elf_size_dynamic_sections called\n");
@@ -1930,7 +1930,6 @@ ppc_elf_size_dynamic_sections (output_bfd, info)
memory for them. */
plt = false;
relocs = false;
- reltext = false;
for (s = dynobj->sections; s != NULL; s = s->next)
{
const char *name;
@@ -1976,22 +1975,9 @@ ppc_elf_size_dynamic_sections (output_bfd, info)
}
else
{
- asection *target;
- const char *outname;
-
/* Remember whether there are any relocation sections. */
relocs = true;
- /* If this relocation section applies to a read only
- section, then we probably need a DT_TEXTREL entry. */
- outname = bfd_get_section_name (output_bfd,
- s->output_section);
- target = bfd_get_section_by_name (output_bfd, outname + 5);
- if (target != NULL
- && (target->flags & SEC_READONLY) != 0
- && (target->flags & SEC_ALLOC) != 0)
- reltext = true;
-
/* We use the reloc_count field as a counter if we need
to copy relocs into the output file. */
s->reloc_count = 0;
@@ -2048,7 +2034,7 @@ ppc_elf_size_dynamic_sections (output_bfd, info)
return false;
}
- if (reltext)
+ if ((info->flags & DF_TEXTREL) != 0)
{
if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
return false;
@@ -2433,6 +2419,8 @@ ppc_elf_check_relocs (abfd, info, sec, relocs)
|| ! bfd_set_section_alignment (dynobj, sreloc, 2))
return false;
}
+ if (sec->flags & SEC_READONLY)
+ info->flags |= DF_TEXTREL;
}
sreloc->_raw_size += sizeof (Elf32_External_Rela);
@@ -3712,6 +3700,25 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
return ret;
}
+
+static enum elf_reloc_type_class
+ppc_elf_reloc_type_class (type)
+ int type;
+{
+ switch (type)
+ {
+ case R_PPC_RELATIVE:
+ return reloc_class_relative;
+ case R_PPC_REL24:
+ case R_PPC_ADDR24:
+ case R_PPC_JMP_SLOT:
+ return reloc_class_plt;
+ case R_PPC_COPY:
+ return reloc_class_copy;
+ default:
+ return reloc_class_normal;
+ }
+}
#define TARGET_LITTLE_SYM bfd_elf32_powerpcle_vec
#define TARGET_LITTLE_NAME "elf32-powerpcle"
@@ -3757,5 +3764,6 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
#define elf_backend_fake_sections ppc_elf_fake_sections
#define elf_backend_additional_program_headers ppc_elf_additional_program_headers
#define elf_backend_modify_segment_map ppc_elf_modify_segment_map
+#define elf_backend_reloc_type_class ppc_elf_reloc_type_class
#include "elf32-target.h"
diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c
index 6a472dd..fad7a8a 100644
--- a/bfd/elf32-s390.c
+++ b/bfd/elf32-s390.c
@@ -56,6 +56,7 @@ static boolean elf_s390_finish_dynamic_symbol
static boolean elf_s390_finish_dynamic_sections
PARAMS ((bfd *, struct bfd_link_info *));
static boolean elf_s390_object_p PARAMS ((bfd *));
+static enum elf_reloc_type_class elf_s390_reloc_type_class PARAMS ((int));
#define USE_RELA 1 /* We want RELA relocations, not REL. */
@@ -712,6 +713,8 @@ elf_s390_check_relocs (abfd, info, sec, relocs)
|| ! bfd_set_section_alignment (dynobj, sreloc, 2))
return false;
}
+ if (sec->flags & SEC_READONLY)
+ info->flags |= DF_TEXTREL;
}
sreloc->_raw_size += sizeof (Elf32_External_Rela);
@@ -1089,12 +1092,11 @@ elf_s390_adjust_dynamic_symbol (info, h)
static boolean
elf_s390_size_dynamic_sections (output_bfd, info)
- bfd *output_bfd;
+ bfd *output_bfd ATTRIBUTE_UNUSED;
struct bfd_link_info *info;
{
bfd *dynobj;
asection *s;
- boolean reltext;
boolean relocs;
boolean plt;
@@ -1137,7 +1139,6 @@ elf_s390_size_dynamic_sections (output_bfd, info)
determined the sizes of the various dynamic sections. Allocate
memory for them. */
plt = false;
- reltext = false;
relocs = false;
for (s = dynobj->sections; s != NULL; s = s->next)
{
@@ -1184,29 +1185,10 @@ elf_s390_size_dynamic_sections (output_bfd, info)
}
else
{
- asection *target;
-
/* Remember whether there are any reloc sections other
than .rela.plt. */
if (strcmp (name, ".rela.plt") != 0)
- {
- const char *outname;
-
- relocs = true;
-
- /* If this relocation section applies to a read only
- section, then we probably need a DT_TEXTREL
- entry. The entries in the .rela.plt section
- really apply to the .got section, which we
- created ourselves and so know is not readonly. */
- outname = bfd_get_section_name (output_bfd,
- s->output_section);
- target = bfd_get_section_by_name (output_bfd, outname + 5);
- if (target != NULL
- && (target->flags & SEC_READONLY) != 0
- && (target->flags & SEC_ALLOC) != 0)
- reltext = true;
- }
+ relocs = true;
/* We use the reloc_count field as a counter if we need
to copy relocs into the output file. */
@@ -1262,7 +1244,7 @@ elf_s390_size_dynamic_sections (output_bfd, info)
return false;
}
- if (reltext)
+ if ((info->flags & DF_TEXTREL) != 0)
{
if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
return false;
@@ -2150,6 +2132,23 @@ elf_s390_object_p (abfd)
return bfd_default_set_arch_mach (abfd, bfd_arch_s390, bfd_mach_s390_esa);
}
+static enum elf_reloc_type_class
+elf_s390_reloc_type_class (type)
+ int type;
+{
+ switch (type)
+ {
+ case R_390_RELATIVE:
+ return reloc_class_relative;
+ case R_390_JMP_SLOT:
+ return reloc_class_plt;
+ case R_390_COPY:
+ return reloc_class_copy;
+ default:
+ return reloc_class_normal;
+ }
+}
+
#define TARGET_BIG_SYM bfd_elf32_s390_vec
#define TARGET_BIG_NAME "elf32-s390"
#define ELF_ARCH bfd_arch_s390
@@ -2180,6 +2179,7 @@ elf_s390_object_p (abfd)
#define elf_backend_gc_sweep_hook elf_s390_gc_sweep_hook
#define elf_backend_relocate_section elf_s390_relocate_section
#define elf_backend_size_dynamic_sections elf_s390_size_dynamic_sections
+#define elf_backend_reloc_type_class elf_s390_reloc_type_class
#define elf_backend_object_p elf_s390_object_p
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
index a175555..0e80c43 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -56,6 +56,7 @@ static boolean elf_s390_finish_dynamic_symbol
static boolean elf_s390_finish_dynamic_sections
PARAMS ((bfd *, struct bfd_link_info *));
static boolean elf_s390_object_p PARAMS ((bfd *));
+static enum elf_reloc_type_class elf_s390_reloc_type_class PARAMS ((int));
#define USE_RELA 1 /* We want RELA relocations, not REL. */
@@ -684,6 +685,8 @@ elf_s390_check_relocs (abfd, info, sec, relocs)
|| ! bfd_set_section_alignment (dynobj, sreloc, 2))
return false;
}
+ if (sec->flags & SEC_READONLY)
+ info->flags |= DF_TEXTREL;
}
sreloc->_raw_size += sizeof (Elf64_External_Rela);
@@ -1069,12 +1072,11 @@ elf_s390_adjust_dynamic_symbol (info, h)
static boolean
elf_s390_size_dynamic_sections (output_bfd, info)
- bfd *output_bfd;
+ bfd *output_bfd ATTRIBUTE_UNUSED;
struct bfd_link_info *info;
{
bfd *dynobj;
asection *s;
- boolean reltext;
boolean relocs;
boolean plt;
@@ -1117,7 +1119,6 @@ elf_s390_size_dynamic_sections (output_bfd, info)
determined the sizes of the various dynamic sections. Allocate
memory for them. */
plt = false;
- reltext = false;
relocs = false;
for (s = dynobj->sections; s != NULL; s = s->next)
{
@@ -1164,29 +1165,10 @@ elf_s390_size_dynamic_sections (output_bfd, info)
}
else
{
- asection *target;
-
/* Remember whether there are any reloc sections other
than .rela.plt. */
if (strcmp (name, ".rela.plt") != 0)
- {
- const char *outname;
-
- relocs = true;
-
- /* If this relocation section applies to a read only
- section, then we probably need a DT_TEXTREL
- entry. The entries in the .rela.plt section
- really apply to the .got section, which we
- created ourselves and so know is not readonly. */
- outname = bfd_get_section_name (output_bfd,
- s->output_section);
- target = bfd_get_section_by_name (output_bfd, outname + 5);
- if (target != NULL
- && (target->flags & SEC_READONLY) != 0
- && (target->flags & SEC_ALLOC) != 0)
- reltext = true;
- }
+ relocs = true;
/* We use the reloc_count field as a counter if we need
to copy relocs into the output file. */
@@ -1242,7 +1224,7 @@ elf_s390_size_dynamic_sections (output_bfd, info)
return false;
}
- if (reltext)
+ if ((info->flags & DF_TEXTREL) != 0)
{
if (! bfd_elf64_add_dynamic_entry (info, DT_TEXTREL, 0))
return false;
@@ -2112,6 +2094,24 @@ elf_s390_object_p (abfd)
return bfd_default_set_arch_mach (abfd, bfd_arch_s390, bfd_mach_s390_esame);
}
+
+static enum elf_reloc_type_class
+elf_s390_reloc_type_class (type)
+ int type;
+{
+ switch (type)
+ {
+ case R_390_RELATIVE:
+ return reloc_class_relative;
+ case R_390_JMP_SLOT:
+ return reloc_class_plt;
+ case R_390_COPY:
+ return reloc_class_copy;
+ default:
+ return reloc_class_normal;
+ }
+}
+
/*
* Why was the hash table entry size definition changed from
* ARCH_SIZE/8 to 4? This breaks the 64 bit dynamic linker and
@@ -2179,6 +2179,7 @@ const struct elf_size_info s390_elf64_size_info =
#define elf_backend_gc_sweep_hook elf_s390_gc_sweep_hook
#define elf_backend_relocate_section elf_s390_relocate_section
#define elf_backend_size_dynamic_sections elf_s390_size_dynamic_sections
+#define elf_backend_reloc_type_class elf_s390_reloc_type_class
#define elf_backend_object_p elf_s390_object_p