[ccan] autodata problem

Rusty Russell rusty at rustcorp.com.au
Fri Mar 15 21:57:40 EST 2013


picca <picca at synchrotron-soleil.fr> writes:
> Hello, first thanks for your ccan project.
> It saves my days...
>
> I would like to ask a question about autodata
>
> I create a shared library which use this module with a code like this

Hmm, I never thought of trying to use autodata in a shared library!

When I try it here (32 bit x86 Ubuntu), I get:

/tmp/test/libfoo.so: file not recognised: Bad value

ie. the entire shared library is not recognised.

But it's really weird: any section name starting with 'a' fails
similarly.  An uninitialized variable works, but something about
relocations into such a section makes the linker really upset.

This is different from your problem, of course, but the following hack
fixed it for me...

diff --git a/ccan/autodata/autodata.h b/ccan/autodata/autodata.h
index c9d774b..3b1d01b 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 */
 
 /**


More information about the ccan mailing list