CVS commit: src/tests/usr.bin/ld
Module Name:src Committed By: martin Date: Tue Feb 17 11:51:04 UTC 2015 Modified Files: src/tests/usr.bin/ld: t_section.sh Log Message: Make the dummy data that we expect to go into .data section bigger, otherwise on e.g. alpha it goes into the small objects data .sdata section, which confuses the matching done in this test. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/ld/t_section.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/ld/t_section.sh diff -u src/tests/usr.bin/ld/t_section.sh:1.3 src/tests/usr.bin/ld/t_section.sh:1.4 --- src/tests/usr.bin/ld/t_section.sh:1.3 Sat Nov 15 03:22:29 2014 +++ src/tests/usr.bin/ld/t_section.sh Tue Feb 17 11:51:04 2015 @@ -1,4 +1,4 @@ -# $NetBSD: t_section.sh,v 1.3 2014/11/15 03:22:29 uebayasi Exp $ +# $NetBSD: t_section.sh,v 1.4 2015/02/17 11:51:04 martin Exp $ # # Copyright (c) 2014 The NetBSD Foundation, Inc. # All rights reserved. @@ -59,7 +59,7 @@ const char a[] __section(hoge) = hoge /* read-write orphan */ char b[] __section(fuga) = { 'f', 'u', 'g', 'a', '\0' }; /* .data */ -int c = 123; +int c[1024] = { 123, 20, 1, 0 }; /* .bss */ int d = 0; /* .text */
CVS commit: src/tests/usr.bin/ld
Module Name:src Committed By: uebayasi Date: Sun Nov 16 03:49:09 UTC 2014 Modified Files: src/tests/usr.bin/ld: t_script.sh Log Message: Test SORT() command. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/ld/t_script.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/ld/t_script.sh diff -u src/tests/usr.bin/ld/t_script.sh:1.5 src/tests/usr.bin/ld/t_script.sh:1.6 --- src/tests/usr.bin/ld/t_script.sh:1.5 Sat Nov 15 04:47:11 2014 +++ src/tests/usr.bin/ld/t_script.sh Sun Nov 16 03:49:09 2014 @@ -1,4 +1,4 @@ -# $NetBSD: t_script.sh,v 1.5 2014/11/15 04:47:11 uebayasi Exp $ +# $NetBSD: t_script.sh,v 1.6 2014/11/16 03:49:09 uebayasi Exp $ # # Copyright (c) 2014 The NetBSD Foundation, Inc. # All rights reserved. @@ -63,13 +63,13 @@ EOF -atf_test_case reorder -reorder_head() { +atf_test_case order_reorder +order_reorder_head() { atf_set descr check if object reordering works atf_set require.progs cc ld readelf nm sed grep } -reorder_body() { +order_reorder_body() { cat test.x EOF SECTIONS { .data : { @@ -85,6 +85,27 @@ EOF +atf_test_case order_sort +order_sort_head() { + atf_set descr check if object sort works + atf_set require.progs cc ld readelf nm sed grep +} + +order_sort_body() { + cat test.x EOF +SECTIONS { + .data : { + *(.data) + /* SORT_BY_NAME */ + SORT(*)(.data.*) + } +} +EOF + order_assert_ascending +} + + + atf_test_case multisec multisec_head() { atf_set descr check if multiple SECTIONS commands work @@ -200,6 +221,7 @@ atf_init_test_cases() { atf_add_test_case order_default atf_add_test_case order_merge - atf_add_test_case reorder + atf_add_test_case order_reorder + atf_add_test_case order_sort atf_add_test_case multisec }
CVS commit: src/tests/usr.bin/ld
Module Name:src Committed By: uebayasi Date: Sun Nov 16 04:47:18 UTC 2014 Modified Files: src/tests/usr.bin/ld: t_script.sh Log Message: Minor tweaks. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/ld/t_script.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/ld/t_script.sh diff -u src/tests/usr.bin/ld/t_script.sh:1.6 src/tests/usr.bin/ld/t_script.sh:1.7 --- src/tests/usr.bin/ld/t_script.sh:1.6 Sun Nov 16 03:49:09 2014 +++ src/tests/usr.bin/ld/t_script.sh Sun Nov 16 04:47:18 2014 @@ -1,4 +1,4 @@ -# $NetBSD: t_script.sh,v 1.6 2014/11/16 03:49:09 uebayasi Exp $ +# $NetBSD: t_script.sh,v 1.7 2014/11/16 04:47:18 uebayasi Exp $ # # Copyright (c) 2014 The NetBSD Foundation, Inc. # All rights reserved. @@ -36,7 +36,8 @@ order_default_head() { order_default_body() { cat test.x EOF SECTIONS { - /* do nothing */ + /* do nothing; but ld has implicit scripts internally */ + /* which usually do: *(.data) *(.data.*) */ } EOF order_assert_descending @@ -47,7 +48,7 @@ EOF atf_test_case order_merge order_merge_head() { atf_set descr check if glob merge keeps object ordering - atf_set require.progs cc ld readelf nm sed grep + atf_set require.progs ${order_require_progs} } order_merge_body() { @@ -66,7 +67,7 @@ EOF atf_test_case order_reorder order_reorder_head() { atf_set descr check if object reordering works - atf_set require.progs cc ld readelf nm sed grep + atf_set require.progs ${order_require_progs} } order_reorder_body() { @@ -88,7 +89,7 @@ EOF atf_test_case order_sort order_sort_head() { atf_set descr check if object sort works - atf_set require.progs cc ld readelf nm sed grep + atf_set require.progs ${order_require_progs} } order_sort_body() { @@ -109,7 +110,7 @@ EOF atf_test_case multisec multisec_head() { atf_set descr check if multiple SECTIONS commands work - atf_set require.progs cc ld readelf nm sed grep + atf_set require.progs ${order_require_progs} } multisec_body() { @@ -146,6 +147,8 @@ EOF +order_require_progs=cc ld readelf nm sed grep + order_assert_ascending() { order_assert_order a b c }
CVS commit: src/tests/usr.bin/ld
Module Name:src Committed By: uebayasi Date: Fri Nov 14 16:20:42 UTC 2014 Modified Files: src/tests/usr.bin/ld: t_section.sh Log Message: Fix thinko in previous. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/ld/t_section.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/ld/t_section.sh diff -u src/tests/usr.bin/ld/t_section.sh:1.1 src/tests/usr.bin/ld/t_section.sh:1.2 --- src/tests/usr.bin/ld/t_section.sh:1.1 Fri Nov 14 13:30:48 2014 +++ src/tests/usr.bin/ld/t_section.sh Fri Nov 14 16:20:42 2014 @@ -1,4 +1,4 @@ -# $NetBSD: t_section.sh,v 1.1 2014/11/14 13:30:48 uebayasi Exp $ +# $NetBSD: t_section.sh,v 1.2 2014/11/14 16:20:42 uebayasi Exp $ # # Copyright (c) 2014 The NetBSD Foundation, Inc. # All rights reserved. @@ -36,13 +36,12 @@ startstop_body() { #include sys/cdefs.h int i __section(hoge); extern int __start_hoge[], __stop_hoge[]; -int main = __start_hoge[0] + __stop_hoge[0]; +int main(void) { return __start_hoge[0] + __stop_hoge[0]; } EOF atf_check -s exit:0 -o ignore -e ignore cc -o test test.c } atf_init_test_cases() { - atf_add_test_case startstop }
CVS commit: src/tests/usr.bin/ld
Module Name:src Committed By: uebayasi Date: Fri Nov 14 16:29:03 UTC 2014 Modified Files: src/tests/usr.bin/ld: t_orphan.sh Log Message: Tweak previous. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/ld/t_orphan.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/ld/t_orphan.sh diff -u src/tests/usr.bin/ld/t_orphan.sh:1.1 src/tests/usr.bin/ld/t_orphan.sh:1.2 --- src/tests/usr.bin/ld/t_orphan.sh:1.1 Fri Nov 14 16:21:12 2014 +++ src/tests/usr.bin/ld/t_orphan.sh Fri Nov 14 16:29:03 2014 @@ -1,4 +1,4 @@ -# $NetBSD: t_orphan.sh,v 1.1 2014/11/14 16:21:12 uebayasi Exp $ +# $NetBSD: t_orphan.sh,v 1.2 2014/11/14 16:29:03 uebayasi Exp $ # # Copyright (c) 2014 The NetBSD Foundation, Inc. # All rights reserved. @@ -35,9 +35,9 @@ orphan_body() { cat test.c EOF #include sys/cdefs.h /* read-only orphan */ -const char a[] __section(hoge) = { 'h', 'o', 'g', 'e', '\0' }; +const char a[] __section(hoge) = hoge; /* read-write orphan */ -char b[] __section(fuga) = fuga; +char b[] __section(fuga) = { 'f', 'u', 'g', 'a', '\0' }; /* .data */ int c = 123; /* .bss */ @@ -46,27 +46,27 @@ int d = 0; int main(void) { return 0; } EOF atf_check -s exit:0 -o ignore -e ignore cc -o test test.c - readelf -S test readelf -S test | grep ' \.text\| hoge\| \.data\| fuga\| \.bss' test.secs { # Read-only orphan sections are placed after well-known - # read-only sections (.text, .rodata) but before .data - read line match $line .text - read line match $line hoge + # read-only sections (.text, .rodata) but before .data. + match .text + match hoge # Read-write orphan sections are placed after well-known - # read-write sections (.data) but before .bss - read line match $line .data - read line match $line fuga - read line match $line .bss + # read-write sections (.data) but before .bss. + match .data + match fuga + match .bss : } test.secs atf_check test $? -eq 0 } match() { - case $1 in - *$2*) return 0; + read line + case $line in + *$1*) return 0; esac return 1 }
CVS commit: src/tests/usr.bin/ld
Module Name:src Committed By: uebayasi Date: Sat Nov 15 03:10:01 UTC 2014 Modified Files: src/tests/usr.bin/ld: t_script.sh Log Message: Tweak. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/ld/t_script.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/ld/t_script.sh diff -u src/tests/usr.bin/ld/t_script.sh:1.1 src/tests/usr.bin/ld/t_script.sh:1.2 --- src/tests/usr.bin/ld/t_script.sh:1.1 Fri Nov 14 09:03:39 2014 +++ src/tests/usr.bin/ld/t_script.sh Sat Nov 15 03:10:01 2014 @@ -1,4 +1,4 @@ -# $NetBSD: t_script.sh,v 1.1 2014/11/14 09:03:39 uebayasi Exp $ +# $NetBSD: t_script.sh,v 1.2 2014/11/15 03:10:01 uebayasi Exp $ # # Copyright (c) 2014 The NetBSD Foundation, Inc. # All rights reserved. @@ -58,12 +58,9 @@ EOF ld -r -T test.x -Map test.map -o test.ro test.o extract_section_names test.ro test.secs extract_symbol_names test.ro test.syms - atf_check -s exit:1 -o ignore -e ignore \ - grep '\.data\.a$' test.secs - atf_check -s exit:1 -o ignore -e ignore \ - grep '\.data\.b$' test.secs - atf_check -s exit:0 -o ignore -e ignore \ - grep '\.data\.c$' test.secs + assert_nosec '\.data\.a' + assert_nosec '\.data\.b' + assert_sec '\.data\.c' } extract_section_names() { @@ -76,6 +73,16 @@ extract_symbol_names() { sed -e 's/^.* //' } +assert_sec() { + atf_check -s exit:0 -o ignore -e ignore \ + grep ^$1\$ test.secs +} + +assert_nosec() { + atf_check -s exit:1 -o ignore -e ignore \ + grep ^$1\$ test.secs +} + atf_init_test_cases() {
CVS commit: src/tests/usr.bin/ld
Module Name:src Committed By: uebayasi Date: Sat Nov 15 03:23:12 UTC 2014 Modified Files: src/tests/usr.bin/ld: Makefile Log Message: Merge tests. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/ld/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/ld/Makefile diff -u src/tests/usr.bin/ld/Makefile:1.3 src/tests/usr.bin/ld/Makefile:1.4 --- src/tests/usr.bin/ld/Makefile:1.3 Fri Nov 14 16:21:12 2014 +++ src/tests/usr.bin/ld/Makefile Sat Nov 15 03:23:11 2014 @@ -1,11 +1,10 @@ -# $NetBSD: Makefile,v 1.3 2014/11/14 16:21:12 uebayasi Exp $ +# $NetBSD: Makefile,v 1.4 2014/11/15 03:23:11 uebayasi Exp $ .include bsd.own.mk TESTSDIR= ${TESTSBASE}/usr.bin/ld -TESTS_SH= t_orphan \ - t_script \ +TESTS_SH= t_script \ t_section .include bsd.test.mk
CVS commit: src/tests/usr.bin/ld
Module Name:src Committed By: uebayasi Date: Sat Nov 15 03:47:29 UTC 2014 Modified Files: src/tests/usr.bin/ld: t_script.sh Log Message: Test object ordering. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/ld/t_script.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/ld/t_script.sh diff -u src/tests/usr.bin/ld/t_script.sh:1.2 src/tests/usr.bin/ld/t_script.sh:1.3 --- src/tests/usr.bin/ld/t_script.sh:1.2 Sat Nov 15 03:10:01 2014 +++ src/tests/usr.bin/ld/t_script.sh Sat Nov 15 03:47:29 2014 @@ -1,4 +1,4 @@ -# $NetBSD: t_script.sh,v 1.2 2014/11/15 03:10:01 uebayasi Exp $ +# $NetBSD: t_script.sh,v 1.3 2014/11/15 03:47:29 uebayasi Exp $ # # Copyright (c) 2014 The NetBSD Foundation, Inc. # All rights reserved. @@ -25,6 +25,40 @@ # POSSIBILITY OF SUCH DAMAGE. # + + +atf_test_case order +order_head() { + atf_set descr check if object ordering work + atf_set require.progs cc ld readelf nm sed grep +} + +order_body() { + for i in a b c; do + cat $i.c EOF +#include sys/cdefs.h +char $i __section(.data.$i) = '$i'; +EOF + done + cat test.c EOF +int main(void) { return 0; } +EOF + # c - b - a + atf_check -s exit:0 -o ignore -e ignore \ + cc -o test test.c c.c b.c a.c + extract_symbol_names test | + grep '^[abc]$' test.syms + { + match c + match b + match a + : + } test.syms + atf_check test $? -eq 0 +} + + + atf_test_case multisec multisec_head() { atf_set descr check if multiple SECTIONS commands work @@ -63,6 +97,8 @@ EOF assert_sec '\.data\.c' } + + extract_section_names() { readelf -S $1 | sed -ne '/\] \./ { s/^.*\] //; s/ .*$//; p }' @@ -73,6 +109,14 @@ extract_symbol_names() { sed -e 's/^.* //' } +match() { + read line + case $line in + *$1*) return 0; + esac + return 1 +} + assert_sec() { atf_check -s exit:0 -o ignore -e ignore \ grep ^$1\$ test.secs @@ -83,8 +127,10 @@ assert_nosec() { grep ^$1\$ test.secs } + + atf_init_test_cases() { - + atf_add_test_case order atf_add_test_case multisec }
CVS commit: src/tests/usr.bin/ld
Module Name:src Committed By: uebayasi Date: Sat Nov 15 04:23:49 UTC 2014 Modified Files: src/tests/usr.bin/ld: t_script.sh Log Message: Test object reordering by script. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/ld/t_script.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/ld/t_script.sh diff -u src/tests/usr.bin/ld/t_script.sh:1.3 src/tests/usr.bin/ld/t_script.sh:1.4 --- src/tests/usr.bin/ld/t_script.sh:1.3 Sat Nov 15 03:47:29 2014 +++ src/tests/usr.bin/ld/t_script.sh Sat Nov 15 04:23:48 2014 @@ -1,4 +1,4 @@ -# $NetBSD: t_script.sh,v 1.3 2014/11/15 03:47:29 uebayasi Exp $ +# $NetBSD: t_script.sh,v 1.4 2014/11/15 04:23:48 uebayasi Exp $ # # Copyright (c) 2014 The NetBSD Foundation, Inc. # All rights reserved. @@ -27,34 +27,63 @@ -atf_test_case order -order_head() { - atf_set descr check if object ordering work +atf_test_case order_default +order_default_head() { + atf_set descr check if default object ordering works atf_set require.progs cc ld readelf nm sed grep } -order_body() { - for i in a b c; do - cat $i.c EOF -#include sys/cdefs.h -char $i __section(.data.$i) = '$i'; +order_default_body() { + order_compile + cat test.x EOF +SECTIONS { + /* do nothing */ +} EOF - done - cat test.c EOF -int main(void) { return 0; } + order_assert_descending +} + + + +atf_test_case order_merge +order_merge_head() { + atf_set descr check if glob merge doesn't change ordering + atf_set require.progs cc ld readelf nm sed grep +} + +order_merge_body() { + order_compile + cat test.x EOF +SECTIONS { + .data : { + *(.data .data.*) + } +} EOF - # c - b - a - atf_check -s exit:0 -o ignore -e ignore \ - cc -o test test.c c.c b.c a.c - extract_symbol_names test | - grep '^[abc]$' test.syms - { - match c - match b - match a - : - } test.syms - atf_check test $? -eq 0 + order_assert_descending +} + + + +atf_test_case reorder +reorder_head() { + atf_set descr check if reordering works + atf_set require.progs cc ld readelf nm sed grep +} + +reorder_body() { + order_compile + cat test.x EOF +SECTIONS { + .data : { + *(.data) + *(.data.a) + *(.data.b) + *(.data.c) + } +} +EOF + order_assert_ascending } @@ -99,6 +128,45 @@ EOF +order_compile() { + for i in a b c; do + cat $i.c EOF +#include sys/cdefs.h +char $i __section(.data.$i) = '$i'; +EOF + atf_check -s exit:0 -o ignore -e ignore cc -c $i.c + done + cat test.c EOF +int main(void) { return 0; } +EOF + atf_check -s exit:0 -o ignore -e ignore cc -c test.c +} + +order_link() { + atf_check -s exit:0 -o ignore -e ignore \ + ld -r -T test.x -Map test.map -o x.o c.o b.o a.o + atf_check -s exit:0 -o ignore -e ignore \ + cc -o test test.o x.o + extract_symbol_names test | + grep '^[abc]$' test.syms +} + +order_assert_ascending() { + order_assert_order a b c +} + +order_assert_descending() { + order_assert_order c b a +} + +order_assert_order() { + order_link + { + match $1 match $2 match $3 + } test.syms + atf_check test $? -eq 0 +} + extract_section_names() { readelf -S $1 | sed -ne '/\] \./ { s/^.*\] //; s/ .*$//; p }' @@ -131,6 +199,8 @@ assert_nosec() { atf_init_test_cases() { - atf_add_test_case order + atf_add_test_case order_default + atf_add_test_case order_merge + atf_add_test_case reorder atf_add_test_case multisec }
CVS commit: src/tests/usr.bin/ld
Module Name:src Committed By: uebayasi Date: Sat Nov 15 04:47:11 UTC 2014 Modified Files: src/tests/usr.bin/ld: t_script.sh Log Message: Tweaks. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/ld/t_script.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/ld/t_script.sh diff -u src/tests/usr.bin/ld/t_script.sh:1.4 src/tests/usr.bin/ld/t_script.sh:1.5 --- src/tests/usr.bin/ld/t_script.sh:1.4 Sat Nov 15 04:23:48 2014 +++ src/tests/usr.bin/ld/t_script.sh Sat Nov 15 04:47:11 2014 @@ -1,4 +1,4 @@ -# $NetBSD: t_script.sh,v 1.4 2014/11/15 04:23:48 uebayasi Exp $ +# $NetBSD: t_script.sh,v 1.5 2014/11/15 04:47:11 uebayasi Exp $ # # Copyright (c) 2014 The NetBSD Foundation, Inc. # All rights reserved. @@ -34,7 +34,6 @@ order_default_head() { } order_default_body() { - order_compile cat test.x EOF SECTIONS { /* do nothing */ @@ -47,12 +46,11 @@ EOF atf_test_case order_merge order_merge_head() { - atf_set descr check if glob merge doesn't change ordering + atf_set descr check if glob merge keeps object ordering atf_set require.progs cc ld readelf nm sed grep } order_merge_body() { - order_compile cat test.x EOF SECTIONS { .data : { @@ -67,12 +65,11 @@ EOF atf_test_case reorder reorder_head() { - atf_set descr check if reordering works + atf_set descr check if object reordering works atf_set require.progs cc ld readelf nm sed grep } reorder_body() { - order_compile cat test.x EOF SECTIONS { .data : { @@ -128,6 +125,23 @@ EOF +order_assert_ascending() { + order_assert_order a b c +} + +order_assert_descending() { + order_assert_order c b a +} + +order_assert_order() { + order_compile + order_link + { + match $1 match $2 match $3 + } test.syms + atf_check test $? -eq 0 +} + order_compile() { for i in a b c; do cat $i.c EOF @@ -143,6 +157,7 @@ EOF } order_link() { + # c - b - a atf_check -s exit:0 -o ignore -e ignore \ ld -r -T test.x -Map test.map -o x.o c.o b.o a.o atf_check -s exit:0 -o ignore -e ignore \ @@ -151,22 +166,6 @@ order_link() { grep '^[abc]$' test.syms } -order_assert_ascending() { - order_assert_order a b c -} - -order_assert_descending() { - order_assert_order c b a -} - -order_assert_order() { - order_link - { - match $1 match $2 match $3 - } test.syms - atf_check test $? -eq 0 -} - extract_section_names() { readelf -S $1 | sed -ne '/\] \./ { s/^.*\] //; s/ .*$//; p }'