diff options
author | Nick Clifton <nickc@redhat.com> | 2007-10-16 14:42:15 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2007-10-16 14:42:15 +0000 |
commit | 504b7d2026f1fbbe912b6f513c069c0d47ba2505 (patch) | |
tree | aa3186b5ab4a002cd64900af269e99d41031d584 /ld | |
parent | 62c018fe4a6de89d710e84b7efffe2462fa435cd (diff) | |
download | gdb-504b7d2026f1fbbe912b6f513c069c0d47ba2505.zip gdb-504b7d2026f1fbbe912b6f513c069c0d47ba2505.tar.gz gdb-504b7d2026f1fbbe912b6f513c069c0d47ba2505.tar.bz2 |
Support the use of the STT_COMMON type. (In source and object files only at the moment)
Diffstat (limited to 'ld')
-rw-r--r-- | ld/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | ld/testsuite/ld-elfcomm/elfcomm.exp | 67 | ||||
-rw-r--r-- | ld/testsuite/ld-sh/sh64/crangerel1.rd | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-sh/sh64/crangerel2.rd | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-sh/sh64/reldl32.rd | 2 | ||||
-rw-r--r-- | ld/testsuite/ld-sh/sh64/reldl64.rd | 2 |
6 files changed, 71 insertions, 7 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index e84bd0a..07b1e92 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-10-16 Nick Clifton <nickc@redhat.com> + + * lf-elfcomm/elfcomm.exp: Add tests of STT_COMMON symbol + generation. + 2007-10-12 Joseph Myers <joseph@codesourcery.com> * ld-mips-elf/multi-got-hidden-1.d, diff --git a/ld/testsuite/ld-elfcomm/elfcomm.exp b/ld/testsuite/ld-elfcomm/elfcomm.exp index bed5258..400dcad 100644 --- a/ld/testsuite/ld-elfcomm/elfcomm.exp +++ b/ld/testsuite/ld-elfcomm/elfcomm.exp @@ -53,12 +53,11 @@ proc dump_common1 { testname } { global exec_output global READELF - send_log "$READELF -s tmpdir/common1.o | grep foo\n" - set exec_output [run_host_cmd "readelf" "-s tmpdir/common1.o | grep foo"] + send_log "$READELF --syms tmpdir/common1.o | grep foo\n" + set exec_output [run_host_cmd "readelf" "--syms tmpdir/common1.o | grep foo"] - if { ![regexp "(\[ \]*)(\[0-9\]+):(\[ \]*)(\[0\]*)80(\[ \]+)4(\[ \]+)OBJECT(\[ \]+)GLOBAL(\[ \]+)DEFAULT(\[ \]+)(PRC\\\[0xff03\\\]|COM|SCOM)(\[ \]+)_?foo2" $exec_output] - || ![regexp "(\[ \]*)(\[0-9\]+):(\[ \]*)(\[0-9\]+)(\[ \]+)21(\[ \]+)OBJECT(\[ \]+)GLOBAL(\[ \]+)DEFAULT(\[ \]+)(\[0-9\]+)(\[ \]+)_?foo1" $exec_output] } { - send_log "$exec_output\n" + if { ![regexp "(\[ \]*)(\[0-9\]+):(\[ \]*)(\[0\]*)80(\[ \]+)4(\[ \]+)(COMMON|OBJECT)(\[ \]+)GLOBAL(\[ \]+)DEFAULT(\[ \]+)(PRC\\\[0xff03\\\]|COM|SCOM)(\[ \]+)_?foo2" $exec_output] + || ![regexp "(\[ \]*)(\[0-9\]+):(\[ \]*)(\[0-9\]+)(\[ \]+)21(\[ \]+)OBJECT(\[ \]+)GLOBAL(\[ \]+)DEFAULT(\[ \]+)(\[0-9\]+)(\[ \]+)_?foo1" $exec_output] } { verbose $exec_output fail $testname return 0 @@ -67,7 +66,49 @@ proc dump_common1 { testname } { return 1 } -if { ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/common1a.c tmpdir/common1a.o] +proc stt_common_test { options testname } { + global exec_output + global READELF + global ld + + set options "$options tmpdir/common1a.o" + + if { ! [ld_simple_link $ld tmpdir/common.exe $options] } { + unresolved $testname + return 0 + } + + send_log "$READELF --syms tmpdir/common.exe | grep foo\n" + set exec_output [run_host_cmd "readelf" "--syms tmpdir/common.exe | grep foo"] + + if {![regexp "(\[ \]*)(\[0-9\]+):(\[ \]*)(\[0-9\]+)(\[ \]+)(\[0-9\]+)(\[ \]+)COMMON(\[ \]+)GLOBAL(\[ \]+)DEFAULT(\[ \]+)(\[0-9\]+)(\[ \]+)_?foo2" $exec_output] } { + fail $testname + return 0 + } + + pass $testname + return 1 +} + +# Check to see if the assembler is generating symbols with the STT_COMMON type. +proc assembler_generates_commons {} { + global exec_output + global READELF + + verbose "Check to see if STT_COMMON symbols are being generated:" + set exec_output [run_host_cmd "readelf" "--syms tmpdir/common1a.o | grep foo"] + + if { ![regexp "(\[ \]*)(\[0-9\]+):(\[ \]*)(\[0\]*)80(\[ \]+).(\[ \]+)COMMON(\[ \]+)GLOBAL(\[ \]+)DEFAULT(\[ \]+)(PRC\\\[0xff03\\\]|COM|SCOM)(\[ \]+)_?foo2" $exec_output] } { + verbose "STT_COMMON not generated" + return 0 + } + + verbose "STT_COMMON's are generated" + return 1 +} + + +if { ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/common1a.c tmpdir/common1a.o] || ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/common1b.c tmpdir/common1b.o] } { unresolved $test1 return @@ -90,7 +131,6 @@ if {[istarget mips*-*-*]} { pass $test1w1 } } else { - pass $test1w1 if { ![regexp "Warning: alignment (\[0-9\]+) of symbol \`_?foo1\' in tmpdir/common1b.o is smaller than 64 in tmpdir/common1a.o" $link_output] || ![regexp "Warning: size of symbol \`_?foo1\' changed from 2 in tmpdir/common1a.o to 21 in tmpdir/common1b.o" $link_output] } { fail $test1w1 @@ -117,3 +157,16 @@ if { ![regexp "Warning: alignment (\[0-9\]+) of symbol \`_?foo1\' in tmpdir/comm if { [dump_common1 $test1c2] } { pass $test1c2 } + +# +# The following tests are for when we are generating STT_COMMON symbols only. +# + +if { ![assembler_generates_commons] } { + return +} + +stt_common_test "-static -e 0" "static link of common symbols" +stt_common_test "-shared" "shared link of common symbols" +stt_common_test "-pie" "position independent link of common symbols" + diff --git a/ld/testsuite/ld-sh/sh64/crangerel1.rd b/ld/testsuite/ld-sh/sh64/crangerel1.rd index 005918e..7b133c6 100644 --- a/ld/testsuite/ld-sh/sh64/crangerel1.rd +++ b/ld/testsuite/ld-sh/sh64/crangerel1.rd @@ -41,5 +41,6 @@ Hex dump of section '\.text\.mixed': 0x00000010 0000002b 00090009 .* Hex dump of section '\.cranges': +.* 0x00000000 00000000 0000000c 00030000 000c0000 .* 0x00000010 00080001 00000014 00000004 0002 .* diff --git a/ld/testsuite/ld-sh/sh64/crangerel2.rd b/ld/testsuite/ld-sh/sh64/crangerel2.rd index f9c55d5..635acfc 100644 --- a/ld/testsuite/ld-sh/sh64/crangerel2.rd +++ b/ld/testsuite/ld-sh/sh64/crangerel2.rd @@ -53,6 +53,7 @@ Hex dump of section '\.text\.mixed': 0x00000050 6ff0fff0 6ff0fff0 6ff0fff0 .* Hex dump of section '\.cranges': +.* 0x00000000 00000000 0000000c 00030000 000c0000 .* 0x00000010 00080001 00000014 00000004 00020000 .* 0x00000020 00180000 00100003 00000028 00000014 .* diff --git a/ld/testsuite/ld-sh/sh64/reldl32.rd b/ld/testsuite/ld-sh/sh64/reldl32.rd index d242c5c..98bbbed 100644 --- a/ld/testsuite/ld-sh/sh64/reldl32.rd +++ b/ld/testsuite/ld-sh/sh64/reldl32.rd @@ -303,6 +303,7 @@ Symbol table '\.symtab' contains 134 entries: 133: 00000000 0 <processor specific>: 13 GLOBAL DEFAULT UND unresolved8 Hex dump of section '\.text': +.* 0x00000000 6ff0fff0 6ff0fff0 cc0000a0 cc000140 .* 0x00000010 cc000140 cc000140 cc000280 cc0001e0 .* 0x00000020 cc0000a0 cc0000a0 cc000280 cc000140 .* @@ -319,6 +320,7 @@ Hex dump of section '\.text': 0x000000d0 6ff0fff0 .* Hex dump of section '\.data': +.* 0x00000000 00000000 00000000 00000008 00000000 .* 0x00000010 00000000 00000000 00000000 00000000 .* 0x00000020 00000028 00000000 00000000 00000000 .* diff --git a/ld/testsuite/ld-sh/sh64/reldl64.rd b/ld/testsuite/ld-sh/sh64/reldl64.rd index 41aa91e..a34537b 100644 --- a/ld/testsuite/ld-sh/sh64/reldl64.rd +++ b/ld/testsuite/ld-sh/sh64/reldl64.rd @@ -305,6 +305,7 @@ Symbol table '\.symtab' contains 134 entries: 133: 0000000000000000 0 <processor specific>: 13 GLOBAL DEFAULT UND unresolved8 Hex dump of section '\.text': +.* 0x00000000 6ff0fff0 6ff0fff0 cc0000a0 cc000140 .* 0x00000010 cc000140 cc000140 cc000280 cc0001e0 .* 0x00000020 cc0000a0 cc0000a0 cc000280 cc000140 .* @@ -321,6 +322,7 @@ Hex dump of section '\.text': 0x000000d0 6ff0fff0 6ff0fff0 6ff0fff0 .* Hex dump of section '\.data': +.* 0x00000000 00000000 00000000 00000008 00000000 .* 0x00000010 00000000 00000000 00000000 00000000 .* 0x00000020 00000028 00000000 00000000 00000000 .* |