https://lists.sr.ht/~emersion/public-inbox/%3CCANvPQf_5qOdfbe4Tk029yVB6BHipmYfQnuuCVoTUv3N%3D2f8jfw%40mail.gmail.com%3E
https://github.com/systemd/systemd/commit/945317a4b69d33752c9513bb8994fe8d5a786ea6

--- src/libsystemd/sd-bus/bus-error.h.orig	2021-01-06 13:56:51 UTC
+++ src/libsystemd/sd-bus/bus-error.h
@@ -28,11 +28,17 @@ int bus_error_set_errnofv(sd_bus_error *e, int error, 
  * the bus error table, and BUS_ERROR_MAP_ELF_USE has to be used at
  * least once per compilation unit (i.e. per library), to ensure that
  * the error map is really added to the final binary.
+ *
+ * In addition, set the retain attribute so that the section cannot be
+ * discarded by ld --gc-sections -z start-stop-gc. Older compilers would
+ * warn for the unknown attribute, so just disable -Wattributes.
  */
 
 #define BUS_ERROR_MAP_ELF_REGISTER                                      \
+        _Pragma("GCC diagnostic ignored \"-Wattributes\"")              \
         __attribute__ ((__section__("BUS_ERROR_MAP")))                  \
         __attribute__ ((__used__))                                      \
+        __attribute__ ((retain))                                        \
         __attribute__ ((aligned(8)))
 
 #define BUS_ERROR_MAP_ELF_USE(errors)                                   \
