aboutsummaryrefslogtreecommitdiff
path: root/binutils/objcopy.c
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/objcopy.c
parentfe9cb9d8dd44ca15104962ff61aceafa921a58b8 (diff)
downloadgdb-ee1f0bd101d402e7a879ae6af128b2c5a30aea48.zip
gdb-ee1f0bd101d402e7a879ae6af128b2c5a30aea48.tar.gz
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/objcopy.c')
-rw-r--r--binutils/objcopy.c35
1 files changed, 34 insertions, 1 deletions
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