diff options
author | Fangrui Song <i@maskray.me> | 2022-03-16 09:38:37 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2022-03-16 09:40:13 -0700 |
commit | 260ecdcec427146f760836092a040f957427760b (patch) | |
tree | d39a6d1d1fdadea58209cace8779773271d38dec /binutils | |
parent | b1b9c4115ed04876813a40c0051636c0ad916993 (diff) | |
download | binutils-260ecdcec427146f760836092a040f957427760b.zip binutils-260ecdcec427146f760836092a040f957427760b.tar.gz binutils-260ecdcec427146f760836092a040f957427760b.tar.bz2 |
objcopy --weaken-symbol: apply to STB_GNU_UNIQUE symbols
PR binutils/28926
* objcopy.c (filter_symbols): Apply weaken to STB_GNU_UNIQUE symbols
* NEWS: Mention feature.
* testsuite/binutils-all/objcopy.exp (objcopy_test_symbol_manipulation): New test.
* testsuite/binutils-all/weaken-gnu-unique.s: New.
Diffstat (limited to 'binutils')
-rw-r--r-- | binutils/ChangeLog | 8 | ||||
-rw-r--r-- | binutils/NEWS | 2 | ||||
-rw-r--r-- | binutils/objcopy.c | 4 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/objcopy.exp | 4 | ||||
-rw-r--r-- | binutils/testsuite/binutils-all/weaken-gnu-unique.d | 8 |
5 files changed, 24 insertions, 2 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 127ee5c..f843239 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,11 @@ +2022-03-16 Fangrui Song <maskray@google.com> + + PR binutils/28926 + * objcopy.c (filter_symbols): Apply weaken to STB_GNU_UNIQUE symbols + * NEWS: Mention feature. + * testsuite/binutils-all/objcopy.exp (objcopy_test_symbol_manipulation): New test. + * testsuite/binutils-all/weaken-gnu-unique.s: New. + 2022-03-16 Martin Storsjö <martin@martin.st> PR 28885 diff --git a/binutils/NEWS b/binutils/NEWS index 3c44708..7e3c005 100644 --- a/binutils/NEWS +++ b/binutils/NEWS @@ -2,6 +2,8 @@ * Add an option to objdump and readelf to prevent attempts to access debuginfod servers when following links. +* objcopy --weaken, --weaken-symbol, and --weaken-symbols now make ELF + STB_GNU_UNIQUE symbols weak. Changes in 2.38: diff --git a/binutils/objcopy.c b/binutils/objcopy.c index d53aa5c..aaa5aa9 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -1681,11 +1681,11 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms, if (keep) { - if (((flags & BSF_GLOBAL) != 0 + if (((flags & (BSF_GLOBAL | BSF_GNU_UNIQUE)) || undefined) && (weaken || is_specified_symbol (name, weaken_specific_htab))) { - sym->flags &= ~ BSF_GLOBAL; + sym->flags &= ~ (BSF_GLOBAL | BSF_GNU_UNIQUE); sym->flags |= BSF_WEAK; } diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp index 32c76a1..9a5dad5 100644 --- a/binutils/testsuite/binutils-all/objcopy.exp +++ b/binutils/testsuite/binutils-all/objcopy.exp @@ -1144,6 +1144,10 @@ proc objcopy_test_symbol_manipulation {} { verbose [file rootname $t] run_dump_test [file rootname $t] } + + if { [supports_gnu_unique] } { + run_dump_test "weaken-gnu-unique" + } } proc objcopy_test_elf_common_symbols {} { diff --git a/binutils/testsuite/binutils-all/weaken-gnu-unique.d b/binutils/testsuite/binutils-all/weaken-gnu-unique.d new file mode 100644 index 0000000..b0e60c4 --- /dev/null +++ b/binutils/testsuite/binutils-all/weaken-gnu-unique.d @@ -0,0 +1,8 @@ +#name: weaken STB_GNU_UNIQUE symbols +#PROG: objcopy +#objcopy: -W foo +#source: unique.s +#readelf: -s + +#... + +[0-9]+: +[0-9a-f]+ +[0-9]+ +OBJECT +WEAK +DEFAULT +[1-9] foo |