diff options
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 + |