This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] LD/testsuite: ld-*/comm-data.exp improvements
- From: "Maciej W. Rozycki" <macro at linux-mips dot org>
- To: binutils at sourceware dot org
- Cc: Joseph Myers <joseph at codesourcery dot com>
- Date: Sun, 28 Jul 2013 01:00:29 +0100 (BST)
- Subject: [PATCH] LD/testsuite: ld-*/comm-data.exp improvements
Hi,
This change fixes ld-elf/comm-data.exp failures with the mn10300-*-linux*
and vax-*-linux* targets that do not implement copy reloc elimination (see
the ELIMINATE_COPY_RELOCS macro some backends use). Alternative dump
patterns are provided to support the different ELF file contents.
Additionally meaningful testing of such targets requires fixed VMA
assignments, so a linker script is now used and ld-mips-elf/comm-data.exp
has been adjusted accordingly.
Additionally check_shared_lib_support is now used to provide coverage
beyond *-*-linux*, *-*-nacl* and *-*-gnu* targets. This in turn required
providing extra assembler and/or linker flags for some oddball platforms,
and also a source file adjustment for the different .comm directive syntax
on HPUX.
(Joseph, any idea why the default linker emulation used by tic6x-uclinux
fails shared library or shared executable links?)
No regressions across the usual targets. OK to apply?
2013-07-27 Maciej W. Rozycki <macro@linux-mips.org>
ld/testsuite/
* ld-elf/comm-data.exp: Use check_shared_lib_support rather than
explicit patterns for test target qualification. Define extra
tool flags for *-*-hpux* and tic6x-*-* targets. Link with a
linker script. Use alternative patterns for targets that do not
eliminate copy relocs, currently mn10300-*-* and vax-*-*.
* ld-elf/comm-data2.s: Handle HPUX's `.comm' syntax.
* ld-elf/comm-data2.ld: New test linker script.
* ld-elf/comm-data2.xd: Match section's VMA too. Ignore ASCII
data dump.
* ld-elf/comm-data2r.rd: New test pattern.
* ld-elf/comm-data2r.sd: New test pattern.
* ld-elf/comm-data2r.xd: New test pattern.
* ld-mips-elf/comm-data.exp: Use check_shared_lib_support rather
than an explicit pattern for test target qualification. Link with
a linker script.
Maciej
binutils-2.23.52-20130506-ld-test-comm-data-copy.patch
Index: binutils/ld/testsuite/ld-elf/comm-data.exp
===================================================================
--- binutils.orig/ld/testsuite/ld-elf/comm-data.exp
+++ binutils/ld/testsuite/ld-elf/comm-data.exp
@@ -24,17 +24,22 @@
# Written by Maciej W. Rozycki <macro@codesourcery.com>
#
-# Exclude non-ELF targets.
-if ![is_elf_format] {
+# This test is for ELF shared-library targets.
+if { ![is_elf_format] || ![check_shared_lib_support] } {
return
}
-# Exclude some more targets; feel free to include your favorite one
-# if you like.
-if { ![istarget *-*-linux*]
- && ![istarget *-*-nacl*]
- && ![istarget *-*-gnu*] } {
- return
+# This target requires extra GAS options when building code for shared
+# libraries.
+set AFLAGS_PIC ""
+if [istarget "tic6x-*-*"] {
+ append AFLAGS_PIC " -mpic -mpid=near"
+}
+# This target requires a non-default emulation for successful shared
+# library/executable builds.
+set LFLAGS ""
+if [istarget "tic6x-*-*"] {
+ append LFLAGS " -melf32_tic6x_le"
}
set testname "Common symbol override test"
@@ -43,8 +48,8 @@ set testname "Common symbol override tes
run_ld_link_tests [list \
[list \
"$testname (auxiliary shared object build)" \
- "-shared" "" \
- "" \
+ "$LFLAGS -shared" "" \
+ "$AFLAGS_PIC" \
{ comm-data1.s } \
{ \
{ readelf -s comm-data1.sd } \
@@ -58,23 +63,35 @@ set AFLAGS ""
if [is_elf64 "tmpdir/libcomm-data.so"] {
append AFLAGS " --defsym ELF64=1"
}
+# HPUX targets use a different .comm syntax.
+if [istarget "*-*-hpux*"] {
+ append AFLAGS " --defsym HPUX=1"
+}
setup_xfail "arm*-*-*" "ld/13802"
+# List targets here that keep copy relocs rather than eliminating
+# them where possible in favour to dynamic relocs in the relevant
+# loadable sections; see also the "-z nocopyreloc" command-line
+# option and the ELIMINATE_COPY_RELOCS macro some backends use.
+set copy_reloc [expr [istarget mn10300-*-*] || [istarget vax-*-*]]
+
# Verify that a common symbol has been converted to an undefined
# reference to the global symbol of the same name defined above
# and that the debug reference has been dropped.
run_ld_link_tests [list \
[list \
"$testname" \
- "-Ltmpdir -lcomm-data" "" \
+ "$LFLAGS -T comm-data2.ld -Ltmpdir -lcomm-data" "" \
"$AFLAGS" \
{ comm-data2.s } \
- { \
- { readelf -s comm-data2.sd } \
- { readelf -r comm-data2.rd } \
- { readelf "-x .debug_foo" comm-data2.xd } \
- } \
+ [list \
+ [list readelf -s \
+ [expr { $copy_reloc ? "comm-data2r.sd" : "comm-data2.sd"}]] \
+ [list readelf -r \
+ [expr { $copy_reloc ? "comm-data2r.rd" : "comm-data2.rd"}]] \
+ [list readelf "-x .debug_foo" \
+ [expr { $copy_reloc ? "comm-data2r.xd" : "comm-data2.xd"}]]] \
"comm-data" \
] \
[list \
Index: binutils/ld/testsuite/ld-elf/comm-data2.ld
===================================================================
--- /dev/null
+++ binutils/ld/testsuite/ld-elf/comm-data2.ld
@@ -0,0 +1,20 @@
+SECTIONS
+{
+ . = 0x12340000;
+ .bss : { *(.dynbss) }
+ .got : { *(.got.plt) *(.got) }
+ .dynamic : { *(.dynamic) }
+ .data : { *(.data) }
+ . = 0x56780000;
+ .rela.dyn : { *(.rela.*) }
+ .interp : { *(.interp) }
+ .hash : { *(.hash) }
+ .dynsym : { *(.dynsym) }
+ .dynstr : { *(.dynstr) }
+ . = 0x76540000;
+ .debug_foo : { *(.debug_foo) }
+ .shstrtab : { *(.shstrtab) }
+ .symtab : { *(.symtab) }
+ .strtab : { *(.strtab) }
+ /DISCARD/ : { *(*) }
+}
Index: binutils/ld/testsuite/ld-elf/comm-data2.s
===================================================================
--- binutils.orig/ld/testsuite/ld-elf/comm-data2.s
+++ binutils/ld/testsuite/ld-elf/comm-data2.s
@@ -3,7 +3,11 @@
.globl __start
_start:
__start:
+ .ifdef HPUX
+foo .comm 4
+ .else
.comm foo, 4, 4
+ .endif
.section .debug_foo,"",%progbits
.balign 16
.ifdef ELF64
Index: binutils/ld/testsuite/ld-elf/comm-data2.xd
===================================================================
--- binutils.orig/ld/testsuite/ld-elf/comm-data2.xd
+++ binutils/ld/testsuite/ld-elf/comm-data2.xd
@@ -1,2 +1,2 @@
Hex dump of section '\.debug_foo':
- +0x0+ +00000000 00000000 00000000 00000000 +\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.
+ +0x0*76540000 00000000 00000000 00000000 00000000 .*
Index: binutils/ld/testsuite/ld-elf/comm-data2r.rd
===================================================================
--- /dev/null
+++ binutils/ld/testsuite/ld-elf/comm-data2r.rd
@@ -0,0 +1,3 @@
+Relocation section '\.rela\.dyn' at offset 0x[0-9a-f]+ contains 1 entries:
+ +Offset +Info +Type +Sym\.Value +Sym\. Name \+ Addend
+0*12340000 +[0-9a-f]+ +R_.*_COPY +0*12340000 +foo \+ 0
Index: binutils/ld/testsuite/ld-elf/comm-data2r.sd
===================================================================
--- /dev/null
+++ binutils/ld/testsuite/ld-elf/comm-data2r.sd
@@ -0,0 +1,10 @@
+Symbol table '\.dynsym' contains [0-9]+ entries:
+ +Num: +Value +Size +Type +Bind +Vis +Ndx +Name
+#...
+ +[0-9]+: +0*12340000 +4 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +foo
+#...
+Symbol table '\.symtab' contains [0-9]+ entries:
+ +Num: +Value +Size +Type +Bind +Vis +Ndx +Name
+#...
+ +[0-9]+: +0*12340000 +4 +OBJECT +GLOBAL +DEFAULT +[0-9]+ +foo
+#pass
Index: binutils/ld/testsuite/ld-elf/comm-data2r.xd
===================================================================
--- /dev/null
+++ binutils/ld/testsuite/ld-elf/comm-data2r.xd
@@ -0,0 +1,2 @@
+Hex dump of section '\.debug_foo':
+ +0x0*76540000 (?:12340000 00000000|00003412 00000000|00000000 00003412) 00000000 00000000 .*
Index: binutils/ld/testsuite/ld-mips-elf/comm-data.exp
===================================================================
--- binutils.orig/ld/testsuite/ld-mips-elf/comm-data.exp
+++ binutils/ld/testsuite/ld-mips-elf/comm-data.exp
@@ -24,9 +24,10 @@
# Written by Maciej W. Rozycki <macro@codesourcery.com>
#
-# Exclude non-Linux targets; feel free to include your favorite one
-# if you like.
-if ![istarget mips*-*-linux*] {
+# This test is for MIPS shared-library targets.
+if { ![istarget mips*-*-*]
+ || ![is_elf_format]
+ || ![check_shared_lib_support] } {
return
}
@@ -64,7 +65,7 @@ proc mips_comm_data_test { abi flag emul
run_ld_link_tests [list \
[list \
"$testname" \
- "$LDFLAGS $ZFLAG -Ltmpdir -lmips-$abi-$reloc-comm-data" "" \
+ "$LDFLAGS $ZFLAG -T ../ld-elf/comm-data2.ld -Ltmpdir -lmips-$abi-$reloc-comm-data" "" \
"$AFLAGS -call_nonpic" \
{ ../ld-elf/comm-data2.s } \
{ \