]> sigrok.org Git - libsigrok.git/commitdiff
driver_list: unbreak list of builtin drivers for LTO configurations
authorGerhard Sittig <redacted>
Tue, 3 Nov 2020 17:25:18 +0000 (18:25 +0100)
committerGerhard Sittig <redacted>
Thu, 5 Nov 2020 04:20:42 +0000 (05:20 +0100)
Check for the availability of the "no_reorder" linker attribute, which
keeps the list of builtin drivers in shape on LTO enabled build setups.
Keep backwards compatibility for platforms which lack support for the
"no_reorder" attribute. Phrase the implementation such that other
keywords as well as user provided external specs are possible.

This resolves bug #1433.

Submitted-By: Ivan Mironov <redacted>
src/driver_list_start.c
src/driver_list_stop.c
src/libsigrok-internal.h

index 7b6c7755c65f5ba5dceb8901d4e970b7b0b0e3ea..535e33122bc609b5a3bfb9f366eb5c563d6e853c 100644 (file)
@@ -28,6 +28,7 @@
  */
 
 SR_PRIV const struct sr_dev_driver *sr_driver_list__start[]
+       SR_DRIVER_LIST_NOREORDER
        __attribute__((section (SR_DRIVER_LIST_SECTION),
                       used, aligned(sizeof(struct sr_dev_driver *))))
   = { NULL /* Dummy item, as zero length arrays are not allowed by C99 */ };
index ff2c51de16e3f30748a4dbbaefcb345023c30580..eefda05595ea0360fc6855b09d6e1c726d29b3d7 100644 (file)
@@ -28,6 +28,7 @@
  */
 
 SR_PRIV const struct sr_dev_driver *sr_driver_list__stop[]
+       SR_DRIVER_LIST_NOREORDER
        __attribute__((section (SR_DRIVER_LIST_SECTION),
                       used, aligned(sizeof(struct sr_dev_driver *))))
   = { NULL /* Dummy item, as zero length arrays are not allowed by C99 */ };
index 98d1631e2f4a4a5d3b209f3e85446e464799ccc6..19fcccfdc1183674140f0a670783d74c5c7bc1d1 100644 (file)
@@ -967,6 +967,15 @@ static inline void write_dblle_inc(uint8_t **p, double x)
 #define SR_DRIVER_LIST_SECTION "__sr_driver_list"
 #endif
 
+#if !defined SR_DRIVER_LIST_NOREORDER && defined __has_attribute
+#if __has_attribute(no_reorder)
+#define SR_DRIVER_LIST_NOREORDER __attribute__((no_reorder))
+#endif
+#endif
+#if !defined SR_DRIVER_LIST_NOREORDER
+#define SR_DRIVER_LIST_NOREORDER /* EMPTY */
+#endif
+
 /**
  * Register a list of hardware drivers.
  *
@@ -996,6 +1005,7 @@ static inline void write_dblle_inc(uint8_t **p, double x)
  */
 #define SR_REGISTER_DEV_DRIVER_LIST(name, ...) \
        static const struct sr_dev_driver *name[] \
+               SR_DRIVER_LIST_NOREORDER \
                __attribute__((section (SR_DRIVER_LIST_SECTION), used, \
                        aligned(sizeof(struct sr_dev_driver *)))) \
                = { \