* objcopy.c (parse_flags): Make flag check case insensitive.
Check for `contents' flag. Give an error for unrecognized flags. (copy_section): If the contents flag was set for a section that had no contents, zero out the new contents. * binutils.texi (objcopy): Document contents section flag. PR 10601.
This commit is contained in:
parent
fe9cb9d8dd
commit
ee1f0bd101
3 changed files with 48 additions and 4 deletions
|
@ -1,3 +1,11 @@
|
|||
Mon Nov 3 12:36:19 1997 Ian Lance Taylor <ian@cygnus.com>
|
||||
|
||||
* objcopy.c (parse_flags): Make flag check case insensitive.
|
||||
Check for `contents' flag. Give an error for unrecognized flags.
|
||||
(copy_section): If the contents flag was set for a section that
|
||||
had no contents, zero out the new contents.
|
||||
* binutils.texi (objcopy): Document contents section flag.
|
||||
|
||||
Sun Nov 2 14:49:56 1997 Ian Lance Taylor <ian@cygnus.com>
|
||||
|
||||
* objcopy.c: Move new struct and variable definitions to top of
|
||||
|
|
|
@ -1004,9 +1004,12 @@ the named section does not exist.
|
|||
@item --set-section-flags @var{section}=@var{flags}
|
||||
Set the flags for the named section. The @var{flags} argument is a
|
||||
comma separated string of flag names. The recognized names are
|
||||
@samp{alloc}, @samp{load}, @samp{readonly}, @samp{code}, @samp{data},
|
||||
and @samp{rom}. Not all flags are meaningful for all object file
|
||||
formats.
|
||||
@samp{alloc}, @samp{contents}, @samp{load}, @samp{readonly},
|
||||
@samp{code}, @samp{data}, and @samp{rom}. You can set the
|
||||
@samp{contents} flag for a section which does not have contents, but it
|
||||
is not meaningful to clear the @samp{contents} flag of a section which
|
||||
does have contents--just remove the section instead. Not all flags are
|
||||
meaningful for all object file formats.
|
||||
|
||||
@item --add-section @var{sectionname}=@var{filename}
|
||||
Add a new section named @var{sectionname} while copying the file. The
|
||||
|
|
|
@ -354,14 +354,31 @@ parse_flags (s)
|
|||
++snext;
|
||||
}
|
||||
|
||||
#define PARSE_FLAG(fname,fval) if (strncmp (fname, s, len) == 0) ret |= fval;
|
||||
if (0) ;
|
||||
#define PARSE_FLAG(fname,fval) \
|
||||
else if (strncasecmp (fname, s, len) == 0) ret |= fval
|
||||
PARSE_FLAG ("alloc", SEC_ALLOC);
|
||||
PARSE_FLAG ("load", SEC_LOAD);
|
||||
PARSE_FLAG ("readonly", SEC_READONLY);
|
||||
PARSE_FLAG ("code", SEC_CODE);
|
||||
PARSE_FLAG ("data", SEC_DATA);
|
||||
PARSE_FLAG ("rom", SEC_ROM);
|
||||
PARSE_FLAG ("contents", SEC_HAS_CONTENTS);
|
||||
#undef PARSE_FLAG
|
||||
else
|
||||
{
|
||||
char *copy;
|
||||
|
||||
copy = xmalloc (len + 1);
|
||||
strncpy (copy, s, len);
|
||||
copy[len] = '\0';
|
||||
fprintf (stderr, "%s: unrecognized section flag `%s'\n",
|
||||
program_name, copy);
|
||||
fprintf (stderr,
|
||||
"%s: supported flags: alloc, load, readonly, code, data, rom, contents\n",
|
||||
program_name);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
s = snext;
|
||||
}
|
||||
|
@ -1272,6 +1289,22 @@ copy_section (ibfd, isection, obfdarg)
|
|||
}
|
||||
free (memhunk);
|
||||
}
|
||||
else if (p->set_flags && (p->flags & SEC_HAS_CONTENTS) != 0)
|
||||
{
|
||||
PTR memhunk = (PTR) xmalloc ((unsigned) size);
|
||||
|
||||
/* We don't permit the user to turn off the SEC_HAS_CONTENTS
|
||||
flag--they can just remove the section entirely and add it
|
||||
back again. However, we do permit them to turn on the
|
||||
SEC_HAS_CONTENTS flag, and take it to mean that the section
|
||||
contents should be zeroed out. */
|
||||
|
||||
memset (memhunk, 0, size);
|
||||
if (! bfd_set_section_contents (obfd, osection, memhunk, (file_ptr) 0,
|
||||
size))
|
||||
nonfatal (bfd_get_filename (obfd));
|
||||
free (memhunk);
|
||||
}
|
||||
}
|
||||
|
||||
/* Get all the sections. This is used when --gap-fill or --pad-to is
|
||||
|
|
Loading…
Reference in a new issue