This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Combreloc patches for SH, Arm, CRIS
- To: binutils at sources dot redhat dot com
- Subject: Combreloc patches for SH, Arm, CRIS
- From: Andreas Jaeger <aj at suse dot de>
- Date: Sun, 26 Aug 2001 14:35:11 +0200
After these and previous patches for PPC, S390 and m68k have been
installed, most supported glibc platforms should handle combreloc
correctly. I didn't touch MIPS since it has again active maintainers
and MIPS does already some sorting. HP-PA is also missing.
I just compiled the files on i686-linux with --enable-targets=all and
run the testsuite but did no exhaustive tests.
Ok to commit?
Andreas
2001-08-26 Andreas Jaeger <aj@suse.de>
* elf32-cris.c (cris_elf_check_relocs): Set DF_TEXTREL if the
reloc is against read-only section.
(elf_cris_size_dynamic_sections): Use DF_TEXTREL flag instead of
looking up section names for DT_TEXTREL.
(elf_cris_reloc_type_class): New.
(elf_backend_reloc_type_class): Define.
* elf32-sh.c (sh_elf_check_relocs): Set DF_TEXTREL if the reloc is
against read-only section.
(elf_backend_reloc_type_class): Define.
(sh_elf_reloc_type_class): New.
(sh_elf_size_dynamic_sections): Use DF_TEXTREL flag instead of
looking up section names for DT_TEXTREL.
* elf32-arm.h (elf32_arm_check_relocs): Set DF_TEXTREL if the
reloc is against read-only section.
(elf32_arm_size_dynamic_sections): Use DF_TEXTREL flag instead of
looking up section names for DT_TEXTREL.
(elf32_arm_reloc_type_class): New.
(elf_backend_reloc_type_class): Define.
============================================================
Index: bfd/elf32-arm.h
--- bfd/elf32-arm.h 2001/08/25 09:47:34 1.54
+++ bfd/elf32-arm.h 2001/08/26 12:24:36
@@ -91,6 +91,9 @@
PARAMS ((bfd *, struct bfd_link_info *));
boolean bfd_elf32_arm_process_before_allocation
PARAMS ((bfd *, struct bfd_link_info *, int));
+static enum elf_reloc_type_class elf32_arm_reloc_type_class
+ PARAMS ((int));
+
#define INTERWORK_FLAG(abfd) (elf_elfheader (abfd)->e_flags & EF_ARM_INTERWORK)
/* The linker script knows the section names for placement.
@@ -2637,6 +2640,8 @@
|| ! bfd_set_section_alignment (dynobj, sreloc, 2))
return false;
}
+ if (sec->flags & SEC_READONLY)
+ info->flags |= DF_TEXTREL;
}
sreloc->_raw_size += sizeof (Elf32_External_Rel);
@@ -2951,14 +2956,13 @@
static boolean
elf32_arm_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;
dynobj = elf_hash_table (info)->dynobj;
BFD_ASSERT (dynobj != NULL);
@@ -3000,7 +3004,6 @@
memory for them. */
plt = false;
relocs = false;
- reltext = false;
for (s = dynobj->sections; s != NULL; s = s->next)
{
const char * name;
@@ -3046,31 +3049,11 @@
}
else
{
- asection * target;
-
/* Remember whether there are any reloc sections other
than .rel.plt. */
if (strcmp (name, ".rel.plt") != 0)
- {
- const char *outname;
-
- relocs = true;
+ relocs = true;
- /* If this relocation section applies to a read only
- section, then we probably need a DT_TEXTREL
- entry. The entries in the .rel.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 + 4);
-
- 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;
@@ -3133,7 +3116,7 @@
return false;
}
- if (reltext)
+ if ((info->flags & DF_TEXTREL) != 0)
{
if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
return false;
@@ -3457,6 +3440,24 @@
i_ehdrp->e_ident[EI_ABIVERSION] = ARM_ELF_ABI_VERSION;
}
+static enum elf_reloc_type_class
+elf32_arm_reloc_type_class (type)
+ int type;
+{
+ switch (type)
+ {
+ case R_ARM_RELATIVE:
+ return reloc_class_relative;
+ case R_ARM_JUMP_SLOT:
+ return reloc_class_plt;
+ case R_ARM_COPY:
+ return reloc_class_copy;
+ default:
+ return reloc_class_normal;
+ }
+}
+
+
#define ELF_ARCH bfd_arch_arm
#define ELF_MACHINE_CODE EM_ARM
#define ELF_MAXPAGESIZE 0x8000
@@ -3480,6 +3481,7 @@
#define elf_backend_finish_dynamic_sections elf32_arm_finish_dynamic_sections
#define elf_backend_size_dynamic_sections elf32_arm_size_dynamic_sections
#define elf_backend_post_process_headers elf32_arm_post_process_headers
+#define elf_backend_reloc_type_class elf32_arm_reloc_type_class
#define elf_backend_can_gc_sections 1
#define elf_backend_plt_readonly 1
============================================================
Index: bfd/elf32-sh.c
--- bfd/elf32-sh.c 2001/08/25 09:47:35 1.30
+++ bfd/elf32-sh.c 2001/08/26 12:24:40
@@ -83,6 +83,8 @@
static boolean sh_elf_gc_sweep_hook
PARAMS ((bfd *, struct bfd_link_info *, asection *,
const Elf_Internal_Rela *));
+static enum elf_reloc_type_class sh_elf_reloc_type_class
+ PARAMS ((int));
/* The name of the dynamic interpreter. This is put in the .interp
section. */
@@ -2761,14 +2763,13 @@
static boolean
sh_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;
dynobj = elf_hash_table (info)->dynobj;
BFD_ASSERT (dynobj != NULL);
@@ -2810,7 +2811,6 @@
memory for them. */
plt = false;
relocs = false;
- reltext = false;
for (s = dynobj->sections; s != NULL; s = s->next)
{
const char *name;
@@ -2856,30 +2856,11 @@
}
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;
+ 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;
- }
-
/* We use the reloc_count field as a counter if we need
to copy relocs into the output file. */
s->reloc_count = 0;
@@ -2934,7 +2915,7 @@
return false;
}
- if (reltext)
+ if ((info->flags & DF_TEXTREL) != 0)
{
if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
return false;
@@ -3957,6 +3938,8 @@
|| ! 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);
@@ -4441,6 +4424,23 @@
return true;
}
+static enum elf_reloc_type_class
+sh_elf_reloc_type_class (type)
+ int type;
+{
+ switch (type)
+ {
+ case R_SH_RELATIVE:
+ return reloc_class_relative;
+ case R_SH_JMP_SLOT:
+ return reloc_class_plt;
+ case R_SH_COPY:
+ return reloc_class_copy;
+ default:
+ return reloc_class_normal;
+ }
+}
+
#ifndef ELF_ARCH
#define TARGET_BIG_SYM bfd_elf32_sh_vec
#define TARGET_BIG_NAME "elf32-sh"
@@ -4484,6 +4484,7 @@
sh_elf_finish_dynamic_symbol
#define elf_backend_finish_dynamic_sections \
sh_elf_finish_dynamic_sections
+#define elf_backend_reloc_type_class sh_elf_reloc_type_class
#define elf_backend_want_got_plt 1
#define elf_backend_plt_readonly 1
============================================================
Index: bfd/elf32-cris.c
--- bfd/elf32-cris.c 2001/08/11 07:59:54 1.7
+++ bfd/elf32-cris.c 2001/08/26 12:24:43
@@ -85,6 +85,8 @@
PARAMS ((bfd *, struct bfd_link_info *));
static void elf_cris_hide_symbol
PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
+static enum elf_reloc_type_class elf_cris_reloc_type_class
+ PARAMS ((int));
static reloc_howto_type cris_elf_howto_table [] =
{
@@ -2575,6 +2577,8 @@
|| !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);
@@ -2642,14 +2646,13 @@
static boolean
elf_cris_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;
dynobj = elf_hash_table (info)->dynobj;
BFD_ASSERT (dynobj != NULL);
@@ -2703,7 +2706,6 @@
memory for them. */
plt = false;
relocs = false;
- reltext = false;
for (s = dynobj->sections; s != NULL; s = s->next)
{
const char *name;
@@ -2749,41 +2751,11 @@
}
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 are actually
- associated with .got.plt, 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 + strlen (".rela"));
-
- /* We have to test the .text section by name, becase for
- some reason it does not have SEC_READONLY set at this
- time. That flag is actually set in ldmain.c:main
- specifically for ".text" at a time long after this
- function is called. FIXME: This might be due to a
- general bug. FIXME: Have testcase for this. */
- if (target != NULL
- && (target->flags & SEC_ALLOC) != 0
- && ((target->flags & SEC_READONLY) != 0
- || strcmp (outname + strlen (".rela"),
- ".text") == 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;
@@ -2842,7 +2814,7 @@
return false;
}
- if (reltext)
+ if ((info->flags & DF_TEXTREL) != 0)
{
if (!bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
return false;
@@ -3020,6 +2992,24 @@
return true;
}
+
+
+static enum elf_reloc_type_class
+elf_cris_reloc_type_class (type)
+ int type;
+{
+ switch (type)
+ {
+ case R_CRIS_RELATIVE:
+ return reloc_class_relative;
+ case R_CRIS_JUMP_SLOT:
+ return reloc_class_plt;
+ case R_CRIS_COPY:
+ return reloc_class_copy;
+ default:
+ return reloc_class_normal;
+ }
+}
#define ELF_ARCH bfd_arch_cris
#define ELF_MACHINE_CODE EM_CRIS
@@ -3063,6 +3053,7 @@
#define bfd_elf32_bfd_final_link \
_bfd_elf32_gc_common_final_link
#define elf_backend_hide_symbol elf_cris_hide_symbol
+#define elf_backend_reloc_type_class elf_cris_reloc_type_class
#define elf_backend_want_got_plt 1
#define elf_backend_plt_readonly 1
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj