linux/tools/testing/selftests/nolibc/nolibc-test-linkage.c
Thomas Weißschuh b8c60e8fc6 selftests/nolibc: add tests for multi-object linkage
While uncommon, nolibc executables can be linked together from multiple
compilation units.
Add some tests to make sure everything works in that case.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/lkml/20231012-nolibc-linkage-test-v1-1-315e682768b4@weissschuh.net/
Acked-by: Willy Tarreau <w@1wt.eu>
2023-10-12 21:14:20 +02:00

27 lines
429 B
C

/* SPDX-License-Identifier: GPL-2.0 */
#include "nolibc-test-linkage.h"
#ifndef NOLIBC
#include <errno.h>
#endif
void *linkage_test_errno_addr(void)
{
return &errno;
}
int linkage_test_constructor_test_value;
__attribute__((constructor))
static void constructor1(void)
{
linkage_test_constructor_test_value = 2;
}
__attribute__((constructor))
static void constructor2(void)
{
linkage_test_constructor_test_value *= 3;
}