libbsd/test
Sam James b62f36f305 test: nlist: make resilient against -Wl,--gc-sections
With linker sections GC enabled, we get a test failure in `nlist.c`:
```
nlist: nlist.c:72: main: Assertion `rc == 0' failed.
```

This turns out to be because several sections used by the test can be discarded:
```
ld: removing unused section '.text.func_pub' in file 'nlist.o'
ld: removing unused section '.bss.data_pub_uninit' in file 'nlist.o'
ld: removing unused section '.data.data_pub_init' in file 'nlist.o'
```

Reproduced with `CFLAGS="-Og -fdata-sections -ffunction-sections"` and
`LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--gc-sections -Wl,-z,start-stop-gc"`.

Additionally, `LDFLAGS="... -Wl,--print-gc-sections"` can help with diagnosing
which sections get removed.

We already mark these symbols as `used`, but we need `retain` [0] for them
to survive linker GC too.

[0] https://releases.llvm.org/18.1.0/tools/lld/docs/ELF/start-stop-gc.html#annotate-c-identifier-name-sections

Closes: !29
Signed-off-by: Sam James <sam@gentoo.org>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
2024-03-14 09:33:34 +01:00
..
.gitignore Add explicit time32 and time64 support 2024-02-27 05:47:50 +01:00
arc4random.c test: Fix success return code for arc4random unit test 2016-01-11 02:35:34 +01:00
bzero.c test: Add proper prototypes for main() function 2021-02-28 05:30:31 +01:00
closefrom.c test: Close all descriptors before initializing them for closefrom() 2024-01-08 01:58:54 +01:00
endian.c test: Add proper prototypes for main() function 2021-02-28 05:30:31 +01:00
explicit_bzero.c test: Disable blank_stack_side_effects() on non-Hurd systems 2023-04-17 04:12:32 +02:00
fgetln.c test: Check that strdup() does not fail 2021-11-27 23:42:37 +01:00
fparseln.c test: Fix pipe_feed() to allow checking fprintf format strings 2021-11-27 05:06:14 +01:00
fpurge.c test: Use open_memstream() only if available 2023-04-17 04:12:42 +02:00
funopen.c test: Do not pass NULL as the first funopen() argument 2021-11-27 05:06:14 +01:00
headers-overlay.sh test: Do not use /dev/null as compiler output file 2023-04-18 01:09:05 +02:00
headers-system.sh test: Do not use /dev/null as compiler output file 2023-04-18 01:09:05 +02:00
humanize.c Fix dehumanize_number() to correctly detect overflows 2013-10-21 05:29:37 +02:00
Makefile.am Add explicit time32 and time64 support 2024-02-27 05:47:50 +01:00
md5.c test: Add proper prototypes for main() function 2021-02-28 05:30:31 +01:00
nlist.c test: nlist: make resilient against -Wl,--gc-sections 2024-03-14 09:33:34 +01:00
overlay.c build: On macOS do not build functions provided by the system 2023-04-17 04:12:42 +02:00
proctitle.c test: Check asprintf() return code 2015-11-30 23:48:50 +01:00
progname.c test: Handle libtool executable names in getprogname() unit test 2017-06-24 16:05:50 +02:00
pwcache.c test: Fix short-lived memory leak 2024-01-07 16:45:39 +01:00
setmode.c Update copyright claims 2021-02-07 01:28:27 +01:00
strl.c test: Add unit test for strlcpy() and strlcat() 2017-06-09 05:47:07 +02:00
strmode.c test: Add missing <sys/stat.h> include 2016-01-27 15:24:39 +01:00
strnstr.c test: Improve code coverage for strnstr(3) unit tests 2021-02-07 23:24:51 +01:00
strtonum.c test: Import explicit_bzero and strtonum test cases from OpenBSD 2022-01-29 14:54:24 +01:00
test-stream.c test: Fix pipe_feed() to allow checking fprintf format strings 2021-11-27 05:06:14 +01:00
test-stream.h test: Fix pipe_feed() to allow checking fprintf format strings 2021-11-27 05:06:14 +01:00
timeconv32.c Add explicit time32 and time64 support 2024-02-27 05:47:50 +01:00
timeconv64.c Add explicit time32 and time64 support 2024-02-27 05:47:50 +01:00
vis-openbsd.c Add support for new LIBBSD_VIS_OPENBSD selection macro 2021-02-07 02:03:22 +01:00
vis.c Fix strnvis() and strnunvis() NetBSD ABI break 2018-05-22 16:07:42 +02:00