aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@linux-mips.org>2013-05-03 15:19:27 +0000
committerMaciej W. Rozycki <macro@linux-mips.org>2013-05-03 15:19:27 +0000
commitcde7cb0129a884a060b99c7c83e8f5c9af728b0a (patch)
tree5200a969a7d2373802a23d78f8160613a192603f /ld
parenta5382c42bb58229b90b373efffc3a91a8e1bd044 (diff)
downloadgdb-cde7cb0129a884a060b99c7c83e8f5c9af728b0a.zip
gdb-cde7cb0129a884a060b99c7c83e8f5c9af728b0a.tar.gz
gdb-cde7cb0129a884a060b99c7c83e8f5c9af728b0a.tar.bz2
gold/
PR ld/15365 * layout.cc (Layout::finalize): Make __ehdr_start STV_HIDDEN. ld/ PR ld/15365 * emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): Restrict __ehdr_start's export class to no less than STV_HIDDEN. ld/testsuite/ PR ld/15365 * ld-elf/ehdr_start.d: Expect __ehdr_start to be STB_LOCAL. * ld-mips-elf/ehdr_start-1.nd: New test. * ld-mips-elf/ehdr_start-2.nd: New test. * ld-mips-elf/ehdr_start-1.ld: New test linker script. * ld-mips-elf/ehdr_start-2.ld: New test linker script. * ld-mips-elf/ehdr_start-new.s: New test source. * ld-mips-elf/ehdr_start-o32.s: New test source. * ld-mips-elf/mips-elf.exp: Run the new tests.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog6
-rw-r--r--ld/emultempl/elf32.em7
-rw-r--r--ld/testsuite/ChangeLog12
-rw-r--r--ld/testsuite/ld-elf/ehdr_start.d2
-rw-r--r--ld/testsuite/ld-mips-elf/ehdr_start-1.ld9
-rw-r--r--ld/testsuite/ld-mips-elf/ehdr_start-1.nd4
-rw-r--r--ld/testsuite/ld-mips-elf/ehdr_start-2.ld10
-rw-r--r--ld/testsuite/ld-mips-elf/ehdr_start-2.nd4
-rw-r--r--ld/testsuite/ld-mips-elf/ehdr_start-new.s13
-rw-r--r--ld/testsuite/ld-mips-elf/ehdr_start-o32.s14
-rw-r--r--ld/testsuite/ld-mips-elf/mips-elf.exp25
11 files changed, 105 insertions, 1 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 7175c98..e41c4dd 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,11 @@
2013-05-03 Alan Modra <amodra@gmail.com>
+ PR ld/15365
+ * emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation):
+ Restrict __ehdr_start's export class to no less than STV_HIDDEN.
+
+2013-05-03 Alan Modra <amodra@gmail.com>
+
* emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation):
Only call lang_for_each_statement if an ELF hash table is used.
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 251c511..581d9db 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -1487,6 +1487,13 @@ gld${EMULATION_NAME}_before_allocation (void)
{
_bfd_elf_tls_setup (link_info.output_bfd, &link_info);
+ /* Make __ehdr_start hidden if it has been referenced, to
+ prevent the symbol from being dynamic. */
+ if (!bfd_elf_record_link_assignment (link_info.output_bfd, &link_info,
+ "__ehdr_start", TRUE, TRUE))
+ einfo ("%P%F: failed to record assignment to %s: %E\n",
+ "__ehdr_start");
+
/* If we are going to make any variable assignments, we need to
let the ELF backend know about them in case the variables are
referred to by dynamic objects. */
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 4b8645b..a6919e3 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,5 +1,17 @@
2013-05-03 Maciej W. Rozycki <macro@codesourcery.com>
+ PR ld/15365
+ * ld-elf/ehdr_start.d: Expect __ehdr_start to be STB_LOCAL.
+ * ld-mips-elf/ehdr_start-1.nd: New test.
+ * ld-mips-elf/ehdr_start-2.nd: New test.
+ * ld-mips-elf/ehdr_start-1.ld: New test linker script.
+ * ld-mips-elf/ehdr_start-2.ld: New test linker script.
+ * ld-mips-elf/ehdr_start-new.s: New test source.
+ * ld-mips-elf/ehdr_start-o32.s: New test source.
+ * ld-mips-elf/mips-elf.exp: Run the new tests.
+
+2013-05-03 Maciej W. Rozycki <macro@codesourcery.com>
+
* ld-elf/provide-hidden-s.nd: New test.
* ld-elf/provide-hidden-abs.nd: New test.
* ld-elf/provide-hidden-def.nd: New test.
diff --git a/ld/testsuite/ld-elf/ehdr_start.d b/ld/testsuite/ld-elf/ehdr_start.d
index 9a82882..52e5b54 100644
--- a/ld/testsuite/ld-elf/ehdr_start.d
+++ b/ld/testsuite/ld-elf/ehdr_start.d
@@ -4,5 +4,5 @@
#target: *-*-linux* *-*-gnu* *-*-nacl*
#...
-[0-9a-f]*000 [ADRT] __ehdr_start
+[0-9a-f]*000 [Adrt] __ehdr_start
#pass
diff --git a/ld/testsuite/ld-mips-elf/ehdr_start-1.ld b/ld/testsuite/ld-mips-elf/ehdr_start-1.ld
new file mode 100644
index 0000000..0485b05
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/ehdr_start-1.ld
@@ -0,0 +1,9 @@
+ENTRY (__start)
+SECTIONS
+{
+ . = 0x12300000 + SIZEOF_HEADERS;
+ .text : { *(.text) }
+ . = 0x23400000;
+ HIDDEN (_gp = ALIGN (16) + 0x7ff0);
+ .got : { *(.got) }
+}
diff --git a/ld/testsuite/ld-mips-elf/ehdr_start-1.nd b/ld/testsuite/ld-mips-elf/ehdr_start-1.nd
new file mode 100644
index 0000000..9496b7d
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/ehdr_start-1.nd
@@ -0,0 +1,4 @@
+Symbol table '\.symtab' contains [0-9]+ entries:
+#...
+ *[0-9]+: 0*12300000 +0 (?:NOTYPE|OBJECT) +LOCAL +DEFAULT +[0-9]+ __ehdr_start
+#pass
diff --git a/ld/testsuite/ld-mips-elf/ehdr_start-2.ld b/ld/testsuite/ld-mips-elf/ehdr_start-2.ld
new file mode 100644
index 0000000..5d5e183
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/ehdr_start-2.ld
@@ -0,0 +1,10 @@
+ENTRY (__start)
+SECTIONS
+{
+ . = 0x12300000 + SIZEOF_HEADERS;
+ .text : { *(.text) }
+ . = 0x23400000;
+ __ehdr_start = .;
+ HIDDEN (_gp = ALIGN (16) + 0x7ff0);
+ .got : { *(.got) }
+}
diff --git a/ld/testsuite/ld-mips-elf/ehdr_start-2.nd b/ld/testsuite/ld-mips-elf/ehdr_start-2.nd
new file mode 100644
index 0000000..986c2a2
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/ehdr_start-2.nd
@@ -0,0 +1,4 @@
+Symbol table '\.symtab' contains [0-9]+ entries:
+#...
+ *[0-9]+: 0*23400000 +0 (?:NOTYPE|OBJECT) +LOCAL +DEFAULT +[0-9]+ __ehdr_start
+#pass
diff --git a/ld/testsuite/ld-mips-elf/ehdr_start-new.s b/ld/testsuite/ld-mips-elf/ehdr_start-new.s
new file mode 100644
index 0000000..5ee00dc
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/ehdr_start-new.s
@@ -0,0 +1,13 @@
+ .abicalls
+ .text
+ .weak __ehdr_start
+ .globl __start
+ .ent __start
+ .frame $29, 0, $31
+ .mask 0x00000000, 0
+__start:
+ .cplocal $2
+ .cpsetup $t9, $zero, __start
+ lw $2, __ehdr_start
+ jr $31
+ .end __start
diff --git a/ld/testsuite/ld-mips-elf/ehdr_start-o32.s b/ld/testsuite/ld-mips-elf/ehdr_start-o32.s
new file mode 100644
index 0000000..0973447
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/ehdr_start-o32.s
@@ -0,0 +1,14 @@
+ .abicalls
+ .text
+ .weak __ehdr_start
+ .globl __start
+ .ent __start
+ .frame $29, 0, $31
+ .mask 0x00000000, 0
+__start:
+ .set noreorder
+ .cpload $25
+ .set reorder
+ lw $2, __ehdr_start
+ jr $31
+ .end __start
diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp
index 902ae00..97e0c2c 100644
--- a/ld/testsuite/ld-mips-elf/mips-elf.exp
+++ b/ld/testsuite/ld-mips-elf/mips-elf.exp
@@ -709,3 +709,28 @@ foreach { abi } $abis {
"readelf -A export-class-call16-${abi}.gd"] \
"export-class-call16-${abi}.so"]]
}
+
+# Magic __ehdr_start symbol tests.
+set abis [concat o32 [expr {$has_newabi ? "n32 n64" : ""}]]
+foreach { abi } $abis {
+ set suff [string map {o32 o32 n32 new n64 new} $abi]
+ run_ld_link_tests [list \
+ [list \
+ "MIPS magic __ehdr_start symbol test 1 ($abi)" \
+ "$abi_ldflags($abi) -T ehdr_start-1.ld" "" \
+ "$abi_asflags($abi)" \
+ [list ehdr_start-${suff}.s] \
+ [list "readelf -s ehdr_start-1.nd"] \
+ "ehdr_start-1-${abi}"]]
+ if [regexp "(?:n32|n64)" "$abi"] {
+ setup_kfail "mips*-*-*" "ld/15428"
+ }
+ run_ld_link_tests [list \
+ [list \
+ "MIPS magic __ehdr_start symbol test 2 ($abi)" \
+ "$abi_ldflags($abi) -T ehdr_start-2.ld" "" \
+ "$abi_asflags($abi)" \
+ [list ehdr_start-${suff}.s] \
+ [list "readelf -s ehdr_start-2.nd"] \
+ "ehdr_start-2-${abi}"]]
+}