From: Peter Ekberg Date: Sun, 25 Sep 2005 07:01:29 +0000 (+0000) Subject: * libltdl/libltdl/lt__private.h, libltdl/lt_error.c: X-Git-Tag: release-2-1b~498 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b25bb1115a97ca4c2618cce74822949e14de396;p=thirdparty%2Flibtool.git * libltdl/libltdl/lt__private.h, libltdl/lt_error.c: Don't export the lt__last_error and lt__error_strings variables. Define lt__error_strings so that no relocations are needed. * libltdl/libltdl/lt__private.h (LT__STRERROR, LT__GETERROR) (LT__SETERRORSTR): Adjust to not use the above variables, instead use the following functions... * libltdl/lt_error.c: (lt__error_string, lt__get_last_error) (lt__set_last_error): Reimplement the functionality in these functions instead. * libltdl/libltdl/lt_error.h: Add LT_ERROR_LEN_MAX define for max error string length. (lt_dlerror_table): Append explicit nul terminators so that compilers warn more reliably if the above define is too small. --- diff --git a/ChangeLog b/ChangeLog index 0c92fbccd..1ded34447 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,25 @@ +2005-09-25 Peter Ekberg + + * libltdl/libltdl/lt__private.h, libltdl/lt_error.c: + Don't export the lt__last_error and lt__error_strings + variables. Define lt__error_strings so that no relocations + are needed. + * libltdl/libltdl/lt__private.h (LT__STRERROR, LT__GETERROR) + (LT__SETERRORSTR): Adjust to not use the above variables, + instead use the following functions... + * libltdl/lt_error.c: (lt__error_string, lt__get_last_error) + (lt__set_last_error): Reimplement the functionality in + these functions instead. + * libltdl/libltdl/lt_error.h: Add LT_ERROR_LEN_MAX define for + max error string length. + (lt_dlerror_table): Append explicit nul terminators so that + compilers warn more reliably if the above define is too small. + 2005-09-23 Ralf Wildenhues * tests/link-order.at [ aix* ]: skip path syntax grep. -2005-09-23 Peter Ekberg , +2005-09-23 Peter Ekberg * libltdl/m4/libtool.m4 (_LT_CMD_GLOBAL_SYMBOLS): Fix awk script to be a single line so that the cache variable isn't @@ -26,7 +43,7 @@ symbols. Fixes segfault in stresstest.at on Cygwin and makes the test pass. -2005-09-22 Peter Ekberg , +2005-09-22 Peter Ekberg * tests/link-order.test: Clean up the uninstalled libraries before linking the test executables so that they don't pick @@ -45,7 +62,7 @@ (_LT_LINKER_SHLIBS): Require _LT_TAG_COMPILER to make sure that $compiler is assigned. Fixes crippled configure output. -2005-09-21 Peter Ekberg , +2005-09-21 Peter Ekberg * libltdl/m4/libtool.m4 (LT_PATH_NM): Fix autodetection of dumpbin and also check for "link -dump -symbols" as a synonym @@ -56,7 +73,7 @@ library. Fixes -mode=clean on Cygwin and MinGW to actually remove the dll when cleaning up an uninstalled library. -2005-09-20 Peter Ekberg , +2005-09-20 Peter Ekberg * libltdl/m4/libtool.m4 (_LT_LINKER_SHLIBS, _LT_LANG_CXX_CONFIG): Split up --out-implib option for linker in separate args so that @@ -86,7 +103,7 @@ libltdl/libltdl/lt__private.h, libltdl/libltdl/lt__strl.h: Adjusted. -2005-09-16 Peter Ekberg , +2005-09-16 Peter Ekberg * tests/testsuite.at (LT_AT_EXEC_CHECK): Make sure that the exit status of the tested program is diff --git a/libltdl/libltdl/lt__private.h b/libltdl/libltdl/lt__private.h index 9098f4241..59c945012 100644 --- a/libltdl/libltdl/lt__private.h +++ b/libltdl/libltdl/lt__private.h @@ -122,15 +122,15 @@ struct lt__handle { /* Extract the diagnostic strings from the error table macro in the same order as the enumerated indices in lt_error.h. */ -LT_SCOPE const char *lt__error_strings[]; +#define LT__STRERROR(name) lt__error_string(LT_CONC(LT_ERROR_,name)) -#define LT__STRERROR(name) lt__error_strings[LT_CONC(LT_ERROR_,name)] - -#define LT__GETERROR(lvalue) (lvalue) = lt__last_error; -#define LT__SETERRORSTR(errormsg) lt__last_error = (errormsg) +#define LT__GETERROR(lvalue) (lvalue) = lt__get_last_error() +#define LT__SETERRORSTR(errormsg) lt__set_last_error(errormsg) #define LT__SETERROR(errorcode) LT__SETERRORSTR(LT__STRERROR(errorcode)) -LT_SCOPE const char *lt__last_error; +LT_SCOPE const char *lt__error_string (int errorcode); +LT_SCOPE const char *lt__get_last_error (void); +LT_SCOPE const char *lt__set_last_error (const char *errormsg); LT_END_C_DECLS diff --git a/libltdl/libltdl/lt_error.h b/libltdl/libltdl/lt_error.h index 6cc53e7b5..8773770a4 100644 --- a/libltdl/libltdl/lt_error.h +++ b/libltdl/libltdl/lt_error.h @@ -37,27 +37,28 @@ LT_BEGIN_C_DECLS /* Defining error strings alongside their symbolic names in a macro in this way allows us to expand the macro in different contexts with confidence that the enumeration of symbolic names will map correctly - onto the table of error strings. */ + onto the table of error strings. \0 is appended to the strings to + expilicitely initialize the string terminator. */ #define lt_dlerror_table \ - LT_ERROR(UNKNOWN, "unknown error") \ - LT_ERROR(DLOPEN_NOT_SUPPORTED, "dlopen support not available") \ - LT_ERROR(INVALID_LOADER, "invalid loader") \ - LT_ERROR(INIT_LOADER, "loader initialization failed") \ - LT_ERROR(REMOVE_LOADER, "loader removal failed") \ - LT_ERROR(FILE_NOT_FOUND, "file not found") \ - LT_ERROR(DEPLIB_NOT_FOUND, "dependency library not found") \ - LT_ERROR(NO_SYMBOLS, "no symbols defined") \ - LT_ERROR(CANNOT_OPEN, "can't open the module") \ - LT_ERROR(CANNOT_CLOSE, "can't close the module") \ - LT_ERROR(SYMBOL_NOT_FOUND, "symbol not found") \ - LT_ERROR(NO_MEMORY, "not enough memory") \ - LT_ERROR(INVALID_HANDLE, "invalid module handle") \ - LT_ERROR(BUFFER_OVERFLOW, "internal buffer overflow") \ - LT_ERROR(INVALID_ERRORCODE, "invalid errorcode") \ - LT_ERROR(SHUTDOWN, "library already shutdown") \ - LT_ERROR(CLOSE_RESIDENT_MODULE, "can't close resident module") \ - LT_ERROR(INVALID_MUTEX_ARGS, "internal error (code withdrawn)") \ - LT_ERROR(INVALID_POSITION, "invalid search path insert position") + LT_ERROR(UNKNOWN, "unknown error\0") \ + LT_ERROR(DLOPEN_NOT_SUPPORTED, "dlopen support not available\0") \ + LT_ERROR(INVALID_LOADER, "invalid loader\0") \ + LT_ERROR(INIT_LOADER, "loader initialization failed\0") \ + LT_ERROR(REMOVE_LOADER, "loader removal failed\0") \ + LT_ERROR(FILE_NOT_FOUND, "file not found\0") \ + LT_ERROR(DEPLIB_NOT_FOUND, "dependency library not found\0") \ + LT_ERROR(NO_SYMBOLS, "no symbols defined\0") \ + LT_ERROR(CANNOT_OPEN, "can't open the module\0") \ + LT_ERROR(CANNOT_CLOSE, "can't close the module\0") \ + LT_ERROR(SYMBOL_NOT_FOUND, "symbol not found\0") \ + LT_ERROR(NO_MEMORY, "not enough memory\0") \ + LT_ERROR(INVALID_HANDLE, "invalid module handle\0") \ + LT_ERROR(BUFFER_OVERFLOW, "internal buffer overflow\0") \ + LT_ERROR(INVALID_ERRORCODE, "invalid errorcode\0") \ + LT_ERROR(SHUTDOWN, "library already shutdown\0") \ + LT_ERROR(CLOSE_RESIDENT_MODULE, "can't close resident module\0") \ + LT_ERROR(INVALID_MUTEX_ARGS, "internal error (code withdrawn)\0")\ + LT_ERROR(INVALID_POSITION, "invalid search path insert position\0") /* Enumerate the symbolic error names. */ enum { @@ -68,6 +69,9 @@ enum { LT_ERROR_MAX }; +/* Should be max of the error string lengths above */ +#define LT_ERROR_LEN_MAX (35) + /* These functions are only useful from inside custom module loaders. */ LT_SCOPE int lt_dladderror (const char *diagnostic); LT_SCOPE int lt_dlseterror (int errorcode); diff --git a/libltdl/lt_error.c b/libltdl/lt_error.c index 245ae4b2d..e7de3c9a9 100644 --- a/libltdl/lt_error.c +++ b/libltdl/lt_error.c @@ -29,14 +29,12 @@ Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA #include "lt_error.h" #include "lt__private.h" -LT_GLOBAL_DATA const char *lt__last_error = 0; -LT_GLOBAL_DATA const char *lt__error_strings[] = +static const char *lt__last_error = 0; +static const char lt__error_strings[LT_ERROR_MAX][LT_ERROR_LEN_MAX + 1] = { #define LT_ERROR(name, diagnostic) (diagnostic), lt_dlerror_table #undef LT_ERROR - - 0 }; static const char **user_error_strings = 0; @@ -87,3 +85,24 @@ lt_dlseterror (int errindex) return errors; } + +const char * +lt__error_string (int errorcode) +{ + assert (errorcode >= 0); + assert (errorcode < LT_ERROR_MAX); + + return lt__error_strings[errorcode]; +} + +const char * +lt__get_last_error (void) +{ + return lt__last_error; +} + +const char * +lt__set_last_error (const char *errormsg) +{ + return lt__last_error = errormsg; +}