aboutsummaryrefslogtreecommitdiff
path: root/ld/testsuite
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2008-08-22 08:32:40 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2008-08-22 08:32:40 +0000
commitb2064611d4230414258b5a3a1e8f49e5b0af2f3f (patch)
treea6dd4bf218ffecc8295d1475b1871fcc2eb724b7 /ld/testsuite
parentfec8276095570d58a8d32a0956d831e0e58e4981 (diff)
downloadgdb-b2064611d4230414258b5a3a1e8f49e5b0af2f3f.zip
gdb-b2064611d4230414258b5a3a1e8f49e5b0af2f3f.tar.gz
gdb-b2064611d4230414258b5a3a1e8f49e5b0af2f3f.tar.bz2
bfd/
Fix PR ld/3290 regression for cross-files DW_FORM_ref_addr relocations. * elflink.c (elf_link_add_object_symbols): Make debug symbols local now only for non-RELOCATABLE targets. ld/testsuite/ * ld-x86-64/dwarfreloc.exp, ld-x86-64/dwarfreloc.rd, ld-x86-64/dwarfreloc1.s, ld-x86-64/dwarfreloc2.s: New test.
Diffstat (limited to 'ld/testsuite')
-rw-r--r--ld/testsuite/ChangeLog5
-rw-r--r--ld/testsuite/ld-x86-64/dwarfreloc.exp86
-rw-r--r--ld/testsuite/ld-x86-64/dwarfreloc.rd17
-rw-r--r--ld/testsuite/ld-x86-64/dwarfreloc1.s101
-rw-r--r--ld/testsuite/ld-x86-64/dwarfreloc2.s94
5 files changed, 303 insertions, 0 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 5e1332a..117f5b7 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2008-08-22 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * ld-x86-64/dwarfreloc.exp, ld-x86-64/dwarfreloc.rd,
+ ld-x86-64/dwarfreloc1.s, ld-x86-64/dwarfreloc2.s: New test.
+
2008-08-20 Bob Wilson <bob.wilson@acm.org>
* ld-xtensa/tlsbin.dd, ld-xtensa/tlsbin.rd, ld-xtensa/tlsbin.s,
diff --git a/ld/testsuite/ld-x86-64/dwarfreloc.exp b/ld/testsuite/ld-x86-64/dwarfreloc.exp
new file mode 100644
index 0000000..8137a3d
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/dwarfreloc.exp
@@ -0,0 +1,86 @@
+# Expect script for DWARF relocation test.
+# Copyright 2008 Free Software Foundation, Inc.
+#
+# This file is part of the GNU Binutils.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+# MA 02110-1301, USA.
+#
+
+#
+# Written by Jan Kratochvil (jan.kratochvil@redhat.com)
+#
+# Test PR ld/3290 Comment 8+9. DW_FORM_ref_addr used in dwarfreloc2.s was left
+# unrelocated as its target symbol from dwarfreloc1.s became LOCAL due to its
+# `ld -r'.
+#
+# <1><57>: Abbrev Number: 2 (DW_TAG_variable)
+# <58> DW_AT_name : i2
+# ...
+# <5d> DW_AT_type : <0x32>
+# vs.
+# <5d> DW_AT_type : <0x0>
+
+# Only the testcase .s files are arch-dependent, the relocations are cross-arch.
+if { !([istarget "x86_64-*-elf*"]
+ || [istarget "x86_64-*-linux*"]) } {
+ return
+}
+
+set build_tests_ld {
+ {"Build dwarfreloc1x.o"
+ "-r" ""
+ {dwarfreloc1.s} {} "dwarfreloc1x.o"}
+ {"Build dwarfreloc2.o"
+ "-r" ""
+ {dwarfreloc2.s} {} "dwarfreloc2x.o"}
+}
+
+run_ld_link_tests $build_tests_ld
+
+set testname "Link dwarfreloc1x.o and dwarfreloc2x.o to dwarfreloc.o"
+if [ld_simple_link $ld "tmpdir/dwarfreloc.o" "-r tmpdir/dwarfreloc1x.o tmpdir/dwarfreloc2x.o"] {
+ pass $testname
+} else {
+ fail $testname
+}
+
+# The code is copied from `ld-lib.exp'. We cannot use the functions there as
+# they expect source (.s or .c) files while we to check a `ld -r' output (.o).
+
+set testname "Check dwarfreloc.o readelf"
+set dumpfile "dwarfreloc.rd"
+set cmd "$READELF --debug-dump=info tmpdir/dwarfreloc.o"
+set status [remote_exec host [concat sh -c [list "$cmd >dump.out 2>ld.stderr"]] "" "/dev/null"]
+send_log "$cmd\n"
+remote_upload host "ld.stderr"
+set comp_output [prune_warnings [file_contents "ld.stderr"]]
+remote_file host delete "ld.stderr"
+remote_file build delete "ld.stderr"
+
+if ![string match "" $comp_output] then {
+ send_log "$comp_output\n"
+ fail $testname
+} else {
+ remote_upload host "dump.out"
+ if { [regexp_diff "dump.out" "$srcdir/$subdir/$dumpfile"] } then {
+ verbose "output is [file_contents "dump.out"]" 2
+ fail $testname
+ } else {
+ pass $testname
+ }
+ remote_file build delete "dump.out"
+ remote_file host delete "dump.out"
+}
diff --git a/ld/testsuite/ld-x86-64/dwarfreloc.rd b/ld/testsuite/ld-x86-64/dwarfreloc.rd
new file mode 100644
index 0000000..84798ce
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/dwarfreloc.rd
@@ -0,0 +1,17 @@
+# Parenthesized `(...)' is the offset we cross-check.
+# The third parenthesized value was left unrelocated (0x0) before.
+#...
+.*Abbrev Number: .* \(DW_TAG_variable\).*
+#...
+.*DW_AT_type *: *<0x(32)>.*
+#...
+.*<(32)>: Abbrev Number: .* \(DW_TAG_base_type\).*
+#...
+.*Compilation Unit.*
+#...
+.*Abbrev Number: .* \(DW_TAG_compile_unit\).*
+#...
+.*Abbrev Number: .* \(DW_TAG_variable\).*
+#...
+.*DW_AT_type : <0x(32)>.*
+#...
diff --git a/ld/testsuite/ld-x86-64/dwarfreloc1.s b/ld/testsuite/ld-x86-64/dwarfreloc1.s
new file mode 100644
index 0000000..2f46ae2
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/dwarfreloc1.s
@@ -0,0 +1,101 @@
+ .file 1 "dwarfreloc1.c"
+ .comm i1,4,4
+ .section .debug_line,"",@progbits
+.Ldebug_line0:
+ .section .debug_info
+.Ldebug_info0:
+ .long .Ldebug_info_end - .Ldebug_info_start
+.Ldebug_info_start:
+ .value 0x2
+ .long .Ldebug_abbrev0
+ .byte 0x8
+
+ .uleb128 0x1 /* DW_TAG_compile_unit */
+ .long .LASF0 /* DW_AT_producer */
+ .byte 0x1 /* DW_AT_language */
+ .long .LASF1 /* DW_AT_name */
+ .long .LASF2 /* DW_AT_comp_dir */
+ .long .Ldebug_line0 /* DW_AT_stmt_list */
+
+ .uleb128 0x2 /* DW_TAG_variable */
+ .string "i1" /* DW_AT_name */
+ .byte 0x1 /* DW_AT_decl_file */
+ .byte 0x1 /* DW_AT_decl_line */
+ .long .dwarfreloc1.0.2 - .Ldebug_info0 /* DW_AT_type (DW_FORM_ref4) */
+ .byte 0x1 /* DW_AT_external */
+ .byte 0x9 /* DW_AT_location: length */
+ .byte 0x3 /* DW_AT_location: DW_OP_addr */
+ .quad i1 /* DW_AT_location: DW_OP_addr: address */
+
+ /* DWARF3 Page 224 (236/267)
+ <prefix>.<file-designator>.<gid-number>.<die-number> */
+ .globl .dwarfreloc1.0.2
+.dwarfreloc1.0.2:
+ .uleb128 0x3 /* DW_TAG_base_type */
+ .byte 0x4 /* DW_AT_byte_size */
+ .byte 0x5 /* DW_AT_encoding */
+ .string "int" /* DW_AT_name */
+
+ .byte 0x0
+.Ldebug_info_end:
+
+ .section .debug_abbrev
+.Ldebug_abbrev0:
+ .uleb128 0x1
+ .uleb128 0x11
+
+ .byte 0x1
+ .uleb128 0x25 /* DW_AT_producer */
+ .uleb128 0xe /* DW_FORM_strp */
+ .uleb128 0x13 /* DW_AT_language */
+ .uleb128 0xb /* DW_FORM_data1 */
+ .uleb128 0x3 /* DW_AT_name */
+ .uleb128 0xe /* DW_FORM_strp */
+ .uleb128 0x1b /* DW_AT_comp_dir */
+ .uleb128 0xe /* DW_FORM_strp */
+ .uleb128 0x10 /* DW_AT_stmt_list */
+ .uleb128 0x6 /* DW_FORM_data4 */
+ .byte 0x0
+ .byte 0x0
+
+ .uleb128 0x2
+ .uleb128 0x34 /* DW_TAG_variable */
+ .byte 0x0
+ .uleb128 0x3 /* DW_AT_name */
+ .uleb128 0x8 /* DW_FORM_string */
+ .uleb128 0x3a /* DW_AT_decl_file */
+ .uleb128 0xb /* DW_FORM_data1 */
+ .uleb128 0x3b /* DW_AT_decl_line */
+ .uleb128 0xb /* DW_FORM_data1 */
+ .uleb128 0x49 /* DW_AT_type */
+ .uleb128 0x13 /* DW_FORM_ref4 */
+ .uleb128 0x3f /* DW_AT_external */
+ .uleb128 0xc /* DW_FORM_flag */
+ .uleb128 0x2 /* DW_AT_location */
+ .uleb128 0xa /* DW_FORM_block1 */
+ .byte 0x0
+ .byte 0x0
+
+ .uleb128 0x3
+ .uleb128 0x24 /* DW_TAG_base_type */
+ .byte 0x0
+ .uleb128 0xb /* DW_AT_byte_size */
+ .uleb128 0xb /* DW_FORM_data1 */
+ .uleb128 0x3e /* DW_AT_encoding */
+ .uleb128 0xb /* DW_FORM_data1 */
+ .uleb128 0x3 /* DW_AT_name */
+ .uleb128 0x8 /* DW_FORM_string */
+ .byte 0x0
+ .byte 0x0
+
+ .byte 0x0
+
+ .section .debug_str,"MS",@progbits,1
+.LASF1:
+ .string "dwarfreloc1.c"
+.LASF0:
+ .string "GNU C 4.3.1 20080801 (Red Hat 4.3.1-6)"
+.LASF2:
+ .string "/"
+ .ident "GCC: (GNU) 4.3.1 20080801 (Red Hat 4.3.1-6)"
+ .section .note.GNU-stack,"",@progbits
diff --git a/ld/testsuite/ld-x86-64/dwarfreloc2.s b/ld/testsuite/ld-x86-64/dwarfreloc2.s
new file mode 100644
index 0000000..dee3b87
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/dwarfreloc2.s
@@ -0,0 +1,94 @@
+ .file 1 "dwarfreloc2.c"
+ .comm i2,4,4
+ .section .debug_line,"",@progbits
+.Ldebug_line0:
+ .section .debug_info
+.Ldebug_info0:
+ .long .Ldebug_info_end - .Ldebug_info_start
+.Ldebug_info_start:
+ .value 0x2
+ .long .Ldebug_abbrev0
+ .byte 0x8
+
+ .uleb128 0x1 /* DW_TAG_compile_unit */
+ .long .LASF0 /* DW_AT_producer */
+ .byte 0x1 /* DW_AT_language */
+ .long .LASF1 /* DW_AT_name */
+ .long .LASF2 /* DW_AT_comp_dir */
+ .long .Ldebug_line0 /* DW_AT_stmt_list */
+
+ .uleb128 0x2 /* DW_TAG_variable */
+ .string "i2" /* DW_AT_name */
+ .byte 0x1 /* DW_AT_decl_file */
+ .byte 0x1 /* DW_AT_decl_line */
+ /* DWARF3 Page 224 (236/267)
+ <prefix>.<file-designator>.<gid-number>.<die-number> */
+ .quad .dwarfreloc1.0.2 /* DW_AT_type (DW_FORM_ref_addr) */
+ .byte 0x1 /* DW_AT_external */
+ .byte 0x9 /* DW_AT_location: length */
+ .byte 0x3 /* DW_AT_location: DW_OP_addr */
+ .quad i2 /* DW_AT_location: DW_OP_addr: address */
+
+ .byte 0x0
+.Ldebug_info_end:
+
+ .section .debug_abbrev
+.Ldebug_abbrev0:
+ .uleb128 0x1
+ .uleb128 0x11
+
+ .byte 0x1
+ .uleb128 0x25 /* DW_AT_producer */
+ .uleb128 0xe /* DW_FORM_strp */
+ .uleb128 0x13 /* DW_AT_language */
+ .uleb128 0xb /* DW_FORM_data1 */
+ .uleb128 0x3 /* DW_AT_name */
+ .uleb128 0xe /* DW_FORM_strp */
+ .uleb128 0x1b /* DW_AT_comp_dir */
+ .uleb128 0xe /* DW_FORM_strp */
+ .uleb128 0x10 /* DW_AT_stmt_list */
+ .uleb128 0x6 /* DW_FORM_data4 */
+ .byte 0x0
+ .byte 0x0
+
+ .uleb128 0x2
+ .uleb128 0x34 /* DW_TAG_variable */
+ .byte 0x0
+ .uleb128 0x3 /* DW_AT_name */
+ .uleb128 0x8 /* DW_FORM_string */
+ .uleb128 0x3a /* DW_AT_decl_file */
+ .uleb128 0xb /* DW_FORM_data1 */
+ .uleb128 0x3b /* DW_AT_decl_line */
+ .uleb128 0xb /* DW_FORM_data1 */
+ .uleb128 0x49 /* DW_AT_type */
+ .uleb128 0x10 /* DW_FORM_ref_addr */
+ .uleb128 0x3f /* DW_AT_external */
+ .uleb128 0xc /* DW_FORM_flag */
+ .uleb128 0x2 /* DW_AT_location */
+ .uleb128 0xa /* DW_FORM_block1 */
+ .byte 0x0
+ .byte 0x0
+
+ .uleb128 0x3
+ .uleb128 0x24 /* DW_TAG_base_type */
+ .byte 0x0
+ .uleb128 0xb /* DW_AT_byte_size */
+ .uleb128 0xb /* DW_FORM_data1 */
+ .uleb128 0x3e /* DW_AT_encoding */
+ .uleb128 0xb /* DW_FORM_data1 */
+ .uleb128 0x3 /* DW_AT_name */
+ .uleb128 0x8 /* DW_FORM_string */
+ .byte 0x0
+ .byte 0x0
+
+ .byte 0x0
+
+ .section .debug_str,"MS",@progbits,1
+.LASF1:
+ .string "dwarfreloc2.c"
+.LASF0:
+ .string "GNU C 4.3.1 20080801 (Red Hat 4.3.1-6)"
+.LASF2:
+ .string "/"
+ .ident "GCC: (GNU) 4.3.1 20080801 (Red Hat 4.3.1-6)"
+ .section .note.GNU-stack,"",@progbits