diff options
author | Nick Clifton <nickc@redhat.com> | 2018-10-11 11:38:10 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2018-10-11 11:38:10 +0100 |
commit | de564eb5cc8c67fc38f9910937935eef5ebc17d8 (patch) | |
tree | 8586b85602d6752c61d991f8fe5d759760e992d6 /binutils/testsuite | |
parent | fbe61a3661b083a666e6550b3b0c2de364e6d4a6 (diff) | |
download | gdb-de564eb5cc8c67fc38f9910937935eef5ebc17d8.zip gdb-de564eb5cc8c67fc38f9910937935eef5ebc17d8.tar.gz gdb-de564eb5cc8c67fc38f9910937935eef5ebc17d8.tar.bz2 |
Prevent the --keep-global-symbol and --globalize-symbol options from being used together.
This is the result of an email thread starting here:
https://sourceware.org/ml/binutils/2018-09/msg00031.html
The main point of the thread is this observation:
* Supposing we had an object file with two globals, SomeGlobal and
SomeOtherGlobal, if one were to do "--globalize-symbol SomeGlobal
--keep-global-symbol SomeOtherGlobal", you might expect that both
SomeGlobal and SomeOtherGlobal are global in the output file... but it
isn't. Because --keep-global-symbol is set and doesn't include
SomeGlobal, SomeGlobal will be demoted to a local symbol. And because
the check to see if we should apply the --globalize-symbol flag checks
"flags" (the original flag set), and not "sym->flags", it decides not
to do anything, so SomeGlobal remains a local symbol. Although this is
a weird edge case, should this be changed so that --keep-global-symbol
implicitly keeps anything also specified via --globalize-symbol? (The
code seems technically correct with respect to the documentation, but
IMO the behavior is counter-intuitive).
binutils* 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.
Diffstat (limited to 'binutils/testsuite')
-rw-r--r-- | binutils/testsuite/binutils-all/copy-5.d | 7 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/objcopy.exp | 2 |
2 files changed, 9 insertions, 0 deletions
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] } { |