* [PATCH] objcopy --weaken-symbol: apply to STB_GNU_UNIQUE symbols
@ 2022-03-01 21:36 Fangrui Song
2022-03-01 21:56 ` Fangrui Song
0 siblings, 1 reply; 5+ messages in thread
From: Fangrui Song @ 2022-03-01 21:36 UTC (permalink / raw)
To: binutils, Alan Modra, Nick Clifton; +Cc: Fangrui Song
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.
---
binutils/NEWS | 3 +++
binutils/objcopy.c | 4 ++--
binutils/testsuite/binutils-all/objcopy.exp | 4 ++++
binutils/testsuite/binutils-all/weaken-gnu-unique.d | 8 ++++++++
4 files changed, 17 insertions(+), 2 deletions(-)
create mode 100644 binutils/testsuite/binutils-all/weaken-gnu-unique.d
diff --git a/binutils/NEWS b/binutils/NEWS
index c188b469a77..06f34c9a992 100644
--- a/binutils/NEWS
+++ b/binutils/NEWS
@@ -1,5 +1,8 @@
-*- text -*-
+* objcopy --weaken, --weaken-symbol, and --weaken-symbols now make ELF
+ STB_GNU_UNIQUE symbols weak.
+
Changes in 2.38:
* elfedit: Add --output-abiversion option to update ABIVERSION.
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index d53aa5c6000..aaa5aa9b2af 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 32c76a11f3b..9a5dad5384e 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 00000000000..b0e60c4ff80
--- /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
--
2.35.1.574.g5d30c73bfb-goog
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] objcopy --weaken-symbol: apply to STB_GNU_UNIQUE symbols
2022-03-01 21:36 [PATCH] objcopy --weaken-symbol: apply to STB_GNU_UNIQUE symbols Fangrui Song
@ 2022-03-01 21:56 ` Fangrui Song
2022-03-09 0:15 ` [PING] " Fangrui Song
[not found] ` <CAN30aBFa+x5SpgE9HvY467jj2vR=YMUWrMVUq=yD723g5xh+mA@mail.gmail.com>
0 siblings, 2 replies; 5+ messages in thread
From: Fangrui Song @ 2022-03-01 21:56 UTC (permalink / raw)
To: Fangrui Song; +Cc: binutils, Alan Modra, Nick Clifton
On 2022-03-01, Fangrui Song via Binutils wrote:
> 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.
typo: weaken-gnu-unique.s -> weaken-gnu-unique.d
>---
> binutils/NEWS | 3 +++
> binutils/objcopy.c | 4 ++--
> binutils/testsuite/binutils-all/objcopy.exp | 4 ++++
> binutils/testsuite/binutils-all/weaken-gnu-unique.d | 8 ++++++++
> 4 files changed, 17 insertions(+), 2 deletions(-)
> create mode 100644 binutils/testsuite/binutils-all/weaken-gnu-unique.d
>
>diff --git a/binutils/NEWS b/binutils/NEWS
>index c188b469a77..06f34c9a992 100644
>--- a/binutils/NEWS
>+++ b/binutils/NEWS
>@@ -1,5 +1,8 @@
> -*- text -*-
>
>+* objcopy --weaken, --weaken-symbol, and --weaken-symbols now make ELF
>+ STB_GNU_UNIQUE symbols weak.
>+
> Changes in 2.38:
>
> * elfedit: Add --output-abiversion option to update ABIVERSION.
>diff --git a/binutils/objcopy.c b/binutils/objcopy.c
>index d53aa5c6000..aaa5aa9b2af 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 32c76a11f3b..9a5dad5384e 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 00000000000..b0e60c4ff80
>--- /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
>--
>2.35.1.574.g5d30c73bfb-goog
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PING] Re: [PATCH] objcopy --weaken-symbol: apply to STB_GNU_UNIQUE symbols
2022-03-01 21:56 ` Fangrui Song
@ 2022-03-09 0:15 ` Fangrui Song
[not found] ` <CAN30aBFa+x5SpgE9HvY467jj2vR=YMUWrMVUq=yD723g5xh+mA@mail.gmail.com>
1 sibling, 0 replies; 5+ messages in thread
From: Fangrui Song @ 2022-03-09 0:15 UTC (permalink / raw)
To: Fangrui Song; +Cc: binutils, Alan Modra, Nick Clifton
On Tue, Mar 1, 2022 at 1:56 PM Fangrui Song <i@maskray.me> wrote:
>
> On 2022-03-01, Fangrui Song via Binutils wrote:
> > 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.
>
> typo: weaken-gnu-unique.s -> weaken-gnu-unique.d
ping..
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PING] Re: [PATCH] objcopy --weaken-symbol: apply to STB_GNU_UNIQUE symbols
[not found] ` <CAN30aBFa+x5SpgE9HvY467jj2vR=YMUWrMVUq=yD723g5xh+mA@mail.gmail.com>
@ 2022-03-16 1:12 ` Fangrui Song
[not found] ` <BN6PR1201MB00972ACA5F0D8900F1E72764CB119@BN6PR1201MB0097.namprd12.prod.outlook.com>
1 sibling, 0 replies; 5+ messages in thread
From: Fangrui Song @ 2022-03-16 1:12 UTC (permalink / raw)
To: Fangrui Song; +Cc: binutils, Alan Modra, Nick Clifton
On Tue, Mar 8, 2022 at 4:15 PM Fangrui Song <i@maskray.me> wrote:
>
> On Tue, Mar 1, 2022 at 1:56 PM Fangrui Song <i@maskray.me> wrote:
> >
> > On 2022-03-01, Fangrui Song via Binutils wrote:
> > > 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.
> >
> > typo: weaken-gnu-unique.s -> weaken-gnu-unique.d
>
> ping..
ping^2...
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PING] Re: [PATCH] objcopy --weaken-symbol: apply to STB_GNU_UNIQUE symbols
[not found] ` <BN6PR1201MB00972ACA5F0D8900F1E72764CB119@BN6PR1201MB0097.namprd12.prod.outlook.com>
@ 2022-03-16 13:54 ` Nick Clifton
0 siblings, 0 replies; 5+ messages in thread
From: Nick Clifton @ 2022-03-16 13:54 UTC (permalink / raw)
To: Fangrui Song, Fangrui Song; +Cc: binutils, Alan Modra
Hi Fangrui,
>>> On 2022-03-01, Fangrui Song via Binutils wrote:
>>>> 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.
>>>
>>> typo: weaken-gnu-unique.s -> weaken-gnu-unique.d
>>
>> ping..
>
> ping^2...
Sorry^2. Patch approved - please apply.
Cheers
Nick
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-03-16 13:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-01 21:36 [PATCH] objcopy --weaken-symbol: apply to STB_GNU_UNIQUE symbols Fangrui Song
2022-03-01 21:56 ` Fangrui Song
2022-03-09 0:15 ` [PING] " Fangrui Song
[not found] ` <CAN30aBFa+x5SpgE9HvY467jj2vR=YMUWrMVUq=yD723g5xh+mA@mail.gmail.com>
2022-03-16 1:12 ` Fangrui Song
[not found] ` <BN6PR1201MB00972ACA5F0D8900F1E72764CB119@BN6PR1201MB0097.namprd12.prod.outlook.com>
2022-03-16 13:54 ` Nick Clifton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).