From a0304b950c294f40cfa3e1ce5a5a5076c95da167 Mon Sep 17 00:00:00 2001 From: Dave Korn Date: Sat, 3 Jan 2009 17:43:45 +0000 Subject: 2009-01-03 Dave Korn * pe-dll.c (autofilter_liblist): Add entry for shared libgcc. (libnamencmp): New function. (auto_export): Use it in place of strncmp when filtering libraries. Also rolled over ChangeLog to ChangeLog-2008 --- ld/pe-dll.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'ld/pe-dll.c') diff --git a/ld/pe-dll.c b/ld/pe-dll.c index f5aa9dd19c..de43e34329 100644 --- a/ld/pe-dll.c +++ b/ld/pe-dll.c @@ -314,6 +314,7 @@ static const autofilter_entry_type autofilter_liblist[] = { STRING_COMMA_LEN ("libcegcc") }, { STRING_COMMA_LEN ("libcygwin") }, { STRING_COMMA_LEN ("libgcc") }, + { STRING_COMMA_LEN ("libgcc_s") }, { STRING_COMMA_LEN ("libstdc++") }, { STRING_COMMA_LEN ("libmingw32") }, { STRING_COMMA_LEN ("libmingwex") }, @@ -324,6 +325,37 @@ static const autofilter_entry_type autofilter_liblist[] = { NULL, 0 } }; +/* Regardless of the suffix issue mentioned above, we must ensure that + we do not falsely match on a leading substring, such as when libtool + builds libstdc++ as a DLL using libsupc++convenience.a as an intermediate. + This routine ensures that the leading part of the name matches and that + it is followed by only an optional version suffix and a file extension, + returning zero if so or -1 if not. */ +static int libnamencmp (const char *libname, const autofilter_entry_type *afptr) +{ + if (strncmp (libname, afptr->name, afptr->len)) + return -1; + + libname += afptr->len; + + /* Be liberal in interpreting what counts as a version suffix; we + accept anything that has a dash to separate it from the name and + begins with a digit. */ + if (libname[0] == '-') + { + if (!ISDIGIT (*++libname)) + return -1; + /* Ensure the filename has an extension. */ + while (*++libname != '.') + if (!*libname) + return -1; + } + else if (libname[0] != '.') + return -1; + + return 0; +} + static const autofilter_entry_type autofilter_objlist[] = { { STRING_COMMA_LEN ("crt0.o") }, @@ -501,7 +533,7 @@ auto_export (bfd *abfd, def_file *d, const char *n) while (afptr->name) { - if (strncmp (libname, afptr->name, afptr->len) == 0 ) + if (libnamencmp (libname, afptr) == 0 ) return 0; afptr++; } -- cgit v1.2.1