From 6a0d0afdc7ca5c7e0605ede799e994c98d596644 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Thu, 20 Oct 2005 17:06:41 +0000 Subject: [PATCH] binutils/testsuite/ 2005-10-20 H.J. Lu PR ld/251 * binutils-all/group.s: New file. * binutils-all/objcopy.exp (objcopy_test_readelf): New procedure. Use it to test ELF group. ld/testsuite/ 2005-10-20 H.J. Lu PR ld/251 * ld-elf/group.2d: New file. --- binutils/testsuite/ChangeLog | 11 ++++- binutils/testsuite/binutils-all/group.s | 8 ++++ binutils/testsuite/binutils-all/objcopy.exp | 47 +++++++++++++++++++++ ld/testsuite/ChangeLog | 7 ++- ld/testsuite/ld-elf/group2.d | 16 +++++++ ld/testsuite/ld-elf/unknown.d | 7 +++ 6 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 binutils/testsuite/binutils-all/group.s create mode 100644 ld/testsuite/ld-elf/group2.d create mode 100644 ld/testsuite/ld-elf/unknown.d diff --git a/binutils/testsuite/ChangeLog b/binutils/testsuite/ChangeLog index 5cf8bfa8244..648080c5de8 100644 --- a/binutils/testsuite/ChangeLog +++ b/binutils/testsuite/ChangeLog @@ -1,6 +1,15 @@ +2005-10-20 H.J. Lu + + PR ld/251 + * binutils-all/group.s: New file. + + * binutils-all/objcopy.exp (objcopy_test_readelf): New + procedure. + Use it to test ELF group. + 2005-10-19 H.J. Lu - PR binutils/1487 + PR ld/1487 * binutils-all/objcopy.exp (objcopy_test): New procedure. Use it to test simple copy, ia64 link order and ELF unknown section type. diff --git a/binutils/testsuite/binutils-all/group.s b/binutils/testsuite/binutils-all/group.s new file mode 100644 index 00000000000..21aa4be55b6 --- /dev/null +++ b/binutils/testsuite/binutils-all/group.s @@ -0,0 +1,8 @@ + .section .text,"axG",%progbits,foo_group,comdat + .global foo +foo: + .word 0 + .section .data,"awG",%progbits,foo_group,comdat + .global bar +bar: + .word 0 diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp index 87be6893303..23e537ea76a 100644 --- a/binutils/testsuite/binutils-all/objcopy.exp +++ b/binutils/testsuite/binutils-all/objcopy.exp @@ -661,6 +661,52 @@ switch [copy_setup] { } } +proc objcopy_test_readelf {testname srcfile} { + global OBJCOPY + global OBJCOPYFLAGS + global READELF + global srcdir + global subdir + + if {![binutils_assemble $srcdir/$subdir/${srcfile} tmpdir/bintest.o]} then { + unresolved "objcopy ($testname)" + return + } + + verbose -log "$OBJCOPY $OBJCOPYFLAGS tmpdir/bintest.o tmpdir/copy.o" + catch "exec $OBJCOPY $OBJCOPYFLAGS tmpdir/bintest.o tmpdir/copy.o" exec_output + if ![string match "" $exec_output] then { + fail "objcopy ($testname)" + return; + } + + verbose -log "$READELF -a tmpdir/bintest.o > tmpdir/bintest.o.out" + catch "exec $READELF -a tmpdir/bintest.o > tmpdir/bintest.o.out" exec_output + set exec_output [prune_warnings $exec_output] + if ![string match "" $exec_output] then { + unresolved "objcopy ($testname)" + return + } + + verbose -log "$READELF -a tmpdir/copy.o > tmpdir/copy.o.out" + catch "exec $READELF -a tmpdir/copy.o > tmpdir/copy.o.out" exec_output + set exec_output [prune_warnings $exec_output] + if ![string match "" $exec_output] then { + unresolved "objcopy ($testname)" + return + } + + verbose -log "diff tmpdir/bintest.o.out tmpdir/copy.o.out" + catch "exec diff tmpdir/bintest.o.out tmpdir/copy.o.out" exec_output + set exec_output [prune_warnings $exec_output] + + if [string match "" $exec_output] then { + pass "objcopy ($testname)" + } else { + fail "objcopy ($testname)" + } +} + # ia64 specific tests if { ([istarget "ia64-*-elf*"] || [istarget "ia64-*-linux*"]) } { @@ -670,4 +716,5 @@ if { ([istarget "ia64-*-elf*"] # ELF specific tests if [is_elf_format] { objcopy_test "ELF unknown section type" unknown.s + objcopy_test_readelf "ELF group" group.s } diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 5ba4799f92b..33831ce6888 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,6 +1,11 @@ +2005-10-20 H.J. Lu + + PR ld/251 + * ld-elf/group.2d: New file. + 2005-10-19 H.J. Lu - PR binutils/1487 + PR ld/1487 * ld-elf/unknown.d: New file. 2005-10-19 H.J. Lu diff --git a/ld/testsuite/ld-elf/group2.d b/ld/testsuite/ld-elf/group2.d new file mode 100644 index 00000000000..b4d0b819a23 --- /dev/null +++ b/ld/testsuite/ld-elf/group2.d @@ -0,0 +1,16 @@ +#source: ../../../binutils/testsuite/binutils-all/group.s +#ld: -r +#readelf: -Sg --wide + +#... + \[[ 0-9]+\] foo_group[ \t]+GROUP[ \t]+.* +#... + \[[ 0-9]+\] \.text.*[ \t]+PROGBITS[ \t0-9a-f]+AXG.* +#... + \[[ 0-9]+\] \.data.*[ \t]+PROGBITS[ \t0-9a-f]+WAG.* +#... +COMDAT group section \[[ 0-9]+\] `foo_group' \[foo_group\] contains 2 sections: + \[Index\] Name + \[[ 0-9]+\] .text.* + \[[ 0-9]+\] .data.* +#pass diff --git a/ld/testsuite/ld-elf/unknown.d b/ld/testsuite/ld-elf/unknown.d new file mode 100644 index 00000000000..636e6c7e6f3 --- /dev/null +++ b/ld/testsuite/ld-elf/unknown.d @@ -0,0 +1,7 @@ +#source: ../../../binutils/testsuite/binutils-all/unknown.s +#ld: -r +#readelf: -S + +#... + \[[ 0-9]+\] \.foo[ \t]+NOTE[ \t]+.* +#pass -- 2.30.2