+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>
* ld-arm/export-class.exp: Handle non-EABI targets.
# 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"
run_ld_link_tests [list \
[list \
"$testname (auxiliary shared object build)" \
- "-shared" "" \
- "" \
+ "$LFLAGS -shared" "" \
+ "$AFLAGS_PIC" \
{ comm-data1.s } \
{ \
{ readelf -s comm-data1.sd } \
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 \
--- /dev/null
+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/ : { *(*) }
+}
.globl __start
_start:
__start:
+ .ifdef HPUX
+foo .comm 4
+ .else
.comm foo, 4, 4
+ .endif
.section .debug_foo,"",%progbits
.balign 16
.ifdef ELF64
Hex dump of section '\.debug_foo':
- +0x0+ +00000000 00000000 00000000 00000000 +\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.
+ +0x0*76540000 00000000 00000000 00000000 00000000 .*
--- /dev/null
+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
--- /dev/null
+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
--- /dev/null
+Hex dump of section '\.debug_foo':
+ +0x0*76540000 (?:12340000 00000000|00003412 00000000|00000000 00003412) 00000000 00000000 .*
# 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
}
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 } \
{ \