Module: xenomai-3
Branch: stable-3.0.x
Commit: 0129217e7a8b1df94ae50baa72a4eac047121060
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=0129217e7a8b1df94ae50baa72a4eac047121060

Author: Philippe Gerum <r...@xenomai.org>
Date:   Thu Jan 26 15:04:37 2017 +0100

lib/boilerplate: bootstrap: fix Blackfin build

The bootstrap module object is built in two forms:

- in static object form, to be glued to the main executable, which
  should include a wrapper interposing on the main() routine for
  auto-init purpose. Such wrapper is activated when symbol wrapping is
  enabled at link time (--wrap).

- in dynamic object form, to be included in a shared library target
  which enables the auto-init feature. This form should not include
  any wrapper to a main() routine - which does not exist - but only a
  constructor routine performing the inits.

The FDPIC format is used for building static and dynamic objects on
the Blackfin architecture, for which GCC defines __PIC__ in both
cases. This prevents from testing __PIC__ as a way to differentiate
between the static and dynamic versions of the bootstrap module on
Blackfin.

To fix this, set and check for a dedicated macro (__INTERCEPT_MAIN__)
to figure out whether the main() interception code should be present
in the relocatable object.

---

 lib/boilerplate/init/Makefile.am |    1 +
 lib/boilerplate/init/bootstrap.c |   21 +++++++++++++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/lib/boilerplate/init/Makefile.am b/lib/boilerplate/init/Makefile.am
index f41f419..702c900 100644
--- a/lib/boilerplate/init/Makefile.am
+++ b/lib/boilerplate/init/Makefile.am
@@ -3,6 +3,7 @@ noinst_LIBRARIES = libbootstrap.a
 libbootstrap_a_SOURCES = bootstrap.c
 
 libbootstrap_a_CPPFLAGS =              \
+       -D__INTERCEPT_MAIN__            \
        @XENO_USER_CFLAGS@              \
        -I$(top_srcdir)/include         \
        -I$(top_srcdir)/lib
diff --git a/lib/boilerplate/init/bootstrap.c b/lib/boilerplate/init/bootstrap.c
index b0d4a12..118f861 100644
--- a/lib/boilerplate/init/bootstrap.c
+++ b/lib/boilerplate/init/bootstrap.c
@@ -28,7 +28,24 @@ static char *const *early_argv;
 
 const int xenomai_auto_bootstrap = 1;
 
-#ifndef __PIC__
+/*
+ * The bootstrap module object is built in two forms:
+ *
+ * - in static object form, to be glued to the main executable, which
+ *   should include a wrapper interposing on the main() routine for
+ *   auto-init purpose. Such wrapper is activated when symbol wrapping
+ *   is enabled at link time (--wrap).
+ *    
+ * - in dynamic object form, to be included in a shared library target
+ *   which enables the auto-init feature. This form should not include
+ *   any wrapper to a main() routine - which does not exist - but only
+ *   a constructor routine performing the inits.
+ *
+ * The dedicated macro __INTERCEPT_MAIN__ tells us whether the main()
+ * interception code should be present in the relocatable object.
+ */
+
+#ifdef __INTERCEPT_MAIN__
 
 int __real_main(int argc, char *const argv[]);
 
@@ -45,7 +62,7 @@ int xenomai_main(int argc, char *const argv[])
        return __real_main(argc, argv);
 }
 
-#endif /* !__PIC__ */
+#endif /* !__INTERCEPT_MAIN__ */
 
 __bootstrap_ctor static void xenomai_bootstrap(void)
 {


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to