aboutsummaryrefslogtreecommitdiff
path: root/binutils/objcopy.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2001-09-19 06:58:06 +0000
committerAlan Modra <amodra@gmail.com>2001-09-19 06:58:06 +0000
commit3bcfb3e4bd58ff97f4a68952e1a6c1763b0e8ddc (patch)
treea3bd33def5a5597a5cb07a7dc8585ed9c36fe91f /binutils/objcopy.c
parent8f6a59e5ff68ceea037f30ea6f0650a721cf9ab8 (diff)
downloadgdb-3bcfb3e4bd58ff97f4a68952e1a6c1763b0e8ddc.zip
gdb-3bcfb3e4bd58ff97f4a68952e1a6c1763b0e8ddc.tar.gz
gdb-3bcfb3e4bd58ff97f4a68952e1a6c1763b0e8ddc.tar.bz2
* objcopy.c (copy_main): Correct rename-section string parsing.
Consolidate new_name parsing, and error messages.
Diffstat (limited to 'binutils/objcopy.c')
-rw-r--r--binutils/objcopy.c44
1 files changed, 20 insertions, 24 deletions
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 4be1d59..03ec035 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -2399,47 +2399,43 @@ copy_main (argc, argv)
case OPTION_RENAME_SECTION:
{
flagword flags;
- const char * s;
- char * old_name;
- char * new_name;
+ const char *eq, *fl;
+ char *old_name;
+ char *new_name;
unsigned int len;
- s = strchr (optarg, '=');
- if (s == NULL)
+ eq = strchr (optarg, '=');
+ if (eq == NULL)
fatal (_("bad format for %s"), "--rename-section");
- len = s - optarg;
+ len = eq - optarg;
if (len == 0)
- fatal (_("no old name is %s"), "--rename-section");
+ fatal (_("bad format for %s"), "--rename-section");
old_name = (char *) xmalloc (len + 1);
strncpy (old_name, optarg, len);
old_name[len] = 0;
- s = strchr (optarg + len, ',');
- if (s)
+ eq++;
+ fl = strchr (eq, ',');
+ if (fl)
{
- unsigned int new_len;
-
- flags = parse_flags (s + 1);
- new_len = s - (optarg + len);
- if (new_len == 0)
- fatal (_("no new name in %s"), "--rename-section");
- new_name = (char *) xmalloc (new_len + 1);
- strncpy (new_name, optarg + len, new_len);
- new_name [new_len] = 0;
+ flags = parse_flags (fl + 1);
+ len = fl - eq;
}
else
{
- s = optarg + len;
- len = strlen (s);
- if (len == 0)
- fatal (_("no new name in %s"), "--rename-section");
- new_name = (char *) xmalloc (len + 1);
- strcpy (new_name, s);
flags = -1;
+ len = strlen (eq);
}
+ if (len == 0)
+ fatal (_("bad format for %s"), "--rename-section");
+
+ new_name = (char *) xmalloc (len + 1);
+ strncpy (new_name, eq, len);
+ new_name[len] = 0;
+
add_section_rename (old_name, new_name, flags);
}
break;