sd-bus: set retain attribute on BUS_ERROR_MAP_ELF_REGISTER
authorFangrui Song <i@maskray.me>
Mon, 29 Mar 2021 06:35:06 +0000 (23:35 -0700)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 15 May 2021 17:24:29 +0000 (19:24 +0200)
commita360526852eadb2f14f5d4632771c3719a1c4dcf
treed18ebffac6e46b29998adeff483effdc1fe49224
parent1f2b3e1c07881b451b1c78ce299f6cc50f696973
sd-bus: set retain attribute on BUS_ERROR_MAP_ELF_REGISTER

LLD 13 and GNU ld 2.37 support -z start-stop-gc which allows garbage
collection of C identifier name sections despite the __start_/__stop_
references.  Simply set the retain attribute so that GCC 11 (if
configure-time binutils is 2.36 or newer)/Clang 13 will set the
SHF_GNU_RETAIN section attribute to prevent garbage collection.

Without the patch, there are linker errors like the following with -z
start-stop-gc.

```
ld: error: undefined symbol: __start_SYSTEMD_BUS_ERROR_MAP
>>> referenced by bus-error.c:93 (../src/libsystemd/sd-bus/bus-error.c:93)
>>>               sd-bus_bus-error.c.o:(bus_error_name_to_errno) in archive src/libsystemd/libsystemd_static.a
```

(cherry picked from commit 945317a4b69d33752c9513bb8994fe8d5a786ea6)
src/libsystemd/sd-bus/bus-error.h