diff --git a/contrib/netbsd-tests/lib/libc/string/t_strcpy.c b/contrib/netbsd-tests/lib/libc/string/t_strcpy.c --- a/contrib/netbsd-tests/lib/libc/string/t_strcpy.c +++ b/contrib/netbsd-tests/lib/libc/string/t_strcpy.c @@ -2,6 +2,10 @@ /* * Written by J.T. Conklin + * + * Portions of this software were developed by Robert Clausecker + * under sponsorship from the FreeBSD Foundation. + * * Public domain. */ @@ -10,6 +14,9 @@ #include #include #include +#include + +char * (*volatile strcpy_fn)(char *restrict, const char *restrict); ATF_TC(strcpy_basic); ATF_TC_HEAD(strcpy_basic, tc) @@ -19,12 +26,10 @@ ATF_TC_BODY(strcpy_basic, tc) { - /* try to trick the compiler */ - char * (*f)(char *, const char *s) = strcpy; - + void *dl_handle; unsigned int a0, a1, t; - char buf0[64]; - char buf1[64]; + char buf0[128]; + char buf1[128]; char *ret; struct tab { @@ -38,30 +43,38 @@ * trailing unaligned characters (on a 64 bit processor) */ - { "", 0 }, - { "a", 1 }, - { "ab", 2 }, - { "abc", 3 }, - { "abcd", 4 }, - { "abcde", 5 }, - { "abcdef", 6 }, - { "abcdefg", 7 }, - { "abcdefgh", 8 }, - { "abcdefghi", 9 }, - { "abcdefghij", 10 }, - { "abcdefghijk", 11 }, - { "abcdefghijkl", 12 }, - { "abcdefghijklm", 13 }, - { "abcdefghijklmn", 14 }, - { "abcdefghijklmno", 15 }, - { "abcdefghijklmnop", 16 }, - { "abcdefghijklmnopq", 17 }, - { "abcdefghijklmnopqr", 18 }, - { "abcdefghijklmnopqrs", 19 }, - { "abcdefghijklmnopqrst", 20 }, - { "abcdefghijklmnopqrstu", 21 }, - { "abcdefghijklmnopqrstuv", 22 }, - { "abcdefghijklmnopqrstuvw", 23 }, + { "", 0 }, + { "a", 1 }, + { "ab", 2 }, + { "abc", 3 }, + { "abcd", 4 }, + { "abcde", 5 }, + { "abcdef", 6 }, + { "abcdefg", 7 }, + { "abcdefgh", 8 }, + { "abcdefghi", 9 }, + { "abcdefghij", 10 }, + { "abcdefghijk", 11 }, + { "abcdefghijkl", 12 }, + { "abcdefghijklm", 13 }, + { "abcdefghijklmn", 14 }, + { "abcdefghijklmno", 15 }, + { "abcdefghijklmnop", 16 }, + { "abcdefghijklmnopq", 17 }, + { "abcdefghijklmnopqr", 18 }, + { "abcdefghijklmnopqrs", 19 }, + { "abcdefghijklmnopqrst", 20 }, + { "abcdefghijklmnopqrstu", 21 }, + { "abcdefghijklmnopqrstuv", 22 }, + { "abcdefghijklmnopqrstuvw", 23 }, + { "abcdefghijklmnopqrstuvwx", 24 }, + { "abcdefghijklmnopqrstuvwxy", 25 }, + { "abcdefghijklmnopqrstuvwxyz", 26 }, + { "abcdefghijklmnopqrstuvwxyz0", 27 }, + { "abcdefghijklmnopqrstuvwxyz01", 28 }, + { "abcdefghijklmnopqrstuvwxyz012", 29 }, + { "abcdefghijklmnopqrstuvwxyz0123", 30 }, + { "abcdefghijklmnopqrstuvwxyz01234", 31 }, /* * patterns that check for the cases where the expression: @@ -83,12 +96,17 @@ { "abcdefgh" "\xff\xff\xff\xff\xff\xff\xff\xff" "", 16 }, }; - for (a0 = 0; a0 < sizeof(long); ++a0) { + dl_handle = dlopen(NULL, RTLD_LAZY); + strcpy_fn = dlsym(dl_handle, "test_strcpy"); + if (!strcpy_fn) + strcpy_fn = strcpy; + + for (a0 = 0; a0 < 16; ++a0) { for (a1 = 0; a1 < sizeof(long); ++a1) { for (t = 0; t < (sizeof(tab) / sizeof(tab[0])); ++t) { memcpy(&buf1[a1], tab[t].val, tab[t].len + 1); - ret = f(&buf0[a0], &buf1[a1]); + ret = strcpy_fn(&buf0[a0], &buf1[a1]); /* * verify strcpy returns address of