diff options
author | Nick Clifton <nickc@redhat.com> | 2008-05-31 16:35:56 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2008-05-31 16:35:56 +0000 |
commit | de7dd2bdee702cd4a187c09427bd42b7eee239ec (patch) | |
tree | 40d84aa2c577867c71021aeb9f0ddc5bc74c6614 /ld/testsuite/ld-elfcomm | |
parent | c7eb6be45e424188fd6f1035ca747f4295f2588c (diff) | |
download | gdb-de7dd2bdee702cd4a187c09427bd42b7eee239ec.zip gdb-de7dd2bdee702cd4a187c09427bd42b7eee239ec.tar.gz gdb-de7dd2bdee702cd4a187c09427bd42b7eee239ec.tar.bz2 |
PR ld/6430
* testsuite/ld-elfcomm/elfcomm.exp (test_sort_common): Test the
ascending/descending argument to the --sort-common command line
option.
* testsuite/ld-elfcomm/sort-common.s: New file.
* ld.h (enum sort_order): New.
* ldlang.c (lang_check: Fix comment.
(lang_common): Sort commons in ascending or descending order.
(lang_one_common): Likewise.
* lexsup.c (ld_options): Have --sort-common take an option
argument.
(parse_args): Handle argument to --sort-common.
* ld.texinfo (--sort-common): Document new optional argument.
* NEWS: Mention new feature.
Diffstat (limited to 'ld/testsuite/ld-elfcomm')
-rw-r--r-- | ld/testsuite/ld-elfcomm/elfcomm.exp | 68 | ||||
-rw-r--r-- | ld/testsuite/ld-elfcomm/sort-common.s | 6 |
2 files changed, 74 insertions, 0 deletions
diff --git a/ld/testsuite/ld-elfcomm/elfcomm.exp b/ld/testsuite/ld-elfcomm/elfcomm.exp index f7de6fc..daed58b 100644 --- a/ld/testsuite/ld-elfcomm/elfcomm.exp +++ b/ld/testsuite/ld-elfcomm/elfcomm.exp @@ -28,6 +28,74 @@ if ![is_elf_format] { return } +proc test_sort_common {} { + global exec_output + global objdump + global srcdir + global subdir + global as + global ld + + set test "--sort-common (descending)" + + verbose "Check to see that --sort-common sorts in descending alignment" + + # We do not run the sort common tests for the DLX target because we know that the linker + # will seg-fault. The built-in DLX linker script requires that there be something in the + # .text section and our sort-common.s file does not provide anything. + if [istarget dlx-*-*] { + untested "$test" + return 0 + } + + if { ![ld_assemble $as $srcdir/$subdir/sort-common.s tmpdir/sort-common.o] } { + unresolved "$test" + return 0 + } + + if { ![ld_simple_link $ld tmpdir/sort-common.dx "--sort-common=descending tmpdir/sort-common.o"] } { + fail "$test" + return 0 + } + + send_log "$objdump --syms tmpdir/sort-common.dx | grep var | sort\n" + set exec_output [run_host_cmd "$objdump" "--syms tmpdir/sort-common.dx | grep var | sort"] + + # Don't know why, but the CR ports fail this test. + setup_xfail "cr16-*-*" "crx-*-*" + + # Note: The second regexp is for targets which put small commons in a .sbss + # section and large commons in a .bss section. + if { ![regexp ".*var_16.*var_8.*var_4.*var_2.*var_1.*" $exec_output] + && ![regexp ".*sbss.*var_8.*var_4.*var_2.*var_1.*bss.*var_16.*" $exec_output] } { + fail $test + } else { + pass $test + } + + set test "--sort-common (ascending)" + + verbose "Check to see that --sort-common=ascending sorts in ascending alignment" + + if { ![ld_simple_link $ld tmpdir/sort-common.ax "--sort-common=ascending tmpdir/sort-common.o"] } { + fail "$test" + return 0 + } + + send_log "$objdump --syms tmpdir/sort-common.ax | grep var | sort\n" + set exec_output [run_host_cmd "$objdump" "--syms tmpdir/sort-common.ax | grep var | sort"] + + if {![regexp ".*var_1.*var_2.*var_4.*var_8.*var_16.*" $exec_output]} { + fail $test + return 0 + } + + pass $test + return 1 +} + +test_sort_common + set test1 "size/aligment change of common symbols" set test1w1 "$test1 (warning 1)" set test1w2 "$test1 (warning 2)" diff --git a/ld/testsuite/ld-elfcomm/sort-common.s b/ld/testsuite/ld-elfcomm/sort-common.s new file mode 100644 index 0000000..478d73e --- /dev/null +++ b/ld/testsuite/ld-elfcomm/sort-common.s @@ -0,0 +1,6 @@ + .comm var_1byte_align,1,1 + .comm var_2byte_align,2,2 + .comm var_4byte_align,4,4 + .comm var_8byte_align,8,8 + .comm var_16byte_align,16,16 + |