From: Gary V. Vaughan Date: Wed, 1 Sep 2004 01:22:26 +0000 (+0000) Subject: Don't use C99 flexible array types as we want to be C89 X-Git-Tag: release-1-9d~85 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=53f09b2d9826eeb11fafd09540ee072c81067bab;p=thirdparty%2Flibtool.git Don't use C99 flexible array types as we want to be C89 compatible. Instead, revert to the old way of doing things with an array of symbol name vs. address, and adding the originator as the first symbol but with a NULL address: * config/ltmain.in (func_extract_dlsyms): Store originator as a NULL address symbol. * libltdl/ltdl.h (lt_dlsymbol): Removed. (lt_dlsymlist): Remove originator field. (LTDL_SET_PRELOADED_SYMBOLS): Adjust. * libltdl/loaders/preopen.c (vm_open, lt_dlpreload_open): Adjust for new types. (vm_sym): Skip the new originator symbol when scanning symbol names. * m4/libtool.m4 (_LT_CMD_GLOBAL_SYMBOLS): Adjust preloaded symbols test file to match. * NEWS: Updated. --- diff --git a/ChangeLog b/ChangeLog index bae003b8a..ca95eba4a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2004-09-01 Gary V. Vaughan + + Don't use C99 flexible array types as we want to be C89 + compatible. Instead, revert to the old way of doing things with + an array of symbol name vs. address, and adding the originator as + the first symbol but with a NULL address: + + * config/ltmain.in (func_extract_dlsyms): Store originator as a + NULL address symbol. + * libltdl/ltdl.h (lt_dlsymbol): Removed. + (lt_dlsymlist): Remove originator field. + (LTDL_SET_PRELOADED_SYMBOLS): Adjust. + * libltdl/loaders/preopen.c (vm_open, lt_dlpreload_open): Adjust + for new types. + (vm_sym): Skip the new originator symbol when scanning symbol + names. + * m4/libtool.m4 (_LT_CMD_GLOBAL_SYMBOLS): Adjust preloaded symbols + test file to match. + * NEWS: Updated. + 2004-09-01 Gary V. Vaughan Libtool currently assumes that certain characteristics, such as diff --git a/NEWS b/NEWS index 343a23d1c..272475a1c 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,8 @@ NEWS - list of user-visible changes between releases of GNU Libtool New in 1.9d: 2004-??-??; CVS version 1.9c, Libtool team: * Return type of lt_dlloader_remove is no longer `const'. +* libltdl is C89 compatible again. lt_dlsymbol type removed, and lt_dlsymlist + structure changed to avoid using C99 flexible arrays. New in 1.9b: 2004-08-29; CVS version 1.5a, Libtool team: * The /^_?LT_[A-Z_]+$/ namespace is now reserved for Libtool's own macros. diff --git a/config/ltmain.in b/config/ltmain.in index ba9c09b57..29395ac4f 100644 --- a/config/ltmain.in +++ b/config/ltmain.in @@ -962,23 +962,18 @@ extern \"C\" { /* The mapping between symbol names and symbols. */ const struct { - const char *originator; - const struct { - const char *name; - void *address; - } symbols[]; + const char *name; + void *address; } -lt_${my_prefix}_LTX_preloaded_symbols = +lt_${my_prefix}_LTX_preloaded_symbols[] = {\ - \"$my_originator\", - { + { \"$my_originator\", (void *) 0 }, " eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" $echo >> "$output_objdir/$my_dlsyms" "\ {0, (void *) 0} - } }; /* This works around a problem in FreeBSD linker */ diff --git a/libltdl/loaders/preopen.c b/libltdl/loaders/preopen.c index 958c5a4e3..a9b366853 100644 --- a/libltdl/loaders/preopen.c +++ b/libltdl/loaders/preopen.c @@ -158,8 +158,8 @@ vm_open (lt_user_data loader_data, const char *filename) for (lists = preloaded_symlists; lists; lists = lists->next) { - const lt_dlsymbol *symbol; - for (symbol= lists->symlist->symbols; symbol->name; ++symbol) + const lt_dlsymlist *symbol; + for (symbol= lists->symlist; symbol->name; ++symbol) { if (!symbol->address && streq (symbol->name, filename)) { @@ -192,10 +192,9 @@ vm_close (lt_user_data loader_data, lt_module module) static void * vm_sym (lt_user_data loader_data, lt_module module, const char *name) { - lt_dlsymlist *symlist = (lt_dlsymlist*) module; - const lt_dlsymbol *symbol = symlist->symbols; + lt_dlsymlist *symbol = (lt_dlsymlist*) module; - ++symbol; /* Skip header. */ + symbol +=2; /* Skip header (originator then libname). */ while (symbol->name) { @@ -320,15 +319,16 @@ lt_dlpreload_open (const char *originator, lt_dlpreload_callback_func *func) for (list = preloaded_symlists; list; list = list->next) { /* ...that was preloaded by the requesting ORIGINATOR... */ - if (streq (list->symlist->originator, originator)) + if (streq (list->symlist->name, originator)) { - const lt_dlsymbol *symbol; + const lt_dlsymlist *symbol; unsigned int idx = 0; ++found; - /* ...load the symbols per source compilation unit: */ - while ((symbol = &list->symlist->symbols[idx++])->name != 0) + /* ...load the symbols per source compilation unit: + (we preincrement the index to skip over the originator entry) */ + while ((symbol = &list->symlist[++idx])->name != 0) { if ((symbol->address == 0) && (strneq (symbol->name, "@PROGRAM@"))) diff --git a/libltdl/ltdl.h b/libltdl/ltdl.h index fd56505be..dcf88b2d2 100644 --- a/libltdl/ltdl.h +++ b/libltdl/ltdl.h @@ -84,11 +84,6 @@ LT_SCOPE int lt_dlisresident (lt_dlhandle handle); typedef struct { const char *name; void *address; -} lt_dlsymbol; - -typedef struct { - const char *originator; - const lt_dlsymbol symbols[]; } lt_dlsymlist; typedef int lt_dlpreload_callback_func (lt_dlhandle handle); @@ -100,8 +95,8 @@ 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; \ - lt_dlpreload_default(<_preloaded_symbols); \ + extern const lt_dlsymlist lt_preloaded_symbols[]; \ + lt_dlpreload_default(lt_preloaded_symbols); \ }LT_STMT_END diff --git a/m4/libtool.m4 b/m4/libtool.m4 index c4f1364b4..633eb67d6 100644 --- a/m4/libtool.m4 +++ b/m4/libtool.m4 @@ -2793,21 +2793,16 @@ _LT_EOF /* The mapping between symbol names and symbols. */ const struct { - const char *originator; - const struct { - const char *name; - void *address; - } symbols[[]]; + const char *name; + void *address; } -lt__PROGRAM__LTX_preloaded_symbols = +lt__PROGRAM__LTX_preloaded_symbols[[]] = { - "@PROGRAM@", - { + { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} - } }; /* This works around a problem in FreeBSD linker */