aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2011-06-10 14:04:25 +0000
committerNick Clifton <nickc@redhat.com>2011-06-10 14:04:25 +0000
commit894891db7f1ff09f021a0d2c8bb471f3a73a776a (patch)
tree92496b5fd1ebc0c60c95f341ca77699e87569545 /ld
parent12af614e24384fa939bbc1b55e40cfc28322c3a4 (diff)
downloadgdb-894891db7f1ff09f021a0d2c8bb471f3a73a776a.zip
gdb-894891db7f1ff09f021a0d2c8bb471f3a73a776a.tar.gz
gdb-894891db7f1ff09f021a0d2c8bb471f3a73a776a.tar.bz2
* elflink.c (_bfd_elf_link_create_dynamic_sections): If the
backend does not provide a function for creating dynamic sections then fail. (bfd_elf_final_link): Issue a warning message if a dynamic section has the SHT_NOTE type. (bfd_elf_final_link): Do not look for dynamic strings in a section that does not have the SHT_STRTAB type or the name .dynstr. * elf32-arm.c (elf32_arm_finish_dynamic_sections): Fail if the got section is not in the output binary. * elf32-hppa.c (elf32_hppa_finish_dynamic_sections): Likewise. * ld-elf/elf.exp: Add test for linking a shared library with a broken linker script that marks dynamic sections as being notes. * ld-elf/note-3.s: New test source file. * ld-elf/note-3.t: New test linker script. * ld-elf/note-3.l: Expected output from the linker. * lib/ld-lib.exp (run_ld_link_tests): Improve description.
Diffstat (limited to 'ld')
-rw-r--r--ld/testsuite/ChangeLog9
-rw-r--r--ld/testsuite/ld-elf/elf.exp39
-rw-r--r--ld/testsuite/ld-elf/note-3.l2
-rw-r--r--ld/testsuite/ld-elf/note-3.s10
-rw-r--r--ld/testsuite/ld-elf/note-3.t22
-rw-r--r--ld/testsuite/lib/ld-lib.exp34
6 files changed, 102 insertions, 14 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 43b678f..d224e3c 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2011-06-10 Nick Clifton <nickc@redhat.com>
+
+ * ld-elf/elf.exp: Add test for linking a shared library with a
+ broken linker script that marks dynamic sections as being notes.
+ * ld-elf/note-3.s: New test source file.
+ * ld-elf/note-3.t: New test linker script.
+ * ld-elf/note-3.l: Expected output from the linker.
+ * lib/ld-lib.exp (run_ld_link_tests): Improve description.
+
2011-06-08 H.J. Lu <hongjiu.lu@intel.com>
* ld-x86-64/x86-64.exp: Build x32 DSO from x86-64 object file
diff --git a/ld/testsuite/ld-elf/elf.exp b/ld/testsuite/ld-elf/elf.exp
index e991f83..61efc4a 100644
--- a/ld/testsuite/ld-elf/elf.exp
+++ b/ld/testsuite/ld-elf/elf.exp
@@ -49,6 +49,45 @@ run_ld_link_tests {
{symbol3w.s} {} "symbol3w.a"}
}
+# Run a test to check linking a shared library with a broken linker
+# script that accidentally marks dynamic sections as notes. The
+# resulting executable is not expected to work, but the linker
+# should not seg-fault whilst creating the binary.
+#
+# Only run the test on targets thats support creating shared libraries.
+if { ! [istarget arc-*-*]
+ && ! [istarget avr-*-*]
+ && ! [istarget cr16-*-*]
+ && ! [istarget cris*-*-*]
+ && ! [istarget crx-*-*]
+ && ! [istarget d10v-*-*]
+ && ! [istarget d30v-*-*]
+ && ! [istarget dlx-*-*]
+ && ! [istarget fr30-*-*]
+ && ! [istarget frv-*-*]
+ && ! [istarget h8300-*-*]
+ && ! [istarget ip2k-*-*]
+ && ! [istarget m32r-*-*]
+ && ! [istarget mcore*-*-*]
+ && ! [istarget mn10200-*-*]
+ && ! [istarget msp430-*-*]
+ && ! [istarget openrisc-*-*]
+ && ! [istarget or32-*-*]
+ && ! [istarget pj-*-*]
+ && ! [istarget rx-*-*]
+ && ! [istarget v850-*-*]
+ && ! [istarget *-*-irix*]
+ && ! [istarget *-*-rtems] } {
+ run_ld_link_tests {
+ {"Build shared library for next test"
+ "-shared" "" "note-3.s" {} "note-3.so" }
+ {"Link using broken linker script"
+ "--script note-3.t tmpdir/note-3.so" "" ""
+ { { ld "note-3.l" } }
+ "a.out" }
+ }
+}
+
set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
foreach t $test_list {
# We need to strip the ".d", but can leave the dirname.
diff --git a/ld/testsuite/ld-elf/note-3.l b/ld/testsuite/ld-elf/note-3.l
new file mode 100644
index 0000000..551ebaa
--- /dev/null
+++ b/ld/testsuite/ld-elf/note-3.l
@@ -0,0 +1,2 @@
+.*warning: section '.hash' is being made into a note
+.*
diff --git a/ld/testsuite/ld-elf/note-3.s b/ld/testsuite/ld-elf/note-3.s
new file mode 100644
index 0000000..3a1d190
--- /dev/null
+++ b/ld/testsuite/ld-elf/note-3.s
@@ -0,0 +1,10 @@
+ .globl _entry
+ .text
+_entry:
+ .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+ .global foo
+foo:
+ .byte 9
+
+ .section .note,"",%note
+ .byte 0
diff --git a/ld/testsuite/ld-elf/note-3.t b/ld/testsuite/ld-elf/note-3.t
new file mode 100644
index 0000000..13324ae
--- /dev/null
+++ b/ld/testsuite/ld-elf/note-3.t
@@ -0,0 +1,22 @@
+PHDRS
+{
+ text PT_LOAD FILEHDR PHDRS ;
+ note PT_NOTE;
+}
+SECTIONS
+{
+ . = . + SIZEOF_HEADERS ;
+ .text : { *(.text) *(.rodata) } :text
+ .note : { *(.note) } :note :text
+
+ /* BUG: This linker script is broken here. It has not reset the
+ output segment for the following sections, so they are all
+ treated as notes... */
+
+ .hash : { *(.hash) }
+
+ .dynstr : { *(.dynstr) }
+ .dynsym : { *(.dynsym) }
+ .got.plt : { *(.got.plt) *(.igot.plt) }
+ /DISCARD/ : { *(*) }
+}
diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp
index 62e0ff7..2020372 100644
--- a/ld/testsuite/lib/ld-lib.exp
+++ b/ld/testsuite/lib/ld-lib.exp
@@ -903,18 +903,24 @@ proc ar_simple_create { ar aropts target objects } {
# List contains test-items with 3 items followed by 2 lists, one item and
# one optional item:
-# 0:name 1:ld/ar options 2:assembler options
-# 3:filenames of assembler files 4: action and options. 5: name of output file
-# 6:compiler flags (optional)
+# 0:name
+# 1:ld/ar options
+# 2:assembler options
+# 3:filenames of assembler files
+# 4:list of actions, options and expected outputs.
+# 5:name of output file
+# 6:compiler flags (optional)
#
-# Actions:
-# objdump: Apply objdump options on result. Compare with regex (last arg).
-# nm: Apply nm options on result. Compare with regex (last arg).
-# readelf: Apply readelf options on result. Compare with regex (last arg).
-# ld: Don't apply anything on result. Compare output during linking with
-# regex (second arg). Note that this *must* be the first action if it
-# is to be used at all; in all other cases, any output from the linker
-# during linking is treated as a sign of an error and FAILs the test.
+# Actions: { command command-line-options file-containg-expected-output-regexps }
+# Commands:
+# objdump: Apply objdump options on result.
+# nm: Apply nm options on result.
+# readelf: Apply readelf options on result.
+# ld: Don't apply anything on result. Compare output during linking with
+# the file containing regexps (which is the second arg, not the third).
+# Note that this *must* be the first action if it is to be used at all;
+# in all other cases, any output from the linker during linking is
+# treated as a sign of an error and FAILs the test.
#
proc run_ld_link_tests { ldtests } {
global ld
@@ -1019,11 +1025,11 @@ proc run_ld_link_tests { ldtests } {
}
if { $action == "ld" } {
- set dumpfile [lindex $actionlist 1]
- verbose "dumpfile is $dumpfile"
+ set regexpfile $progopts
+ verbose "regexpfile is $srcdir/$subdir/$regexpfile"
set_file_contents "tmpdir/ld.messages" "$ld_output"
verbose "ld.messages has '[file_contents tmpdir/ld.messages]'"
- if { [regexp_diff "tmpdir/ld.messages" "$srcdir/$subdir/$dumpfile"] } then {
+ if { [regexp_diff "tmpdir/ld.messages" "$srcdir/$subdir/$regexpfile"] } then {
verbose "output is $ld_output" 2
set failed 1
break