aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-ppc.c
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/elf32-ppc.c
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/elf32-ppc.c')
-rw-r--r--bfd/elf32-ppc.c42
1 files changed, 25 insertions, 17 deletions
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"