Hi Peter, * Peter Rosin wrote on Mon, Jan 25, 2010 at 04:12:47PM CET: > As promised, here's a testsuite addition for the dlloader API.
Thank you! > 2010-01-25 Peter Rosin <p...@lysator.liu.se> > > Testsuite exposure for dlloader API. > * tests/dlloader-api.at: New file, new test. > * Makefile.am (TESTSUITE_AT): Update. So far I've only take a cursory look: > +static lt_module > +first_open (lt_user_data data, const char *filename, lt_dladvise advise) > +{ > + static char *first_module = "first"; This pointer should be const char *, it may point to read-only memory. There are several more instances that fail when using CC=g++. The patch below makes it pass in this case for me, please look over it that I haven't made any mistakes. The test fails for me when Libtool is configured with --disable-shared. I'm not sure that failure is specific to this test, whether we need to fix it before committing the test or so; looking at this is probably prudent. Thanks, Ralf diff --git a/tests/dlloader-api.at b/tests/dlloader-api.at index 25a01a9..e9b142e 100644 --- a/tests/dlloader-api.at +++ b/tests/dlloader-api.at @@ -42,7 +42,7 @@ first_init (lt_user_data data) static lt_module first_open (lt_user_data data, const char *filename, lt_dladvise advise) { - static char *first_module = "first"; + static const char *first_module = "first"; const char *ctx = (const char *)data; if (!filename || strcmp (filename, "first")) @@ -71,7 +71,7 @@ first_sym (lt_user_data data, lt_module module, const char *symbolname) printf ("first_sym (%s): %s\n", filename, ctx); - return first_symbol; + return (void *) first_symbol; } static int @@ -108,7 +108,7 @@ last_init (lt_user_data data) static lt_module last_open (lt_user_data data, const char *filename, lt_dladvise advise) { - static char *last_module = "last"; + static const char *last_module = "last"; const char *ctx = (const char *)data; if (!filename || strcmp (filename, "last")) @@ -137,7 +137,7 @@ last_sym (lt_user_data data, lt_module module, const char *symbolname) printf ("last_sym (%s): %s\n", filename, ctx); - return last_symbol; + return (void *) last_symbol; } static int @@ -169,10 +169,10 @@ main (int argc, char* argv[]) int err = 0; lt_dlvtable *first; lt_dlvtable *last; - lt_module module = NULL; + lt_dlhandle module = NULL; module_func *symbol; - char *first_ctx = "first_ctx"; - char *last_ctx = "last_ctx"; + const char *first_ctx = "first_ctx"; + const char *last_ctx = "last_ctx"; const lt_dlvtable *finder; if (lt_dlinit ()) @@ -181,7 +181,7 @@ main (int argc, char* argv[]) return 1; } - first = malloc (sizeof (*first)); + first = (lt_dlvtable *) malloc (sizeof (*first)); if (!first) { printf ("malloc failed\n"); @@ -196,7 +196,7 @@ main (int argc, char* argv[]) first->find_sym = first_sym; first->dlloader_init = first_init; /* test that it isn't called twice */ first->dlloader_exit = first_exit; - first->dlloader_data = first_ctx; + first->dlloader_data = (void *)first_ctx; first->priority = LT_DLLOADER_PREPEND; if (first_init (first->dlloader_data)) @@ -224,7 +224,7 @@ main (int argc, char* argv[]) printf ("Found loader \"%s\"\n", finder->name); - last = malloc (sizeof (*last)); + last = (lt_dlvtable *) malloc (sizeof (*last)); if (!last) { printf ("malloc failed\n"); @@ -239,7 +239,7 @@ main (int argc, char* argv[]) last->find_sym = last_sym; last->dlloader_init = last_init; /* test that it isn't called twice */ last->dlloader_exit = last_exit; - last->dlloader_data = last_ctx; + last->dlloader_data = (lt_user_data) last_ctx; last->priority = LT_DLLOADER_APPEND; if (last_init (last->dlloader_data)) @@ -276,7 +276,7 @@ main (int argc, char* argv[]) goto cleanup; } - symbol = lt_dlsym (module, "symbol"); + symbol = (module_func *) lt_dlsym (module, "symbol"); if (!symbol) { @@ -297,7 +297,7 @@ main (int argc, char* argv[]) goto cleanup; } - symbol = lt_dlsym (module, "symbol"); + symbol = (module_func *) lt_dlsym (module, "symbol"); if (!symbol) { @@ -318,7 +318,7 @@ main (int argc, char* argv[]) goto cleanup; } - symbol = lt_dlsym (module, "symbol"); + symbol = (module_func *) lt_dlsym (module, "symbol"); if (!symbol) { @@ -357,7 +357,13 @@ cleanup: AT_DATA([module.c], [[ +#ifdef __cplusplus +extern "C" +#endif const char *symbol (void); +#ifdef __cplusplus +extern "C" +#endif const char * symbol (void) {