aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog11
-rw-r--r--binutils/doc/binutils.texi13
-rw-r--r--binutils/objcopy.c9
-rw-r--r--binutils/testsuite/binutils-all/copy-5.d7
-rw-r--r--binutils/testsuite/binutils-all/objcopy.exp2
5 files changed, 38 insertions, 4 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index fd56834..8b84df5 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,14 @@
+2018-10-11 Jordan Rupprecht <rupprecht@google.com>
+ Nick Clifton <nickc@redhat.com>
+
+ * objcopy.c (copy_main): Issue a fata error if the
+ --keep-global-symbol(s) and the --globalize-symbol(s) options are
+ used together.
+ * doc/binutils.texi: Document that the two options are
+ incompatible.
+ * testsuite/binutils-all/copy-5.d: New test.
+ * testsuite/binutils-all/objcopy.exp: Run the new test.
+
2018-10-10 Helge Deller <deller@gmx.de>
Alan Modra <amodra@gmail.com>
diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi
index 76cbed0..cd70791 100644
--- a/binutils/doc/binutils.texi
+++ b/binutils/doc/binutils.texi
@@ -1129,6 +1129,7 @@ objcopy [@option{-F} @var{bfdname}|@option{--target=}@var{bfdname}]
[@option{--localize-hidden}]
[@option{-L} @var{symbolname}|@option{--localize-symbol=}@var{symbolname}]
[@option{--globalize-symbol=}@var{symbolname}]
+ [@option{--globalize-symbols=}@var{filename}]
[@option{-W} @var{symbolname}|@option{--weaken-symbol=}@var{symbolname}]
[@option{-w}|@option{--wildcard}]
[@option{-x}|@option{--discard-all}]
@@ -1169,7 +1170,6 @@ objcopy [@option{-F} @var{bfdname}|@option{--target=}@var{bfdname}]
[@option{--strip-unneeded-symbols=}@var{filename}]
[@option{--keep-global-symbols=}@var{filename}]
[@option{--localize-symbols=}@var{filename}]
- [@option{--globalize-symbols=}@var{filename}]
[@option{--weaken-symbols=}@var{filename}]
[@option{--add-symbol} @var{name}=[@var{section}:]@var{value}[,@var{flags}]]
[@option{--alt-machine-code=}@var{index}]
@@ -1380,7 +1380,9 @@ by a relocation. This option may be given more than once.
@itemx --keep-global-symbol=@var{symbolname}
Keep only symbol @var{symbolname} global. Make all other symbols local
to the file, so that they are not visible externally. This option may
-be given more than once.
+be given more than once. Note: this option cannot be used in
+conjunction with the @option{--globalize-symbol} or
+@option{--globalize-symbols} options.
@item --localize-hidden
In an ELF object, mark all symbols that have hidden or internal visibility
@@ -1400,7 +1402,8 @@ Make symbol @var{symbolname} weak. This option may be given more than once.
@item --globalize-symbol=@var{symbolname}
Give symbol @var{symbolname} global scoping so that it is visible
outside of the file in which it is defined. This option may be given
-more than once.
+more than once. Note: this option cannot be used in conjunction with
+the @option{-G} or @option{--keep-global-symbol} options.
@item -w
@itemx --wildcard
@@ -1774,7 +1777,9 @@ This option may be given more than once.
Apply @option{--globalize-symbol} option to each symbol listed in the file
@var{filename}. @var{filename} is simply a flat file, with one symbol
name per line. Line comments may be introduced by the hash character.
-This option may be given more than once.
+This option may be given more than once. Note: this option cannot be
+used in conjunction with the @option{-G} or @option{--keep-global-symbol}
+options.
@item --weaken-symbols=@var{filename}
Apply @option{--weaken-symbol} option to each symbol listed in the file
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 9af3c1e..d8ae1f9 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -4753,6 +4753,8 @@ copy_main (int argc, char *argv[])
bfd_boolean show_version = FALSE;
bfd_boolean change_warn = TRUE;
bfd_boolean formats_info = FALSE;
+ bfd_boolean use_globalize = FALSE;
+ bfd_boolean use_keep_global = FALSE;
int c;
struct stat statbuf;
const bfd_arch_info_type *input_arch = NULL;
@@ -4871,10 +4873,12 @@ copy_main (int argc, char *argv[])
break;
case OPTION_GLOBALIZE_SYMBOL:
+ use_globalize = TRUE;
add_specific_symbol (optarg, globalize_specific_htab);
break;
case 'G':
+ use_keep_global = TRUE;
add_specific_symbol (optarg, keepglobal_specific_htab);
break;
@@ -5306,11 +5310,13 @@ copy_main (int argc, char *argv[])
break;
case OPTION_GLOBALIZE_SYMBOLS:
+ use_globalize = TRUE;
add_specific_symbols (optarg, globalize_specific_htab,
&globalize_specific_buffer);
break;
case OPTION_KEEPGLOBAL_SYMBOLS:
+ use_keep_global = TRUE;
add_specific_symbols (optarg, keepglobal_specific_htab,
&keepglobal_specific_buffer);
break;
@@ -5446,6 +5452,9 @@ copy_main (int argc, char *argv[])
}
}
+ if (use_globalize && use_keep_global)
+ fatal(_("--globalize-symbol(s) is incompatible with -G/--keep-global-symbol(s)"));
+
if (formats_info)
{
display_info ();
diff --git a/binutils/testsuite/binutils-all/copy-5.d b/binutils/testsuite/binutils-all/copy-5.d
new file mode 100644
index 0000000..33f22e5
--- /dev/null
+++ b/binutils/testsuite/binutils-all/copy-5.d
@@ -0,0 +1,7 @@
+#PROG: objcopy
+#source: bintest.s
+#objcopy: -G fred --globalize-symbol jim bintest.o bintest.copy.o
+# A few targets cannot assemble the bintest.s source file...
+#notarget: pdp11-* *-darwin
+#name: Error when using --keep-global-symbol with --globalize-symbol
+#error: \A[^\n]*: --globalize-symbol\(s\) is incompatible with -G/--keep-global-symbol\(s\)
diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp
index a161029..3676f76 100644
--- a/binutils/testsuite/binutils-all/objcopy.exp
+++ b/binutils/testsuite/binutils-all/objcopy.exp
@@ -1074,6 +1074,8 @@ if [is_elf_format] {
run_dump_test "copy-2"
run_dump_test "copy-3"
run_dump_test "copy-4"
+run_dump_test "copy-5"
+
# Use bintest.o from the copy-4 test to determine ELF reloc type
set reloc_format rel
if { [is_elf_format] && [is_rela tmpdir/bintest.o] } {