From 1cf60226627d300ec1f87a68a5c9c9981124c1bf Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sun, 17 Mar 2013 14:26:31 +1030 Subject: [PATCH] autodata: make note about not being generally useful for shared libraries. If you have sections, it might still work for some cases though: on x86 Ubuntu it worked once I changed the section name from autodata to xautodata. Signed-off-by: Rusty Russell --- ccan/autodata/_info | 3 +++ ccan/autodata/autodata.h | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ccan/autodata/_info b/ccan/autodata/_info index 11b6e16d..c9cf2663 100644 --- a/ccan/autodata/_info +++ b/ccan/autodata/_info @@ -8,6 +8,9 @@ * together at runtime to form tables. This is often used in place of * having a central registration function or table. * + * Note that this technique does not work in general for shared libaries, + * only for code compiled into a binary. + * * License: BSD-MIT * * Example: diff --git a/ccan/autodata/autodata.h b/ccan/autodata/autodata.h index c9d774b9..3b1d01b4 100644 --- a/ccan/autodata/autodata.h +++ b/ccan/autodata/autodata.h @@ -23,7 +23,7 @@ */ #define AUTODATA_TYPE(name, type) \ typedef type autodata_##name##_; \ - extern type *__start_autodata_##name[], *__stop_autodata_##name[] + extern type *__start_xautodata_##name[], *__stop_xautodata_##name[] /** * AUTODATA - add a pointer to this autodata set @@ -42,7 +42,7 @@ */ #define AUTODATA(name, ptr) \ static const autodata_##name##_ *NEEDED \ - __attribute__((section("autodata_" #name))) \ + __attribute__((section("xautodata_" #name))) \ AUTODATA_VAR_(name, __LINE__) = (ptr); /** @@ -68,8 +68,8 @@ */ #define autodata_get(name, nump) \ ((autodata_##name##_ **) \ - autodata_get_section(__start_autodata_##name, \ - __stop_autodata_##name, (nump))) + autodata_get_section(__start_xautodata_##name, \ + __stop_xautodata_##name, (nump))) #endif /* HAVE_SECTION_START_STOP */ /** -- 2.39.2