]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
* libltdl/libltdl/lt__private.h, libltdl/lt_error.c:
authorPeter Ekberg <peda@lysator.liu.se>
Sun, 25 Sep 2005 07:01:29 +0000 (07:01 +0000)
committerPeter Rosin <peda@lysator.liu.se>
Sun, 25 Sep 2005 07:01:29 +0000 (07:01 +0000)
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.

ChangeLog
libltdl/libltdl/lt__private.h
libltdl/libltdl/lt_error.h
libltdl/lt_error.c

index 0c92fbccda7122da4c0a5ace3d93cebe69502fc4..1ded344472425168d0d6952c4b4dc9d4d83573f1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,25 @@
+2005-09-25  Peter Ekberg  <peda@lysator.liu.se>
+
+       * 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 <Ralf.Wildenhues@gmx.de>
 
        * tests/link-order.at [ aix* ]: skip path syntax grep.
 
-2005-09-23  Peter Ekberg  <peda@lysator.liu.se>,
+2005-09-23  Peter Ekberg  <peda@lysator.liu.se>
 
        * 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  <peda@lysator.liu.se>,
+2005-09-22  Peter Ekberg  <peda@lysator.liu.se>
 
        * 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  <peda@lysator.liu.se>,
+2005-09-21  Peter Ekberg  <peda@lysator.liu.se>
 
        * 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  <peda@lysator.liu.se>,
+2005-09-20  Peter Ekberg  <peda@lysator.liu.se>
 
        * libltdl/m4/libtool.m4 (_LT_LINKER_SHLIBS, _LT_LANG_CXX_CONFIG):
        Split up --out-implib option for linker in separate args so that
        libltdl/libltdl/lt__private.h, libltdl/libltdl/lt__strl.h:
        Adjusted.
 
-2005-09-16  Peter Ekberg  <peda@lysator.liu.se>,
+2005-09-16  Peter Ekberg  <peda@lysator.liu.se>
 
        * tests/testsuite.at (LT_AT_EXEC_CHECK): Make sure
        that the exit status of the tested program is
index 9098f42412228392e69441b3a6f104a447af16dd..59c9450128a852e17c209829f915fe9835ffe6c1 100644 (file)
@@ -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
 
index 6cc53e7b51a16b5383d3431f8e704bb4908b04b5..8773770a493078897fcd53c09e7b6a70b7cbd245 100644 (file)
@@ -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);
index 245ae4b2d70ec910c96f78c7ca1aafb7dafc7a3e..e7de3c9a90b6e6039ed44e672ee5bf9aa6ec4caf 100644 (file)
@@ -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;
+}