This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[PATCH] SH: Remove unexpected DT_TEXTREL entry (committed)
- From: kaz Kojima <kkojima at rr dot iij4u dot or dot jp>
- To: binutils at sources dot redhat dot com
- Date: Sat, 02 Aug 2003 22:56:41 +0900
- Subject: [PATCH] SH: Remove unexpected DT_TEXTREL entry (committed)
Hi,
Dan Kegel pointed out that some shared libraries generated by the current
SH linker have DT_TEXTREL entries although there are no text relocations
in them.
The attached tiny patch for elf32-sh.c fixes this. I'll also add a run-dump
test for this case. Regtested on sh4-unknown-linux-gnu, sh-unknown-netbsd
sh-unknown-elf and sh64-unknown-elf. Committed to the mainline.
Regards,
kaz
--
2003-08-02 Kaz Kojima <kkojima@rr.iij4u.or.jp>
[bfd/ChangeLog]
* elf32-sh.c (sh_elf_check_relocs): Don't set DF_TEXTREL here.
[ld/testsuite/ChangeLog]
* ld-sh/shared-2.d, ld-sh/textrel1.s, ld-sh/textrel2.s: New test.
diff -u3prN ORIG/src/bfd/elf32-sh.c LOCAL/src/bfd/elf32-sh.c
--- ORIG/src/bfd/elf32-sh.c Fri Jul 25 14:46:58 2003
+++ LOCAL/src/bfd/elf32-sh.c Fri Aug 1 08:03:54 2003
@@ -6497,8 +6497,6 @@ sh_elf_check_relocs (bfd *abfd, struct b
sreloc, 2))
return FALSE;
}
- if (sec->flags & SEC_READONLY)
- info->flags |= DF_TEXTREL;
elf_section_data (sec)->sreloc = sreloc;
}
diff -u3prN ORIG/src/ld/testsuite/ld-sh/shared-2.d LOCAL/src/ld/testsuite/ld-sh/shared-2.d
--- ORIG/src/ld/testsuite/ld-sh/shared-2.d Thu Jan 1 09:00:00 1970
+++ LOCAL/src/ld/testsuite/ld-sh/shared-2.d Sat Aug 2 21:10:24 2003
@@ -0,0 +1,20 @@
+#source: textrel1.s
+#source: textrel2.s
+#as: -little
+#ld: -shared -EL
+#readelf: -d
+#target: sh*-*-elf sh*-*-linux* sh*-*-netbsd*
+
+# Make sure that there is no unnecessary DT_TEXTREL entry.
+
+Dynamic segment at offset 0x[0-9a-f]+ contains 9 entries:
+ Tag Type Name/Value
+ 0x00000004 \(HASH\) 0x[0-9a-f]+
+ 0x00000005 \(STRTAB\) 0x[0-9a-f]+
+ 0x00000006 \(SYMTAB\) 0x[0-9a-f]+
+ 0x0000000a \(STRSZ\) [0-9]+ \(bytes\)
+ 0x0000000b \(SYMENT\) 16 \(bytes\)
+ 0x00000007 \(RELA\) 0x[0-9a-f]+
+ 0x00000008 \(RELASZ\) 12 \(bytes\)
+ 0x00000009 \(RELAENT\) 12 \(bytes\)
+ 0x00000000 \(NULL\) 0x0
diff -u3prN ORIG/src/ld/testsuite/ld-sh/textrel1.s LOCAL/src/ld/testsuite/ld-sh/textrel1.s
--- ORIG/src/ld/testsuite/ld-sh/textrel1.s Thu Jan 1 09:00:00 1970
+++ LOCAL/src/ld/testsuite/ld-sh/textrel1.s Sat Aug 2 20:57:01 2003
@@ -0,0 +1,11 @@
+ .text
+ .align 5
+ .globl f
+f:
+ mov.l .L1,r0
+ rts
+ nop
+ .align 2
+.L1: .long g - f
+ .long foo@GOT
+
diff -u3prN ORIG/src/ld/testsuite/ld-sh/textrel2.s LOCAL/src/ld/testsuite/ld-sh/textrel2.s
--- ORIG/src/ld/testsuite/ld-sh/textrel2.s Thu Jan 1 09:00:00 1970
+++ LOCAL/src/ld/testsuite/ld-sh/textrel2.s Sat Aug 2 20:57:01 2003
@@ -0,0 +1,7 @@
+ .text
+ .align 5
+ .globl g
+ .hidden g
+g:
+ rts
+ nop