Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/gnu/dist/toolchain/binutils Add a --redefine-syms-file optio...
details: https://anonhg.NetBSD.org/src/rev/e236f534481c
branches: trunk
changeset: 542446:e236f534481c
user: simonb <simonb%NetBSD.org@localhost>
date: Wed Jan 29 10:26:22 2003 +0000
description:
Add a --redefine-syms-file option from Chris Demetriou's proposed patch
in http://sources.redhat.com/ml/binutils/2002-09/msg00505.html.
diffstat:
gnu/dist/toolchain/binutils/binutils.texi | 7 +
gnu/dist/toolchain/binutils/objcopy.1 | 7 +
gnu/dist/toolchain/binutils/objcopy.c | 112 +++++++++++++++++++++++++++--
3 files changed, 118 insertions(+), 8 deletions(-)
diffs (237 lines):
diff -r 82a11537b698 -r e236f534481c gnu/dist/toolchain/binutils/binutils.texi
--- a/gnu/dist/toolchain/binutils/binutils.texi Wed Jan 29 09:17:08 2003 +0000
+++ b/gnu/dist/toolchain/binutils/binutils.texi Wed Jan 29 10:26:22 2003 +0000
@@ -902,6 +902,7 @@
[ --strip-symbols=@var{filename} ]
[ --keep-global-symbols=@var{filename} ]
[ --localize-symbols=@var{filename} ]
+ [ --redefine-syms-file=@var{filename} ]
[ --weaken-symbols=@var{filename} ]
[ -v | --verbose ] [ -V | --version ] [ --help ]
@var{infile} [@var{outfile}]
@@ -1212,6 +1213,12 @@
name per line. Line comments may be introduced by the hash character.
This option may be given more than once.
+@item --redefine-syms-file=@var{filename}
+Apply @samp{--redefine-sym} option to each symbol listed in the file
+@var{filename}. @var{filename} is simply a flat file, with two symbol
+names per line separated by white space. Line comments may be introduced
+by the hash character. This option may be given more than once.
+
@item --weaken-symbols=@var{filename}
Apply @samp{--weaken-symbol} option to each symbol listed in the file
@var{filename}. @var{filename} is simply a flat file, with one symbol
diff -r 82a11537b698 -r e236f534481c gnu/dist/toolchain/binutils/objcopy.1
--- a/gnu/dist/toolchain/binutils/objcopy.1 Wed Jan 29 09:17:08 2003 +0000
+++ b/gnu/dist/toolchain/binutils/objcopy.1 Wed Jan 29 10:26:22 2003 +0000
@@ -175,6 +175,7 @@
[ \-\-strip-symbols=\fIfilename\fR ]
[ \-\-keep-global-symbols=\fIfilename\fR ]
[ \-\-localize-symbols=\fIfilename\fR ]
+ [ \-\-redefine-syms-file=\fIfilename\fR ]
[ \-\-weaken-symbols=\fIfilename\fR ]
[ \-v | \-\-verbose ] [ \-V | \-\-version ] [ \-\-help ]
\fIinfile\fR [\fIoutfile\fR]
@@ -513,6 +514,12 @@
\&\fIfilename\fR. \fIfilename\fR is simply a flat file, with one symbol
name per line. Line comments may be introduced by the hash character.
This option may be given more than once.
+.Ip "\f(CW\*(C`\-\-redefine\-syms\-file=\f(CIfilename\f(CW\*(C'\fR" 4
+.IX Item "--redefine-syms-file=filename"
+Apply \fB\*(--redefine-sym\fR option to each symbol listed in the file
+\&\fIfilename\fR. \fIfilename\fR is simply a flat file, with two symbol
+names per line separated by white space. Line comments may be introduced
+by the hash character. This option may be given more than once.
.Ip "\f(CW\*(C`\-\-weaken\-symbols=\f(CIfilename\f(CW\*(C'\fR" 4
.IX Item "--weaken-symbols=filename"
Apply \fB\*(--weaken-symbol\fR option to each symbol listed in the file
diff -r 82a11537b698 -r e236f534481c gnu/dist/toolchain/binutils/objcopy.c
--- a/gnu/dist/toolchain/binutils/objcopy.c Wed Jan 29 09:17:08 2003 +0000
+++ b/gnu/dist/toolchain/binutils/objcopy.c Wed Jan 29 10:26:22 2003 +0000
@@ -28,6 +28,7 @@
#include "budbg.h"
#include "filenames.h"
#include <sys/stat.h>
+#include <ctype.h>
/* 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
@@ -72,7 +73,10 @@
static int strip_main PARAMS ((int, char **));
static int copy_main PARAMS ((int, char **));
static const char *lookup_sym_redefinition PARAMS((const char *));
-static void redefine_list_append PARAMS ((const char *, const char *));
+static void redefine_list_append
+ PARAMS ((const char *, const char *, const char *));
+static void add_redefine_syms_file PARAMS ((const char *));
+
#define RETURN_NONFATAL(s) {bfd_nonfatal (s); status = 1; return;}
@@ -219,7 +223,8 @@
#define OPTION_STRIP_UNNEEDED (OPTION_SET_START + 1)
#define OPTION_WEAKEN (OPTION_STRIP_UNNEEDED + 1)
#define OPTION_REDEFINE_SYM (OPTION_WEAKEN + 1)
-#define OPTION_SREC_LEN (OPTION_REDEFINE_SYM + 1)
+#define OPTION_REDEFINE_SYMS_FILE (OPTION_REDEFINE_SYM + 1)
+#define OPTION_SREC_LEN (OPTION_REDEFINE_SYMS_FILE + 1)
#define OPTION_SREC_FORCES3 (OPTION_SREC_LEN + 1)
#define OPTION_STRIP_SYMBOLS (OPTION_SREC_FORCES3 + 1)
#define OPTION_KEEP_SYMBOLS (OPTION_STRIP_SYMBOLS + 1)
@@ -302,6 +307,7 @@
{"weaken", no_argument, 0, OPTION_WEAKEN},
{"weaken-symbol", required_argument, 0, 'W'},
{"redefine-sym", required_argument, 0, OPTION_REDEFINE_SYM},
+ {"redefine-syms-file", required_argument, 0, OPTION_REDEFINE_SYMS_FILE},
{"srec-len", required_argument, 0, OPTION_SREC_LEN},
{"srec-forceS3", no_argument, 0, OPTION_SREC_FORCES3},
{"keep-symbols", required_argument, 0, OPTION_KEEP_SYMBOLS},
@@ -378,6 +384,7 @@
--change-leading-char Force output format's leading character style\n\
--remove-leading-char Remove leading character from global symbols\n\
--redefine-sym <old>=<new> Redefine symbol name <old> to <new>\n\
+ --redefine-syms-file <file> Use <file> as a list of symbol redefinitions\n\
--srec-len <number> Restrict the length of generated Srecords\n\
--srec-forceS3 Restrict the type of generated Srecords to S3\n\
--strip-symbols <file> -N for all symbols listed in <file>\n\
@@ -842,7 +849,8 @@
/* Add a node to a symbol redefine list */
static void
-redefine_list_append (source, target)
+redefine_list_append (cause, source, target)
+ const char *cause;
const char *source;
const char *target;
{
@@ -855,15 +863,13 @@
if (strcmp (source, list->source) == 0)
{
fatal (_("%s: Multiple redefinition of symbol \"%s\""),
- "--redefine-sym",
- source);
+ cause, source);
}
if (strcmp (target, list->target) == 0)
{
fatal (_("%s: Symbol \"%s\" is target of more than one redefinition"),
- "--redefine-sym",
- target);
+ cause, target);
}
}
@@ -876,6 +882,92 @@
*p = new_node;
}
+/* Handle the --redefine-syms-file option. Read lines conataining "old new"
+ from the file, and add them to the symbol redefine list. */
+void
+add_redefine_syms_file (filename)
+ const char *filename;
+{
+ FILE *file;
+ char *buf;
+ size_t bufsize, len, outsym_off;
+ int c, lineno;
+
+ file = fopen (filename, "r");
+ if (file == (FILE *) NULL)
+ fatal (_("couldn't open symbol redefinition file %s (error: %s)"),
+ filename, strerror (errno));
+
+ bufsize = 100;
+ buf = (char *) xmalloc (bufsize);
+
+ lineno = 1;
+ c = getc (file);
+ len = 0;
+ while (c != EOF)
+ {
+ /* Collect the input symbol name. */
+ while (! isspace (c) && c != EOF)
+ {
+ buf[len++] = c;
+ if (len >= bufsize)
+ {
+ bufsize *= 2;
+ buf = xrealloc (buf, bufsize);
+ }
+ c = getc (file);
+ }
+ buf[len++] = '\0';
+ if (c == EOF)
+ break;
+
+ /* Eat white space between the symbol names. */
+ while (isspace (c))
+ c = getc (file);
+ if (c == EOF)
+ break;
+
+ /* Collect the output symbol name. */
+ outsym_off = len;
+ while (! isspace (c) && c != EOF)
+ {
+ buf[len++] = c;
+ if (len >= bufsize)
+ {
+ bufsize *= 2;
+ buf = xrealloc (buf, bufsize);
+ }
+ c = getc (file);
+ }
+ buf[len++] = '\0';
+ if (c == EOF)
+ break;
+
+ /* Eat white space at end of line. */
+ while (c != '\n' && isspace (c))
+ c = getc (file);
+ if (c == EOF)
+ break;
+ else if (c == '\n')
+ {
+ /* Append the redefinition to the list. */
+ redefine_list_append (filename, &buf[0], &buf[outsym_off]);
+
+ lineno++;
+ len = 0;
+ c = getc (file);
+ continue;
+ }
+ else
+ fatal (_("%s: garbage at end of line %d"), filename, lineno);
+ }
+
+ if (len != 0)
+ fatal (_("%s: premature end of file at line %d"), filename, lineno);
+
+ free (buf);
+}
+
/* Keep only every `copy_byte'th byte in MEMHUNK, which is *SIZE bytes long.
Adjust *SIZE. */
@@ -2266,13 +2358,17 @@
target = (char *) xmalloc (len + 1);
strcpy (target, nextarg);
- redefine_list_append (source, target);
+ redefine_list_append ("--redefine-sym", source, target);
free (source);
free (target);
}
break;
+ case OPTION_REDEFINE_SYMS_FILE:
+ add_redefine_syms_file (optarg);
+ break;
+
case OPTION_SET_SECTION_FLAGS:
{
const char *s;
Home |
Main Index |
Thread Index |
Old Index