aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2005-03-24 01:30:47 +0000
committerEric Christopher <echristo@gmail.com>2005-03-24 01:30:47 +0000
commitcc27e1dc443cce3873732b05a22c3ce4462e866a (patch)
tree57c48568716d3936114fb2f493d50efc0107eb07
parent2ecb839027f3cc2f6f5dd55eddd65df2efa0c4a8 (diff)
downloadbinutils-cc27e1dc443cce3873732b05a22c3ce4462e866a.zip
binutils-cc27e1dc443cce3873732b05a22c3ce4462e866a.tar.gz
binutils-cc27e1dc443cce3873732b05a22c3ce4462e866a.tar.bz2
bfd/ChangeLog:
2005-03-23 Eric Christopher <echristo@redhat.com> * elfxx-mips.c (MIPS_ELF_READONLY_SECTION): New. (mips_elf_calculate_relocation): Use. Define DF_TEXTREL after emitting relocation. (_bfd_mips_elf_adjust_dynamic_symbol): Ditto. (_bfd_mips_elf_check_relocs): Remove code to set DF_TEXTREL and readonly_reloc. ld/testsuite/ChangeLog: 2005-03-23 Eric Christopher <echristo@redhat.com> * ld-mips-elf/textrel-1.s, ld-mips-elf/textrel-1.d: New test. * ld-mips-elf/mips-elf.exp: Call it. * ld-mips-elf/rel32-n32.d: Update for DF_TEXTREL removal. * ld-mips-elf/rel32-o32.d: Ditto. * ld-mips-elf/rel64.d: Ditto.
-rw-r--r--bfd/ChangeLog9
-rw-r--r--bfd/elfxx-mips.c40
-rw-r--r--ld/testsuite/ChangeLog9
-rw-r--r--ld/testsuite/ld-mips-elf/mips-elf.exp4
-rw-r--r--ld/testsuite/ld-mips-elf/rel32-n32.d10
-rw-r--r--ld/testsuite/ld-mips-elf/rel32-o32.d2
-rw-r--r--ld/testsuite/ld-mips-elf/rel64.d10
-rw-r--r--ld/testsuite/ld-mips-elf/textrel-1.d26
-rw-r--r--ld/testsuite/ld-mips-elf/textrel-1.s9
9 files changed, 88 insertions, 31 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 9ee10a9..b15a3d5 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,12 @@
+2005-03-23 Eric Christopher <echristo@redhat.com>
+
+ * elfxx-mips.c (MIPS_ELF_READONLY_SECTION): New.
+ (mips_elf_calculate_relocation): Use. Define DF_TEXTREL
+ after emitting relocation.
+ (_bfd_mips_elf_adjust_dynamic_symbol): Ditto.
+ (_bfd_mips_elf_check_relocs): Remove code to set DF_TEXTREL
+ and readonly_reloc.
+
2005-03-23 Mike Frysinger <vapier@gentoo.org>
Nick Clifton <nickc@redhat.com>
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index a4baea9..951d1a7 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -478,6 +478,11 @@ static bfd *reldyn_sorting_bfd;
#define MIPS_ELF_OPTIONS_SECTION_NAME(abfd) \
(NEWABI_P (abfd) ? ".MIPS.options" : ".options")
+/* Whether the section is readonly. */
+#define MIPS_ELF_READONLY_SECTION(sec) \
+ ((sec->flags & (SEC_ALLOC | SEC_LOAD | SEC_READONLY)) \
+ == (SEC_ALLOC | SEC_LOAD | SEC_READONLY))
+
/* The name of the stub section. */
#define MIPS_ELF_STUB_SECTION_NAME(abfd) ".MIPS.stubs"
@@ -4005,6 +4010,10 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd,
&value,
input_section))
return bfd_reloc_undefined;
+
+ /* If we've written this we need to set DF_TEXTREL here. */
+ if (MIPS_ELF_READONLY_SECTION (input_section))
+ info->flags |= DF_TEXTREL;
}
else
{
@@ -6101,33 +6110,21 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
if (sreloc == NULL)
return FALSE;
}
-#define MIPS_READONLY_SECTION (SEC_ALLOC | SEC_LOAD | SEC_READONLY)
+
if (info->shared)
- {
- /* When creating a shared object, we must copy these
- reloc types into the output file as R_MIPS_REL32
- relocs. We make room for this reloc in the
- .rel.dyn reloc section. */
- mips_elf_allocate_dynamic_relocations (dynobj, 1);
- if ((sec->flags & MIPS_READONLY_SECTION)
- == MIPS_READONLY_SECTION)
- /* We tell the dynamic linker that there are
- relocations against the text segment. */
- info->flags |= DF_TEXTREL;
- }
+ /* When creating a shared object, we must copy these
+ reloc types into the output file as R_MIPS_REL32
+ relocs. We make room for this reloc in the
+ .rel.dyn reloc section. */
+ mips_elf_allocate_dynamic_relocations (dynobj, 1);
else
{
struct mips_elf_link_hash_entry *hmips;
-
+
/* We only need to copy this reloc if the symbol is
defined in a dynamic object. */
hmips = (struct mips_elf_link_hash_entry *) h;
++hmips->possibly_dynamic_relocs;
- if ((sec->flags & MIPS_READONLY_SECTION)
- == MIPS_READONLY_SECTION)
- /* We need it to tell the dynamic linker if there
- are relocations against the text segment. */
- hmips->readonly_reloc = TRUE;
}
/* Even though we don't directly need a GOT entry for
@@ -6423,9 +6420,12 @@ _bfd_mips_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
&& (h->root.type == bfd_link_hash_defweak
|| !h->def_regular))
{
+ asection *sec;
+ sec = mips_elf_rel_dyn_section (dynobj, FALSE);
mips_elf_allocate_dynamic_relocations (dynobj,
hmips->possibly_dynamic_relocs);
- if (hmips->readonly_reloc)
+
+ if (MIPS_ELF_READONLY_SECTION (sec))
/* We tell the dynamic linker that there are relocations
against the text segment. */
info->flags |= DF_TEXTREL;
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 657c796..8e8c09d 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2005-03-23 Eric Christopher <echristo@redhat.com>
+
+ * ld-mips-elf/textrel-1.s, ld-mips-elf/textrel-1.d: New
+ test.
+ * ld-mips-elf/mips-elf.exp: Call it.
+ * ld-mips-elf/rel32-n32.d: Update for DF_TEXTREL removal.
+ * ld-mips-elf/rel32-o32.d: Ditto.
+ * ld-mips-elf/rel64.d: Ditto.
+
2005-03-23 H.J. Lu <hongjiu.lu@intel.com>
* ld-cris/expdyn5.d: Updated for alignment change in elf.sc.
diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp
index 5413a72..b07f709 100644
--- a/ld/testsuite/ld-mips-elf/mips-elf.exp
+++ b/ld/testsuite/ld-mips-elf/mips-elf.exp
@@ -101,6 +101,10 @@ if {$has_newabi} {
run_dump_test "mips16-hilo-n32"
}
+if { $linux_gnu } {
+ run_dump_test "textrel-1"
+}
+
# For tests which may involve multiple files, use run_ld_link_tests.
# List contains test-items with 3 items followed by 2 lists:
diff --git a/ld/testsuite/ld-mips-elf/rel32-n32.d b/ld/testsuite/ld-mips-elf/rel32-n32.d
index cff8b36..565742a 100644
--- a/ld/testsuite/ld-mips-elf/rel32-n32.d
+++ b/ld/testsuite/ld-mips-elf/rel32-n32.d
@@ -4,12 +4,12 @@
#readelf: -x 5 -r
#ld: -shared -melf32btsmipn32
-Relocation section '.rel.dyn' at offset 0x304 contains 2 entries:
+Relocation section '.rel.dyn' at offset 0x2fc contains 2 entries:
Offset Info Type Sym.Value Sym. Name
00000000 00000000 R_MIPS_NONE
-00000330 00000003 R_MIPS_REL32
+00000320 00000003 R_MIPS_REL32
Hex dump of section '.text':
- 0x00000320 00000000 00000000 00000000 00000000 ................
- 0x00000330 00000330 00000000 00000000 00000000 ................
- 0x00000340 00000000 00000000 00000000 00000000 ................
+ 0x00000310 00000000 00000000 00000000 00000000 ................
+ 0x00000320 00000320 00000000 00000000 00000000 ................
+ 0x00000330 00000000 00000000 00000000 00000000 ................
diff --git a/ld/testsuite/ld-mips-elf/rel32-o32.d b/ld/testsuite/ld-mips-elf/rel32-o32.d
index 982758a..d89b87a 100644
--- a/ld/testsuite/ld-mips-elf/rel32-o32.d
+++ b/ld/testsuite/ld-mips-elf/rel32-o32.d
@@ -4,7 +4,7 @@
#readelf: -x 6 -r
#ld: -shared -melf32btsmip
-Relocation section '.rel.dyn' at offset 0x31c contains 2 entries:
+Relocation section '.rel.dyn' at offset 0x314 contains 2 entries:
Offset Info Type Sym.Value Sym. Name
00000000 00000000 R_MIPS_NONE
00000340 00000003 R_MIPS_REL32
diff --git a/ld/testsuite/ld-mips-elf/rel64.d b/ld/testsuite/ld-mips-elf/rel64.d
index ead15f0..8663f14 100644
--- a/ld/testsuite/ld-mips-elf/rel64.d
+++ b/ld/testsuite/ld-mips-elf/rel64.d
@@ -4,16 +4,16 @@
#readelf: -x 6 -r
#ld: -shared -melf64btsmip
-Relocation section '.rel.dyn' at offset 0x498 contains 2 entries:
+Relocation section '.rel.dyn' at offset 0x488 contains 2 entries:
Offset Info Type Sym. Value Sym. Name
000000000000 000000000000 R_MIPS_NONE
Type2: R_MIPS_NONE
Type3: R_MIPS_NONE
-0000000004d0 000000001203 R_MIPS_REL32
+0000000004c0 000000001203 R_MIPS_REL32
Type2: R_MIPS_64
Type3: R_MIPS_NONE
Hex dump of section '.text':
- 0x000004c0 00000000 00000000 00000000 00000000 ................
- 0x000004d0 00000000 000004d0 00000000 00000000 ................
- 0x000004e0 00000000 00000000 00000000 00000000 ................
+ 0x000004b0 00000000 00000000 00000000 00000000 ................
+ 0x000004c0 00000000 000004c0 00000000 00000000 ................
+ 0x000004d0 00000000 00000000 00000000 00000000 ................
diff --git a/ld/testsuite/ld-mips-elf/textrel-1.d b/ld/testsuite/ld-mips-elf/textrel-1.d
new file mode 100644
index 0000000..29a166d
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/textrel-1.d
@@ -0,0 +1,26 @@
+#name: MIPS textrel-1
+#source: textrel-1.s
+#as: -EB -n32
+#ld: -shared -melf32btsmipn32
+#readelf: -d
+
+Dynamic section at offset 0xb4 contains 18 entries:
+ Tag Type Name/Value
+ 0x00000004 \(HASH\) 0x16c
+ 0x00000005 \(STRTAB\) 0x30c
+ 0x00000006 \(SYMTAB\) 0x1fc
+ 0x0000000a \(STRSZ\) 84 \(bytes\)
+ 0x0000000b \(SYMENT\) 16 \(bytes\)
+ 0x00000015 \(DEBUG\) 0x0
+ 0x00000003 \(PLTGOT\) 0x1003e0
+ 0x00000011 \(REL\) 0x360
+ 0x00000012 \(RELSZ\) 8 \(bytes\)
+ 0x00000013 \(RELENT\) 8 \(bytes\)
+ 0x70000001 \(MIPS_RLD_VERSION\) 1
+ 0x70000005 \(MIPS_FLAGS\) NOTPOT
+ 0x70000006 \(MIPS_BASE_ADDRESS\) 0
+ 0x7000000a \(MIPS_LOCAL_GOTNO\) 7
+ 0x70000011 \(MIPS_SYMTABNO\) 17
+ 0x70000012 \(MIPS_UNREFEXTNO\) 12
+ 0x70000013 \(MIPS_GOTSYM\) 0x11
+ 0x00000000 \(NULL\) 0x0
diff --git a/ld/testsuite/ld-mips-elf/textrel-1.s b/ld/testsuite/ld-mips-elf/textrel-1.s
new file mode 100644
index 0000000..f6b4a6a
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/textrel-1.s
@@ -0,0 +1,9 @@
+ .globl foo
+foo:
+ .cfi_startproc
+ nop
+ .cfi_def_cfa_offset 4
+ nop
+ .cfi_register $29, $0
+ nop
+ .cfi_endproc