File tree Expand file tree Collapse file tree 4 files changed +45
-6
lines changed
tools/testing/selftests/nolibc Expand file tree Collapse file tree 4 files changed +45
-6
lines changed Original file line number Diff line number Diff line change @@ -171,17 +171,17 @@ sysroot/$(ARCH)/include:
171
171
$(Q ) mv sysroot/sysroot sysroot/$(ARCH )
172
172
173
173
ifneq ($(NOLIBC_SYSROOT ) ,0)
174
- nolibc-test : nolibc-test.c sysroot/$(ARCH ) /include
174
+ nolibc-test : nolibc-test.c nolibc-test-linkage.c sysroot/$(ARCH ) /include
175
175
$(QUIET_CC )$(CC ) $(CFLAGS ) $(LDFLAGS ) -o $@ \
176
- -nostdlib -nostdinc -static -Isysroot/$(ARCH ) /include $< -lgcc
176
+ -nostdlib -nostdinc -static -Isysroot/$(ARCH ) /include nolibc-test.c nolibc-test-linkage.c -lgcc
177
177
else
178
- nolibc-test : nolibc-test.c
178
+ nolibc-test : nolibc-test.c nolibc-test-linkage.c
179
179
$(QUIET_CC )$(CC ) $(CFLAGS ) $(LDFLAGS ) -o $@ \
180
- -nostdlib -static -include ../../../include/nolibc/nolibc.h $< -lgcc
180
+ -nostdlib -static -include ../../../include/nolibc/nolibc.h nolibc-test.c nolibc-test-linkage.c -lgcc
181
181
endif
182
182
183
- libc-test : nolibc-test.c
184
- $(QUIET_CC )$(HOSTCC ) -o $@ $<
183
+ libc-test : nolibc-test.c nolibc-test-linkage.c
184
+ $(QUIET_CC )$(HOSTCC ) -o $@ nolibc-test.c nolibc-test-linkage.c
185
185
186
186
# local libc-test
187
187
run-libc-test : libc-test
Original file line number Diff line number Diff line change
1
+ /* SPDX-License-Identifier: GPL-2.0 */
2
+
3
+ #include "nolibc-test-linkage.h"
4
+
5
+ #ifndef NOLIBC
6
+ #include <errno.h>
7
+ #endif
8
+
9
+ void * linkage_test_errno_addr (void )
10
+ {
11
+ return & errno ;
12
+ }
13
+
14
+ int linkage_test_constructor_test_value ;
15
+
16
+ __attribute__((constructor ))
17
+ static void constructor1 (void )
18
+ {
19
+ linkage_test_constructor_test_value = 2 ;
20
+ }
21
+
22
+ __attribute__((constructor ))
23
+ static void constructor2 (void )
24
+ {
25
+ linkage_test_constructor_test_value *= 3 ;
26
+ }
Original file line number Diff line number Diff line change
1
+ /* SPDX-License-Identifier: GPL-2.0 */
2
+
3
+ #ifndef _NOLIBC_TEST_LINKAGE_H
4
+ #define _NOLIBC_TEST_LINKAGE_H
5
+
6
+ void * linkage_test_errno_addr (void );
7
+ extern int linkage_test_constructor_test_value ;
8
+
9
+ #endif /* _NOLIBC_TEST_LINKAGE_H */
Original file line number Diff line number Diff line change 41
41
#endif
42
42
#endif
43
43
44
+ #include "nolibc-test-linkage.h"
45
+
44
46
/* for the type of int_fast16_t and int_fast32_t, musl differs from glibc and nolibc */
45
47
#define SINT_MAX_OF_TYPE (type ) (((type)1 << (sizeof(type) * 8 - 2)) - (type)1 + ((type)1 << (sizeof(type) * 8 - 2)))
46
48
#define SINT_MIN_OF_TYPE (type ) (-SINT_MAX_OF_TYPE(type) - 1)
@@ -647,6 +649,8 @@ int run_startup(int min, int max)
647
649
CASE_TEST (auxv_addr ); EXPECT_PTRGT (test_auxv != (void * )-1 , test_auxv , brk ); break ;
648
650
CASE_TEST (auxv_AT_UID ); EXPECT_EQ (1 , getauxval (AT_UID ), getuid ()); break ;
649
651
CASE_TEST (constructor ); EXPECT_EQ (1 , constructor_test_value , 2 ); break ;
652
+ CASE_TEST (linkage_errno ); EXPECT_PTREQ (1 , linkage_test_errno_addr (), & errno ); break ;
653
+ CASE_TEST (linkage_constr ); EXPECT_EQ (1 , linkage_test_constructor_test_value , 6 ); break ;
650
654
case __LINE__ :
651
655
return ret ; /* must be last */
652
656
/* note: do not set any defaults so as to permit holes above */
You can’t perform that action at this time.
0 commit comments