aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@linux-mips.org>2003-12-23 13:01:11 +0000
committerMaciej W. Rozycki <macro@linux-mips.org>2003-12-23 13:01:11 +0000
commit4087920c2bc1e852a6c623df3835bec21e654d69 (patch)
tree71451ea61c3233efed7677fae147197d9f14cc39 /binutils
parent231bc717e91afa0707b1078177a5f0aadf282f66 (diff)
downloadgdb-4087920c2bc1e852a6c623df3835bec21e654d69.zip
gdb-4087920c2bc1e852a6c623df3835bec21e654d69.tar.gz
gdb-4087920c2bc1e852a6c623df3835bec21e654d69.tar.bz2
* objcopy.c (bfd_flags_to_set, bfd_flags_to_clear): New variables
to handle flags for tweaking. (copy_options): New options: impure, pure, readonly-text, writable-text. (copy_usage, copy_object, command_line_switch): Handle the new options. * doc/binutils.texi: Document the new options.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog11
-rw-r--r--binutils/doc/binutils.texi20
-rw-r--r--binutils/objcopy.c49
3 files changed, 76 insertions, 4 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 8e6fe75..bf46bce 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,14 @@
+2003-12-23 Ralf Baechle <ralf@gnu.org>
+ Maciej W. Rozycki <macro@ds2.pg.gda.pl>
+
+ * objcopy.c (bfd_flags_to_set, bfd_flags_to_clear): New variables
+ to handle flags for tweaking.
+ (copy_options): New options: impure, pure, readonly-text,
+ writable-text.
+ (copy_usage, copy_object, command_line_switch): Handle the new
+ options.
+ * doc/binutils.texi: Document the new options.
+
2003-12-22 Jakub Jelinek <jakub@redhat.com>
* objdump.c (disassemble_bytes): Subtract rel_offset from printed
diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi
index ffa680f..2e78720 100644
--- a/binutils/doc/binutils.texi
+++ b/binutils/doc/binutils.texi
@@ -976,6 +976,10 @@ objcopy [@option{-F} @var{bfdname}|@option{--target=}@var{bfdname}]
[@option{--prefix-alloc-sections=}@var{string}]
[@option{--add-gnu-debuglink=}@var{path-to-file}]
[@option{--only-keep-debug}]
+ [@option{--writable-text}]
+ [@option{--readonly-text}]
+ [@option{--pure}]
+ [@option{--impure}]
[@option{-v}|@option{--verbose}]
[@option{-V}|@option{--version}]
[@option{--help}] [@option{--info}]
@@ -1357,6 +1361,22 @@ a machine is assigned an official code and the tool-chain adopts the
new code, but other applications still depend on the original code
being used.
+@item --writable-text
+Mark the output text as writable. This option isn't meaningful for all
+object file formats.
+
+@item --readonly-text
+Make the output text write protected. This option isn't meaningful for all
+object file formats.
+
+@item --pure
+Mark the output file as demand paged. This option isn't meaningful for all
+object file formats.
+
+@item --impure
+Mark the output file as impure. This option isn't meaningful for all
+object file formats.
+
@item --prefix-symbols=@var{string}
Prefix all symbols in the output file with @var{string}.
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index b861b74..ac60cb1 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -148,6 +148,10 @@ static bfd_vma pad_to;
/* Use alternate machine code? */
static int use_alt_mach_code = 0;
+/* Output BFD flags user wants to set or clear */
+static flagword bfd_flags_to_set;
+static flagword bfd_flags_to_clear;
+
/* List of sections to add. */
struct section_add
{
@@ -237,7 +241,11 @@ enum command_line_switch
OPTION_PREFIX_ALLOC_SECTIONS,
OPTION_FORMATS_INFO,
OPTION_ADD_GNU_DEBUGLINK,
- OPTION_ONLY_KEEP_DEBUG
+ OPTION_ONLY_KEEP_DEBUG,
+ OPTION_READONLY_TEXT,
+ OPTION_WRITABLE_TEXT,
+ OPTION_PURE,
+ OPTION_IMPURE
};
/* Options to handle if running as "strip". */
@@ -295,6 +303,7 @@ static struct option copy_options[] =
{"format", required_argument, 0, 'F'}, /* Obsolete */
{"gap-fill", required_argument, 0, OPTION_GAP_FILL},
{"help", no_argument, 0, 'h'},
+ {"impure", no_argument, 0, OPTION_IMPURE},
{"info", no_argument, 0, OPTION_FORMATS_INFO},
{"input-format", required_argument, 0, 'I'}, /* Obsolete */
{"input-target", required_argument, 0, 'I'},
@@ -316,6 +325,8 @@ static struct option copy_options[] =
{"prefix-sections", required_argument, 0, OPTION_PREFIX_SECTIONS},
{"prefix-alloc-sections", required_argument, 0, OPTION_PREFIX_ALLOC_SECTIONS},
{"preserve-dates", no_argument, 0, 'p'},
+ {"pure", no_argument, 0, OPTION_PURE},
+ {"readonly-text", no_argument, 0, OPTION_READONLY_TEXT},
{"redefine-sym", required_argument, 0, OPTION_REDEFINE_SYM},
{"redefine-syms", required_argument, 0, OPTION_REDEFINE_SYMS},
{"remove-leading-char", no_argument, 0, OPTION_REMOVE_LEADING_CHAR},
@@ -337,6 +348,7 @@ static struct option copy_options[] =
{"weaken-symbol", required_argument, 0, 'W'},
{"weaken-symbols", required_argument, 0, OPTION_WEAKEN_SYMBOLS},
{"wildcard", no_argument, 0, 'w'},
+ {"writable-text", no_argument, 0, OPTION_WRITABLE_TEXT},
{0, no_argument, 0, 0}
};
@@ -434,6 +446,10 @@ copy_usage (FILE *stream, int exit_status)
--keep-global-symbols <file> -G for all symbols listed in <file>\n\
--weaken-symbols <file> -W for all symbols listed in <file>\n\
--alt-machine-code <index> Use alternate machine code for output\n\
+ --writable-text Mark the output text as writable\n\
+ --readonly-text Make the output text write protected\n\
+ --pure Mark the output file as demand paged\n\
+ --impure Mark the output file as impure\n\
--prefix-symbols <prefix> Add <prefix> to start of every symbol name\n\
--prefix-sections <prefix> Add <prefix> to start of every section name\n\
--prefix-alloc-sections <prefix>\n\
@@ -1127,10 +1143,15 @@ copy_object (bfd *ibfd, bfd *obfd)
need to be set for a core file. */
if (bfd_get_format (obfd) != bfd_core)
{
+ flagword flags;
+
+ flags = bfd_get_file_flags (ibfd);
+ flags |= bfd_flags_to_set;
+ flags &= ~bfd_flags_to_clear;
+ flags &= bfd_applicable_file_flags (obfd);
+
if (!bfd_set_start_address (obfd, start)
- || !bfd_set_file_flags (obfd,
- (bfd_get_file_flags (ibfd)
- & bfd_applicable_file_flags (obfd))))
+ || !bfd_set_file_flags (obfd, flags))
RETURN_NONFATAL (bfd_get_filename (ibfd));
}
@@ -2784,6 +2805,26 @@ copy_main (int argc, char *argv[])
prefix_alloc_sections_string = optarg;
break;
+ case OPTION_READONLY_TEXT:
+ bfd_flags_to_set |= WP_TEXT;
+ bfd_flags_to_clear &= ~WP_TEXT;
+ break;
+
+ case OPTION_WRITABLE_TEXT:
+ bfd_flags_to_clear |= WP_TEXT;
+ bfd_flags_to_set &= ~WP_TEXT;
+ break;
+
+ case OPTION_PURE:
+ bfd_flags_to_set |= D_PAGED;
+ bfd_flags_to_clear &= ~D_PAGED;
+ break;
+
+ case OPTION_IMPURE:
+ bfd_flags_to_clear |= D_PAGED;
+ bfd_flags_to_set &= ~D_PAGED;
+ break;
+
case 0:
/* We've been given a long option. */
break;