* objcopy.c (copy_main): Correct rename-section string parsing.
Consolidate new_name parsing, and error messages.
This commit is contained in:
parent
8f6a59e5ff
commit
3bcfb3e4bd
2 changed files with 25 additions and 24 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2001-09-19 Alan Modra <amodra@bigpond.net.au>
|
||||||
|
|
||||||
|
* objcopy.c (copy_main): Correct rename-section string parsing.
|
||||||
|
Consolidate new_name parsing, and error messages.
|
||||||
|
|
||||||
2001-09-18 Bruno Haible <haible@clisp.cons.org>
|
2001-09-18 Bruno Haible <haible@clisp.cons.org>
|
||||||
|
|
||||||
* addr2line.c: Don't include <ctype.h>.
|
* addr2line.c: Don't include <ctype.h>.
|
||||||
|
|
|
@ -2399,47 +2399,43 @@ copy_main (argc, argv)
|
||||||
case OPTION_RENAME_SECTION:
|
case OPTION_RENAME_SECTION:
|
||||||
{
|
{
|
||||||
flagword flags;
|
flagword flags;
|
||||||
const char * s;
|
const char *eq, *fl;
|
||||||
char *old_name;
|
char *old_name;
|
||||||
char *new_name;
|
char *new_name;
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
|
|
||||||
s = strchr (optarg, '=');
|
eq = strchr (optarg, '=');
|
||||||
if (s == NULL)
|
if (eq == NULL)
|
||||||
fatal (_("bad format for %s"), "--rename-section");
|
fatal (_("bad format for %s"), "--rename-section");
|
||||||
|
|
||||||
len = s - optarg;
|
len = eq - optarg;
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
fatal (_("no old name is %s"), "--rename-section");
|
fatal (_("bad format for %s"), "--rename-section");
|
||||||
|
|
||||||
old_name = (char *) xmalloc (len + 1);
|
old_name = (char *) xmalloc (len + 1);
|
||||||
strncpy (old_name, optarg, len);
|
strncpy (old_name, optarg, len);
|
||||||
old_name[len] = 0;
|
old_name[len] = 0;
|
||||||
|
|
||||||
s = strchr (optarg + len, ',');
|
eq++;
|
||||||
if (s)
|
fl = strchr (eq, ',');
|
||||||
|
if (fl)
|
||||||
{
|
{
|
||||||
unsigned int new_len;
|
flags = parse_flags (fl + 1);
|
||||||
|
len = fl - eq;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
else
|
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;
|
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);
|
add_section_rename (old_name, new_name, flags);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue