aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1997-11-03 17:39:13 +0000
committerIan Lance Taylor <ian@airs.com>1997-11-03 17:39:13 +0000
commitee1f0bd101d402e7a879ae6af128b2c5a30aea48 (patch)
tree220022679907d9bfd6f43a41a2c826192cc4af80 /binutils
parentfe9cb9d8dd44ca15104962ff61aceafa921a58b8 (diff)
downloadfsf-binutils-gdb-ee1f0bd101d402e7a879ae6af128b2c5a30aea48.zip
fsf-binutils-gdb-ee1f0bd101d402e7a879ae6af128b2c5a30aea48.tar.gz
fsf-binutils-gdb-ee1f0bd101d402e7a879ae6af128b2c5a30aea48.tar.bz2
* 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.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog8
-rw-r--r--binutils/binutils.texi9
-rw-r--r--binutils/objcopy.c35
3 files changed, 48 insertions, 4 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 1cd0253..0635d6e 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -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
diff --git a/binutils/binutils.texi b/binutils/binutils.texi
index d117dc2..cc6b506 100644
--- a/binutils/binutils.texi
+++ b/binutils/binutils.texi
@@ -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
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index f477695..7e05c1b 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -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