From 07d14d4e3239188e4f0ee407d7ae3e49fc71741b Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Thu, 5 Sep 2013 13:47:18 +0800 Subject: Fix symbols which need underscore To some archs, the symbols are added a '_' prefix. we should handle it. --- main.c | 3 ++- rap.c | 15 ++++++++++++--- rtl.h | 11 +++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index a8f8640..892cfc6 100644 --- a/main.c +++ b/main.c @@ -47,6 +47,7 @@ int remote_debug; #endif +#include #include #include #include @@ -57,7 +58,7 @@ int remote_debug; * The tarfile is built automatically externally so we need to account * for the leading symbol on the names. */ -#if defined(__sh__) +#if (RTL_GLUE(__USER_LABEL_PREFIX__, 1) == RTL_GLUE(_, 1)) #define SYM(_x) _x #else #define SYM(_x) _ ## _x diff --git a/rap.c b/rap.c index 850d84a..7143629 100644 --- a/rap.c +++ b/rap.c @@ -61,6 +61,15 @@ typedef struct rtems_rap_app_s (RTEMS_PRIORITY | RTEMS_BINARY_SEMAPHORE | \ RTEMS_INHERIT_PRIORITY | RTEMS_NO_PRIORITY_CEILING | RTEMS_LOCAL) +/** + * RTL entry. + */ +#if (RTL_GLUE(__USER_LABEL_PREFIX__, 1) == RTL_GLUE(_, 1)) + #define RTL_ENTRY_POINT "_rtems" +#else + #define RTL_ENTRY_POINT "rtems" +#endif + /** * Static RAP data is returned to the user when the loader is locked. */ @@ -323,7 +332,7 @@ rtems_rap_load (const char* name, int mode, int argc, const char* argv[]) return false; } - init = dlsym (app->handle, "rtems"); + init = dlsym (app->handle, RTL_ENTRY_POINT); if (!init) { rtems_rap_get_rtl_error (); @@ -332,7 +341,7 @@ rtems_rap_load (const char* name, int mode, int argc, const char* argv[]) return false; } - fini = dlsym (app->handle, "rtems"); + fini = dlsym (app->handle, RTL_ENTRY_POINT); if (!fini) { rtems_rap_get_rtl_error (); @@ -375,7 +384,7 @@ rtems_rap_unload (const char* name) return false; } - fini = dlsym (app->handle, "rtems"); + fini = dlsym (app->handle, RTL_ENTRY_POINT); if (!fini) { rtems_rap_get_rtl_error (); diff --git a/rtl.h b/rtl.h index 82fa48a..a67396d 100644 --- a/rtl.h +++ b/rtl.h @@ -48,6 +48,17 @@ extern "C" { * specifing 'archive:object' format. For example 'libfoo.a:bar.o'. */ +/** + * Macros to glue two tokens. + */ +#ifdef __STDC__ +#define RTL_XGLUE(a,b) a##b +#else +#define RTL_XGLUE(a,b) a/**/b +#endif + +#define RTL_GLUE(a,b) RTL_XGLUE(a,b) + /** * The number of buckets in the global symbol table. */ -- cgit v1.2.3