--- binutils/objcopy.c.orig 2003-03-25 00:11:46.000000000 +0800 +++ binutils/objcopy.c 2003-04-29 11:04:11.000000000 +0800 @@ -28,6 +28,7 @@ #include "budbg.h" #include "filenames.h" #include +#include /* A list of symbols to explicitly strip out, or to keep. A linked list is good enough for a small number from the command line, but @@ -226,6 +227,9 @@ /* Whether to remove the leading character from global symbol names. */ static bfd_boolean remove_leading_char = FALSE; +/* Whether to permit wildcard in symbol comparasion. */ +static bfd_boolean wildcard = FALSE; + /* List of symbols to strip, keep, localize, keep-global, weaken, or redefine. */ static struct symlist *strip_specific_list = NULL; @@ -301,6 +305,7 @@ {"target", required_argument, 0, 'F'}, {"verbose", no_argument, 0, 'v'}, {"version", no_argument, 0, 'V'}, + {"wildcard", no_argument, 0, 'w'}, {0, no_argument, 0, 0} }; @@ -368,6 +373,7 @@ {"weaken", no_argument, 0, OPTION_WEAKEN}, {"weaken-symbol", required_argument, 0, 'W'}, {"weaken-symbols", required_argument, 0, OPTION_WEAKEN_SYMBOLS}, + {"wildcard", no_argument, 0, 'w'}, {0, no_argument, 0, 0} }; @@ -459,6 +465,7 @@ section name\n\ -v --verbose List all object files modified\n\ -V --version Display this program's version number\n\ + -w --wildcard Permit wildcard in symbol comparasion\n\ -h --help Display this output\n\ --info List object formats & architectures supported\n\ ")); @@ -491,6 +498,7 @@ -X --discard-locals Remove any compiler-generated symbols\n\ -v --verbose List all object files modified\n\ -V --version Display this program's version number\n\ + -w --wildcard Permit wildcard in symbol comparasion\n\ -h --help Display this output\n\ --info List object formats & architectures supported\n\ -o Place stripped output into \n\ @@ -734,9 +742,20 @@ { struct symlist *tmp_list; - for (tmp_list = list; tmp_list; tmp_list = tmp_list->next) - if (strcmp (name, tmp_list->name) == 0) - return TRUE; + if (wildcard) { + for (tmp_list = list; tmp_list; tmp_list = tmp_list->next) + if (*(tmp_list->name) != '!') { + if (!fnmatch(tmp_list->name, name, 0)) + return TRUE; + } else { + if (fnmatch(tmp_list->name + 1, name, 0)) + return TRUE; + } + } else { + for (tmp_list = list; tmp_list; tmp_list = tmp_list->next) + if (strcmp (name, tmp_list->name) == 0) + return TRUE; + } return FALSE; } @@ -2095,7 +2114,7 @@ struct section_list *p; char *output_file = NULL; - while ((c = getopt_long (argc, argv, "I:O:F:K:N:R:o:sSpdgxXHhVv", + while ((c = getopt_long (argc, argv, "I:O:F:K:N:R:o:sSpdgxXHhVvw", strip_options, (int *) 0)) != EOF) { switch (c) @@ -2152,6 +2171,9 @@ case OPTION_FORMATS_INFO: formats_info = TRUE; break; + case 'w': + wildcard = TRUE; + break; case 0: /* We've been given a long option. */ break; @@ -2242,7 +2264,7 @@ struct section_list *p; struct stat statbuf; - while ((c = getopt_long (argc, argv, "b:B:i:I:j:K:N:s:O:d:F:L:G:R:SpgxXHhVvW:", + while ((c = getopt_long (argc, argv, "b:B:i:I:j:K:N:s:O:d:F:L:G:R:SpgxXHhVvW:w", copy_options, (int *) 0)) != EOF) { switch (c) @@ -2325,6 +2347,10 @@ add_specific_symbol (optarg, &weaken_specific_list); break; + case 'w': + wildcard = TRUE; + break; + case 'p': preserve_dates = TRUE; break;