On some systems, lt_preloaded_symbols may not be declared const due to relocation issues. C99 requires qualification to match for compatible declarations, so ensure we declare const'ness in the same way everywhere; link-time optimization may otherwise rightfully complain about inconsistencies. Since ltdl.h may not depend upon config.h, rely on system defines for choosing const'ness.
* NEWS: Update. * doc/libtool.texi (Dlpreopening): Document this issue. * libltdl/config/ltmain.m4sh (func_generate_dlsyms): [__WINDOWS__, __CYGWIN__, _WIN32_WCE]: Define LT_DLSYM_CONST according to system defines. Remove old shell cruft. Use LT_DLSYM_CONST for lt_${my_prefix}_LTX_preloaded_symbols. * libltdl/libltdl/lt_system.h (LT_DLSYM_CONST): Likewise, define LT_DLSYM_CONST according to system defines. * tests/demo/foo.h (LT_DLSYM_CONST): Likewise. * tests/pdemo/foo.h (LT_DLSYM_CONST): Likewise. * tests/demo/dlmain.c (lt_dlsymlist): Use LT_DLSYM_CONST. * tests/pdemo/longer_file_name_dlmain.c (lt_dlsymlist): Likewise. * libltdl/m4/libtool.m4 (_LT_CMD_GLOBAL_SYMBOLS): Likewise for configure test code. * libltdl/ltdl.c (preloaded_symbols): Use LT_DLSYM_CONST. * libltdl/ltdl.h (LTDL_SET_PRELOADED_SYMBOLS): Likewise. Signed-off-by: Ralf Wildenhues <ralf.wildenh...@gmx.de> --- Hello, this patch addresses the const-ness of the symlist variable. I would like things to be consistent across ltmain, libtool.m4 (where we test symbol-pipe functionality), and ltdl.h, and since the latter can't depend on config.h, I guess the best bet is to hard-code using system defines. Question is whether *cygwin* | *mingw* | *cegcc* | *osf5* matches defined(__WINDOWS__) || defined(__CYGWIN__) || defined(_WIN32_WCE) defined(__osf__) well enough? OK to commit? Thanks, Ralf ChangeLog | 26 ++++++++++++++++++++++++++ NEWS | 3 +++ doc/libtool.texi | 3 +++ libltdl/config/ltmain.m4sh | 33 ++++++++++++++------------------- libltdl/libltdl/lt_system.h | 14 +++++++++++++- libltdl/ltdl.c | 2 +- libltdl/ltdl.h | 2 +- libltdl/m4/libtool.m4 | 14 +++++++++++++- tests/demo/dlmain.c | 2 +- tests/demo/foo.h | 14 +++++++++++++- tests/pdemo/foo.h | 14 +++++++++++++- tests/pdemo/longer_file_name_dlmain.c | 2 +- 12 files changed, 102 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index c082cee..245452b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,31 @@ 2010-04-04 Ralf Wildenhues <ralf.wildenh...@gmx.de> + Uniform const'ness of symlist variable lt_preloaded_symbols. + On some systems, lt_preloaded_symbols may not be declared + const due to relocation issues. C99 requires qualification to + match for compatible declarations, so ensure we declare + const'ness in the same way everywhere; link-time optimization + may otherwise rightfully complain about inconsistencies. + Since ltdl.h may not depend upon config.h, rely on system + defines for choosing const'ness. + * NEWS: Update. + * doc/libtool.texi (Dlpreopening): Document this issue. + * libltdl/config/ltmain.m4sh (func_generate_dlsyms): + [__WINDOWS__, __CYGWIN__, _WIN32_WCE]: Define LT_DLSYM_CONST + according to system defines. Remove old shell cruft. Use + LT_DLSYM_CONST for lt_${my_prefix}_LTX_preloaded_symbols. + * libltdl/libltdl/lt_system.h (LT_DLSYM_CONST): Likewise, + define LT_DLSYM_CONST according to system defines. + * tests/demo/foo.h (LT_DLSYM_CONST): Likewise. + * tests/pdemo/foo.h (LT_DLSYM_CONST): Likewise. + * tests/demo/dlmain.c (lt_dlsymlist): Use LT_DLSYM_CONST. + * tests/pdemo/longer_file_name_dlmain.c (lt_dlsymlist): + Likewise. + * libltdl/m4/libtool.m4 (_LT_CMD_GLOBAL_SYMBOLS): Likewise + for configure test code. + * libltdl/ltdl.c (preloaded_symbols): Use LT_DLSYM_CONST. + * libltdl/ltdl.h (LTDL_SET_PRELOADED_SYMBOLS): Likewise. + Fix incompatible struct declarations. * doc/libtool.texi (Dlpreopening): Remove broken documentation of lt_dlsymbol and lt_dlsymlist. Document typedef lt_dlsymlist diff --git a/NEWS b/NEWS index f220f28..1ffbf74 100644 --- a/NEWS +++ b/NEWS @@ -27,6 +27,9 @@ New in 2.2.8 2010-??-??: git version 2.2.7a, Libtool team: options that begin with '--lt-*' from the argument list before launching (uninstalled) programs. Any '--lt-*' option on the command line not recognized by the wrapper will result in an error. + - The type of the symbol lists variables (lt_*_LTX_preloaded_symbols) has + been fixed in the manual and in a couple of tests to match the actual + implementation. * Changes in supported systems or compilers: diff --git a/doc/libtool.texi b/doc/libtool.texi index f73f5a7..e5de075 100644 --- a/doc/libtool.texi +++ b/doc/libtool.texi @@ -3408,6 +3408,9 @@ The last element of all has a @var{name} and @var{address} of To facilitate inclusion of symbol lists into libraries, @code{lt_preloaded_symbols} is @samp{#define}d to a suitably unique name in @file{ltdl.h}. + +This variable may not be declared @code{const} on some systems due to +relocation issues. @end deftypevar Some compilers may allow identifiers that are not valid in ANSI C, such diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh index b4a23f6..c0082d1 100644 --- a/libltdl/config/ltmain.m4sh +++ b/libltdl/config/ltmain.m4sh @@ -1952,6 +1952,18 @@ extern \"C\" { #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" #endif +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ +#if defined(__WINDOWS__) || defined(__CYGWIN__) || defined(_WIN32_WCE) +/* DATA imports from DLLs on WIN32 con't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT_DLSYM_CONST +#elif defined(__osf__) +/* This system does not cope well with relocations in const data. */ +# define LT_DLSYM_CONST +#else +# define LT_DLSYM_CONST const +#endif + /* External symbol declarations for the compiler. */\ " @@ -2054,26 +2066,9 @@ typedef struct { const char *name; void *address; } lt_dlsymlist; -" - case $host in - *cygwin* | *mingw* | *cegcc* ) - echo >> "$output_objdir/$my_dlsyms" "\ -/* DATA imports from DLLs on WIN32 con't be const, because - runtime relocations are performed -- see ld's documentation - on pseudo-relocs. */" - lt_dlsym_const= ;; - *osf5*) - echo >> "$output_objdir/$my_dlsyms" "\ -/* This system does not cope well with relocations in const data */" - lt_dlsym_const= ;; - *) - lt_dlsym_const=const ;; - esac - - echo >> "$output_objdir/$my_dlsyms" "\ -extern $lt_dlsym_const lt_dlsymlist +extern LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[]; -$lt_dlsym_const lt_dlsymlist +LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = {\ { \"$my_originator\", (void *) 0 }," diff --git a/libltdl/libltdl/lt_system.h b/libltdl/libltdl/lt_system.h index dab2ab6..a8481d6 100644 --- a/libltdl/libltdl/lt_system.h +++ b/libltdl/libltdl/lt_system.h @@ -1,6 +1,6 @@ /* lt_system.h -- system portability abstraction layer - Copyright (C) 2004, 2007 Free Software Foundation, Inc. + Copyright (C) 2004, 2007, 2010 Free Software Foundation, Inc. Written by Gary V. Vaughan, 2004 NOTE: The canonical source of this file is maintained with the @@ -76,6 +76,18 @@ or obtained by writing to the Free Software Foundation, Inc., # endif #endif +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ +#if defined(__WINDOWS__) || defined(__CYGWIN__) || defined(_WIN32_WCE) +/* DATA imports from DLLs on WIN32 con't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT_DLSYM_CONST +#elif defined(__osf__) +/* This system does not cope well with relocations in const data. */ +# define LT_DLSYM_CONST +#else +# define LT_DLSYM_CONST const +#endif + /* Canonicalise Windows and Cygwin recognition macros. To match the values set by recent Cygwin compilers, make sure that if __CYGWIN__ is defined (after canonicalisation), __WINDOWS__ is NOT! */ diff --git a/libltdl/ltdl.c b/libltdl/ltdl.c index 4e1a402..87493f6 100644 --- a/libltdl/ltdl.c +++ b/libltdl/ltdl.c @@ -208,7 +208,7 @@ LT_BEGIN_C_DECLS LT_SCOPE const lt_dlvtable * get_vtable (lt_user_data data); LT_END_C_DECLS #ifdef HAVE_LIBDLLOADER -extern lt_dlsymlist preloaded_symbols[]; +extern LT_DLSYM_CONST lt_dlsymlist preloaded_symbols[]; #endif /* Initialize libltdl. */ diff --git a/libltdl/ltdl.h b/libltdl/ltdl.h index 8b516ad..5154da1 100644 --- a/libltdl/ltdl.h +++ b/libltdl/ltdl.h @@ -103,7 +103,7 @@ LT_SCOPE int lt_dlpreload_open (const char *originator, #define lt_preloaded_symbols lt__PROGRAM__LTX_preloaded_symbols #define LTDL_SET_PRELOADED_SYMBOLS() LT_STMT_START{ \ - extern const lt_dlsymlist lt_preloaded_symbols[]; \ + extern LT_DLSYM_CONST lt_dlsymlist lt_preloaded_symbols[]; \ lt_dlpreload_default(lt_preloaded_symbols); \ }LT_STMT_END diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4 index a946493..ef587b9 100644 --- a/libltdl/m4/libtool.m4 +++ b/libltdl/m4/libtool.m4 @@ -3468,6 +3468,18 @@ _LT_EOF if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ +#if defined(__WINDOWS__) || defined(__CYGWIN__) || defined(_WIN32_WCE) +/* DATA imports from DLLs on WIN32 con't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT@&t...@_dlsym_const +#elif defined(__osf__) +/* This system does not cope well with relocations in const data. */ +# define LT@&t...@_dlsym_const +#else +# define LT@&t...@_dlsym_const const +#endif + #ifdef __cplusplus extern "C" { #endif @@ -3479,7 +3491,7 @@ _LT_EOF cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ -const struct { +LT@&t...@_dlsym_const struct { const char *name; void *address; } diff --git a/tests/demo/dlmain.c b/tests/demo/dlmain.c index c970998..8c8be09 100644 --- a/tests/demo/dlmain.c +++ b/tests/demo/dlmain.c @@ -34,7 +34,7 @@ typedef struct lt_ptr_t address; } lt_dlsymlist; -extern const lt_dlsymlist lt_preloaded_symbols[]; +extern LT_DLSYM_CONST lt_dlsymlist lt_preloaded_symbols[]; int main () diff --git a/tests/demo/foo.h b/tests/demo/foo.h index 287f9c3..838264e 100644 --- a/tests/demo/foo.h +++ b/tests/demo/foo.h @@ -1,6 +1,6 @@ /* foo.h -- interface to the libfoo library - Copyright (C) 1996-1999 Free Software Foundation, Inc. + Copyright (C) 1996-1999, 2010 Free Software Foundation, Inc. Written by Gord Matzigkeit, 1996 This file is part of GNU Libtool. @@ -62,6 +62,18 @@ or obtained by writing to the Free Software Foundation, Inc., # define lt_ptr_t char* #endif +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ +#if defined(__WINDOWS__) || defined(__CYGWIN__) || defined(_WIN32_WCE) +/* DATA imports from DLLs on WIN32 con't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT_DLSYM_CONST +#elif defined(__osf__) +/* This system does not cope well with relocations in const data. */ +# define LT_DLSYM_CONST +#else +# define LT_DLSYM_CONST const +#endif + /* Silly constants that the functions return. */ #define HELLO_RET 0xe110 #define FOO_RET 0xf00 diff --git a/tests/pdemo/foo.h b/tests/pdemo/foo.h index f09db19..dd4e86d 100644 --- a/tests/pdemo/foo.h +++ b/tests/pdemo/foo.h @@ -1,6 +1,6 @@ /* foo.h -- interface to the libfoo library - Copyright (C) 1996-1999 Free Software Foundation, Inc. + Copyright (C) 1996-1999, 2010 Free Software Foundation, Inc. Written by Gord Matzigkeit, 1996 This file is part of GNU Libtool. @@ -61,6 +61,18 @@ or obtained by writing to the Free Software Foundation, Inc., # define lt_ptr_t char* #endif +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ +#if defined(__WINDOWS__) || defined(__CYGWIN__) || defined(_WIN32_WCE) +/* DATA imports from DLLs on WIN32 con't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT_DLSYM_CONST +#elif defined(__osf__) +/* This system does not cope well with relocations in const data. */ +# define LT_DLSYM_CONST +#else +# define LT_DLSYM_CONST const +#endif + #ifdef __CYGWIN32__ # ifdef LIBFOO_DLL /* need some (as yet non-existant) automake magic to tell diff --git a/tests/pdemo/longer_file_name_dlmain.c b/tests/pdemo/longer_file_name_dlmain.c index ef1e4c5..ad223dc 100644 --- a/tests/pdemo/longer_file_name_dlmain.c +++ b/tests/pdemo/longer_file_name_dlmain.c @@ -34,7 +34,7 @@ typedef struct lt_ptr_t address; } lt_dlsymlist; -extern const lt_dlsymlist lt_preloaded_symbols[]; +extern LT_DLSYM_CONST lt_dlsymlist lt_preloaded_symbols[]; int main (int argc, char **argv) -- 1.7.0.rc1.161.g90487