This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] add all missing section flags to objcopy
- From: Robert Schiele <rschiele at gmail dot com>
- To: binutils at sourceware dot org
- Date: Thu, 24 Jan 2013 09:20:03 +0100
- Subject: [PATCH] add all missing section flags to objcopy
---
I was missing the option to set SEC_MERGE and SEC_STRINGS in objcopy.
Instead of just adding those two I thought it might be better to make
the picture complete and just add all that are currently defined.
I left the order of the already existing ones such that abbreviations
of flags (like "a" for "alloc") continue to work as before.
binutils/ChangeLog | 4 ++++
binutils/objcopy.c | 42 +++++++++++++++++++++++++++++++++++++++++-
2 files changed, 45 insertions(+), 1 deletion(-)
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 4860baf..9015802 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,7 @@
+2013-01-24 Robert Schiele <rschiele@gmail.com>
+
+ * objcopy.c (parse_flags): Add all missing section flags.
+
2013-01-23 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
* readelf.c: Add strings for NT_S390_LAST_BREAK and
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index ead8ff4..e9ea006 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -680,6 +680,9 @@ parse_flags (const char *s)
if (0) ;
#define PARSE_FLAG(fname,fval) \
else if (strncasecmp (fname, s, len) == 0) ret |= fval
+#define PARSE_FLAG_FIELD(fname,fval,ffield) \
+ else if (strncasecmp (fname, s, len) == 0) \
+ do { ret &= ~ffield; ret |= fval; } while (0)
PARSE_FLAG ("alloc", SEC_ALLOC);
PARSE_FLAG ("load", SEC_LOAD);
PARSE_FLAG ("noload", SEC_NEVER_LOAD);
@@ -690,7 +693,37 @@ parse_flags (const char *s)
PARSE_FLAG ("rom", SEC_ROM);
PARSE_FLAG ("share", SEC_COFF_SHARED);
PARSE_FLAG ("contents", SEC_HAS_CONTENTS);
+ PARSE_FLAG_FIELD ("noflags", SEC_NO_FLAGS, ~SEC_NO_FLAGS);
+ PARSE_FLAG ("reloc", SEC_RELOC);
+ PARSE_FLAG ("constructor", SEC_CONSTRUCTOR);
+ PARSE_FLAG ("threadlocal", SEC_THREAD_LOCAL);
+ PARSE_FLAG ("hasgotref", SEC_HAS_GOT_REF);
+ PARSE_FLAG ("iscommon", SEC_IS_COMMON);
+ PARSE_FLAG ("inmemory", SEC_IN_MEMORY);
+ PARSE_FLAG ("exclude", SEC_EXCLUDE);
+ PARSE_FLAG ("sortentries", SEC_SORT_ENTRIES);
+ PARSE_FLAG ("linkonce", SEC_LINK_ONCE);
+ PARSE_FLAG_FIELD ("linkduplicatesdiscard",
+ SEC_LINK_DUPLICATES_DISCARD, SEC_LINK_DUPLICATES);
+ PARSE_FLAG_FIELD ("linkduplicatesoneonly",
+ SEC_LINK_DUPLICATES_ONE_ONLY, SEC_LINK_DUPLICATES);
+ PARSE_FLAG_FIELD ("linkduplicatessamesize",
+ SEC_LINK_DUPLICATES_SAME_SIZE, SEC_LINK_DUPLICATES);
+ PARSE_FLAG_FIELD ("linkduplicatessamecontents",
+ SEC_LINK_DUPLICATES_SAME_CONTENTS, SEC_LINK_DUPLICATES);
+ PARSE_FLAG ("linkercreated", SEC_LINKER_CREATED);
+ PARSE_FLAG ("keep", SEC_KEEP);
+ PARSE_FLAG ("smalldata", SEC_SMALL_DATA);
+ PARSE_FLAG ("merge", SEC_MERGE);
+ PARSE_FLAG ("strings", SEC_STRINGS);
+ PARSE_FLAG ("group", SEC_GROUP);
+ PARSE_FLAG ("coffsharedlibrary", SEC_COFF_SHARED_LIBRARY);
+ PARSE_FLAG ("elfreversecopy", SEC_ELF_REVERSE_COPY);
+ PARSE_FLAG ("tic54xblock", SEC_TIC54X_BLOCK);
+ PARSE_FLAG ("tic54xclink", SEC_TIC54X_CLINK);
+ PARSE_FLAG ("coffnoread", SEC_COFF_NOREAD);
#undef PARSE_FLAG
+#undef PARSE_FLAG_FIELD
else
{
char *copy;
@@ -700,7 +733,14 @@ parse_flags (const char *s)
copy[len] = '\0';
non_fatal (_("unrecognized section flag `%s'"), copy);
fatal (_("supported flags: %s"),
- "alloc, load, noload, readonly, debug, code, data, rom, share, contents");
+ "\n"
+ " alloc, load, noload, readonly, debug, code, data, rom, share,\n"
+ " contents, noflags, reloc, constructor, threadlocal, hasgotref,\n"
+ " iscommon, inmemory, exclude, sortentries, linkonce,\n"
+ " linkduplicatesdiscard, linkduplicatesoneonly, linkduplicatessamesize,\n"
+ " linkduplicatessamecontents, linkercreated, keep, smalldata, merge,\n"
+ " strings, group, coffsharedlibrary, elfreversecopy, tic54xblock,\n"
+ " tic54xclink, coffnoread");
}
s = snext;
--
1.7.10.4