* 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.
This commit is contained in:
Maciej W. Rozycki
2013-08-24 22:37:18 +00:00
parent aea6ea421d
commit fe9cd7ab17
9 changed files with 96 additions and 21 deletions

View File

@ -1,3 +1,21 @@
2013-08-24 Maciej W. Rozycki <macro@linux-mips.org>
* 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.
2013-08-24 Maciej W. Rozycki <macro@linux-mips.org> 2013-08-24 Maciej W. Rozycki <macro@linux-mips.org>
* ld-arm/export-class.exp: Handle non-EABI targets. * ld-arm/export-class.exp: Handle non-EABI targets.

View File

@ -24,17 +24,22 @@
# Written by Maciej W. Rozycki <macro@codesourcery.com> # Written by Maciej W. Rozycki <macro@codesourcery.com>
# #
# Exclude non-ELF targets. # This test is for ELF shared-library targets.
if ![is_elf_format] { if { ![is_elf_format] || ![check_shared_lib_support] } {
return return
} }
# Exclude some more targets; feel free to include your favorite one # This target requires extra GAS options when building code for shared
# if you like. # libraries.
if { ![istarget *-*-linux*] set AFLAGS_PIC ""
&& ![istarget *-*-nacl*] if [istarget "tic6x-*-*"] {
&& ![istarget *-*-gnu*] } { append AFLAGS_PIC " -mpic -mpid=near"
return }
# 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" set testname "Common symbol override test"
@ -43,8 +48,8 @@ set testname "Common symbol override test"
run_ld_link_tests [list \ run_ld_link_tests [list \
[list \ [list \
"$testname (auxiliary shared object build)" \ "$testname (auxiliary shared object build)" \
"-shared" "" \ "$LFLAGS -shared" "" \
"" \ "$AFLAGS_PIC" \
{ comm-data1.s } \ { comm-data1.s } \
{ \ { \
{ readelf -s comm-data1.sd } \ { readelf -s comm-data1.sd } \
@ -58,23 +63,35 @@ set AFLAGS ""
if [is_elf64 "tmpdir/libcomm-data.so"] { if [is_elf64 "tmpdir/libcomm-data.so"] {
append AFLAGS " --defsym ELF64=1" 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" 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 # Verify that a common symbol has been converted to an undefined
# reference to the global symbol of the same name defined above # reference to the global symbol of the same name defined above
# and that the debug reference has been dropped. # and that the debug reference has been dropped.
run_ld_link_tests [list \ run_ld_link_tests [list \
[list \ [list \
"$testname" \ "$testname" \
"-Ltmpdir -lcomm-data" "" \ "$LFLAGS -T comm-data2.ld -Ltmpdir -lcomm-data" "" \
"$AFLAGS" \ "$AFLAGS" \
{ comm-data2.s } \ { comm-data2.s } \
{ \ [list \
{ readelf -s comm-data2.sd } \ [list readelf -s \
{ readelf -r comm-data2.rd } \ [expr { $copy_reloc ? "comm-data2r.sd" : "comm-data2.sd"}]] \
{ readelf "-x .debug_foo" comm-data2.xd } \ [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" \ "comm-data" \
] \ ] \
[list \ [list \

View File

@ -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/ : { *(*) }
}

View File

@ -3,7 +3,11 @@
.globl __start .globl __start
_start: _start:
__start: __start:
.ifdef HPUX
foo .comm 4
.else
.comm foo, 4, 4 .comm foo, 4, 4
.endif
.section .debug_foo,"",%progbits .section .debug_foo,"",%progbits
.balign 16 .balign 16
.ifdef ELF64 .ifdef ELF64

View File

@ -1,2 +1,2 @@
Hex dump of section '\.debug_foo': Hex dump of section '\.debug_foo':
+0x0+ +00000000 00000000 00000000 00000000 +\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\. +0x0*76540000 00000000 00000000 00000000 00000000 .*

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,2 @@
Hex dump of section '\.debug_foo':
+0x0*76540000 (?:12340000 00000000|00003412 00000000|00000000 00003412) 00000000 00000000 .*

View File

@ -24,9 +24,10 @@
# Written by Maciej W. Rozycki <macro@codesourcery.com> # Written by Maciej W. Rozycki <macro@codesourcery.com>
# #
# Exclude non-Linux targets; feel free to include your favorite one # This test is for MIPS shared-library targets.
# if you like. if { ![istarget mips*-*-*]
if ![istarget mips*-*-linux*] { || ![is_elf_format]
|| ![check_shared_lib_support] } {
return return
} }
@ -64,7 +65,7 @@ proc mips_comm_data_test { abi flag emul reloc } {
run_ld_link_tests [list \ run_ld_link_tests [list \
[list \ [list \
"$testname" \ "$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" \ "$AFLAGS -call_nonpic" \
{ ../ld-elf/comm-data2.s } \ { ../ld-elf/comm-data2.s } \
{ \ { \