public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] testsuite: support mold linker
@ 2022-12-05 12:10 Martin Liška
  2022-12-05 12:22 ` Jan Beulich
  0 siblings, 1 reply; 15+ messages in thread
From: Martin Liška @ 2022-12-05 12:10 UTC (permalink / raw)
  To: binutils

Mold linker demotes symbols like main to be local and the patch
adjusts expected output from nm.

Ready to be installed?
Thanks,
Martin

---
 binutils/testsuite/binutils-all/addr2line.exp | 4 ++--
 binutils/testsuite/binutils-all/objcopy.exp   | 8 ++++----
 libbacktrace/Makefile.am                      | 2 +-
 libbacktrace/Makefile.in                      | 2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/binutils/testsuite/binutils-all/addr2line.exp b/binutils/testsuite/binutils-all/addr2line.exp
index 66a2d5d32a0..957ae55df33 100644
--- a/binutils/testsuite/binutils-all/addr2line.exp
+++ b/binutils/testsuite/binutils-all/addr2line.exp
@@ -34,7 +34,7 @@ if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog executable debug
 #testcase for default option.
 #Run nm command and input the main symbol address to addr2line.
 set output [binutils_run $NM "$opts tmpdir/testprog$exe"]
-if ![regexp -line "^(\[0-9a-fA-F\]+)? +T ${dot}main" $output contents] then {
+if ![regexp -line "^(\[0-9a-fA-F\]+)? +\[Tt\] ${dot}main" $output contents] then {
     fail "$testname"
 } else {
     set list [regexp -inline -all -- {\S+} $contents]
@@ -49,7 +49,7 @@ if ![regexp -line "^(\[0-9a-fA-F\]+)? +T ${dot}main" $output contents] then {
 
 #testcase for -f option.
 #Run nm command and input the fn function symbol address to addr2line.
-if ![regexp -line "^(\[0-9a-fA-F\]+)? +T ${dot}fn" $output contents] then {
+if ![regexp -line "^(\[0-9a-fA-F\]+)? +\[Tt\] ${dot}fn" $output contents] then {
     fail "$testname -f option"
 } else {
     set list [regexp -inline -all -- {\S+} $contents]
diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp
index de6f3aaaef2..9288506eee7 100644
--- a/binutils/testsuite/binutils-all/objcopy.exp
+++ b/binutils/testsuite/binutils-all/objcopy.exp
@@ -652,8 +652,8 @@ proc strip_test_with_saving_a_symbol { } {
 
     set exec_output [binutils_run $NM "$NMFLAGS $objfile"]
     set exec_output [prune_warnings $exec_output]
-    if {![regexp {^([0-9a-fA-F]+)?[ ]+[TD] main} $exec_output] \
-         && ![regexp {^([0-9a-fA-F]+)?[ ]+T _main} $exec_output]} {
+    if {![regexp {^([0-9a-fA-F]+)?[ ]+[tTD] main} $exec_output] \
+         && ![regexp {^([0-9a-fA-F]+)?[ ]+[tT] _main} $exec_output]} {
 	fail $test
 	return
     }
@@ -902,8 +902,8 @@ proc strip_executable_with_saving_a_symbol { prog flags test1 test2 } {
 	regsub "^\[0-9a-fA-F\]+\[ \]+T Main\[\n\r\]+" $exec_output "" exec_output
     }
 
-    if {![regexp {^([0-9a-fA-F]+)?[ ]+[TD] main} $exec_output] \
-         && ![regexp {^([0-9a-fA-F]+)?[ ]+[TD] _main} $exec_output]} {
+    if {![regexp {^([0-9a-fA-F]+)?[ ]+[TtD] main} $exec_output] \
+         && ![regexp {^([0-9a-fA-F]+)?[ ]+[TtD] _main} $exec_output]} {
 	fail $test1
 	return
     }
diff --git a/libbacktrace/Makefile.am b/libbacktrace/Makefile.am
index 8874f41338a..bf9d30a382c 100644
--- a/libbacktrace/Makefile.am
+++ b/libbacktrace/Makefile.am
@@ -498,7 +498,7 @@ TESTS += mtest_minidebug
 
 %_minidebug: %
 	$(NM) -D $< -P --defined-only | $(AWK) '{ print $$1 }' | sort > $<.dsyms
-	$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort > $<.fsyms
+	$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D" || $$2 == "d") print $$1 }' | sort > $<.fsyms
 	$(COMM) -13 $<.dsyms $<.fsyms > $<.keepsyms
 	$(OBJCOPY) --only-keep-debug $< $<.dbg
 	$(OBJCOPY) -S --remove-section .gdb_index --remove-section .comment --keep-symbols=$<.keepsyms $<.dbg $<.mdbg
diff --git a/libbacktrace/Makefile.in b/libbacktrace/Makefile.in
index 2ba8dfa8428..5167ca80ad1 100644
--- a/libbacktrace/Makefile.in
+++ b/libbacktrace/Makefile.in
@@ -2459,7 +2459,7 @@ uninstall-am:
 
 @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@%_minidebug: %
 @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@	$(NM) -D $< -P --defined-only | $(AWK) '{ print $$1 }' | sort > $<.dsyms
-@HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@	$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort > $<.fsyms
+@HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@	$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D" || $$2 == "d") print $$1 }' | sort > $<.fsyms
 @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@	$(COMM) -13 $<.dsyms $<.fsyms > $<.keepsyms
 @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@	$(OBJCOPY) --only-keep-debug $< $<.dbg
 @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@	$(OBJCOPY) -S --remove-section .gdb_index --remove-section .comment --keep-symbols=$<.keepsyms $<.dbg $<.mdbg
-- 
2.38.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] testsuite: support mold linker
  2022-12-05 12:10 [PATCH] testsuite: support mold linker Martin Liška
@ 2022-12-05 12:22 ` Jan Beulich
  2022-12-05 13:46   ` Martin Liška
  0 siblings, 1 reply; 15+ messages in thread
From: Jan Beulich @ 2022-12-05 12:22 UTC (permalink / raw)
  To: Martin Liška; +Cc: binutils

On 05.12.2022 13:10, Martin Liška wrote:
> --- a/binutils/testsuite/binutils-all/objcopy.exp
> +++ b/binutils/testsuite/binutils-all/objcopy.exp
> @@ -652,8 +652,8 @@ proc strip_test_with_saving_a_symbol { } {
>  
>      set exec_output [binutils_run $NM "$NMFLAGS $objfile"]
>      set exec_output [prune_warnings $exec_output]
> -    if {![regexp {^([0-9a-fA-F]+)?[ ]+[TD] main} $exec_output] \
> -         && ![regexp {^([0-9a-fA-F]+)?[ ]+T _main} $exec_output]} {
> +    if {![regexp {^([0-9a-fA-F]+)?[ ]+[tTD] main} $exec_output] \

Further below, for libbacktrace, you also include 'd' in the check (and 't'
was already there). Could you clarify why 't' alone isn't sufficient there,
but is sufficient here?

> +         && ![regexp {^([0-9a-fA-F]+)?[ ]+[tT] _main} $exec_output]} {

While orthogonal to the purpose of the patch I still wonder whether you
wouldn't better take the opportunity and fold the two regexp-s (also
elsewhere):

    if {![regexp {^[0-9a-fA-F]*[ ]+[tTD] _?main} $exec_output]} {

(with a simplification to the earlier part also included). Looking at
strip_executable_with_saving_a_symbol, which you also adjust, the [TtD]
vs [tT] difference looks to be accidental rather than deliberate.

Jan

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH] testsuite: support mold linker
  2022-12-05 12:22 ` Jan Beulich
@ 2022-12-05 13:46   ` Martin Liška
  2022-12-05 13:48     ` [PATCH V2] " Martin Liška
  0 siblings, 1 reply; 15+ messages in thread
From: Martin Liška @ 2022-12-05 13:46 UTC (permalink / raw)
  To: Jan Beulich; +Cc: binutils

On 12/5/22 13:22, Jan Beulich wrote:
> On 05.12.2022 13:10, Martin Liška wrote:
>> --- a/binutils/testsuite/binutils-all/objcopy.exp
>> +++ b/binutils/testsuite/binutils-all/objcopy.exp
>> @@ -652,8 +652,8 @@ proc strip_test_with_saving_a_symbol { } {
>>  
>>      set exec_output [binutils_run $NM "$NMFLAGS $objfile"]
>>      set exec_output [prune_warnings $exec_output]
>> -    if {![regexp {^([0-9a-fA-F]+)?[ ]+[TD] main} $exec_output] \
>> -         && ![regexp {^([0-9a-fA-F]+)?[ ]+T _main} $exec_output]} {
>> +    if {![regexp {^([0-9a-fA-F]+)?[ ]+[tTD] main} $exec_output] \
> 
> Further below, for libbacktrace, you also include 'd' in the check (and 't'
> was already there). Could you clarify why 't' alone isn't sufficient there,
> but is sufficient here?

Yeah, it is sufficient.

> 
>> +         && ![regexp {^([0-9a-fA-F]+)?[ ]+[tT] _main} $exec_output]} {
> 
> While orthogonal to the purpose of the patch I still wonder whether you
> wouldn't better take the opportunity and fold the two regexp-s (also
> elsewhere):
> 
>     if {![regexp {^[0-9a-fA-F]*[ ]+[tTD] _?main} $exec_output]} {

Yep, works for me.

> 
> (with a simplification to the earlier part also included). Looking at
> strip_executable_with_saving_a_symbol, which you also adjust, the [TtD]
> vs [tT] difference looks to be accidental rather than deliberate.

Correct, D is really accidental value here.

Lemme send V2.

Martin

> 
> Jan


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH V2] testsuite: support mold linker
  2022-12-05 13:46   ` Martin Liška
@ 2022-12-05 13:48     ` Martin Liška
  2022-12-05 14:08       ` Jan Beulich
  0 siblings, 1 reply; 15+ messages in thread
From: Martin Liška @ 2022-12-05 13:48 UTC (permalink / raw)
  To: binutils; +Cc: Jan Beulich

Mold linker demotes symbols like main to be local and the patch
adjusts expected output from nm.

Moreover, simplify the patterns and remove accidental type 'D' that
is supported value for _?main functions.
---
 binutils/testsuite/binutils-all/addr2line.exp | 4 ++--
 binutils/testsuite/binutils-all/objcopy.exp   | 6 ++----
 libbacktrace/Makefile.am                      | 2 +-
 libbacktrace/Makefile.in                      | 2 +-
 4 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/binutils/testsuite/binutils-all/addr2line.exp b/binutils/testsuite/binutils-all/addr2line.exp
index 66a2d5d32a0..957ae55df33 100644
--- a/binutils/testsuite/binutils-all/addr2line.exp
+++ b/binutils/testsuite/binutils-all/addr2line.exp
@@ -34,7 +34,7 @@ if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog executable debug
 #testcase for default option.
 #Run nm command and input the main symbol address to addr2line.
 set output [binutils_run $NM "$opts tmpdir/testprog$exe"]
-if ![regexp -line "^(\[0-9a-fA-F\]+)? +T ${dot}main" $output contents] then {
+if ![regexp -line "^(\[0-9a-fA-F\]+)? +\[Tt\] ${dot}main" $output contents] then {
     fail "$testname"
 } else {
     set list [regexp -inline -all -- {\S+} $contents]
@@ -49,7 +49,7 @@ if ![regexp -line "^(\[0-9a-fA-F\]+)? +T ${dot}main" $output contents] then {
 
 #testcase for -f option.
 #Run nm command and input the fn function symbol address to addr2line.
-if ![regexp -line "^(\[0-9a-fA-F\]+)? +T ${dot}fn" $output contents] then {
+if ![regexp -line "^(\[0-9a-fA-F\]+)? +\[Tt\] ${dot}fn" $output contents] then {
     fail "$testname -f option"
 } else {
     set list [regexp -inline -all -- {\S+} $contents]
diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp
index de6f3aaaef2..7a1a36b9b57 100644
--- a/binutils/testsuite/binutils-all/objcopy.exp
+++ b/binutils/testsuite/binutils-all/objcopy.exp
@@ -652,8 +652,7 @@ proc strip_test_with_saving_a_symbol { } {
 
     set exec_output [binutils_run $NM "$NMFLAGS $objfile"]
     set exec_output [prune_warnings $exec_output]
-    if {![regexp {^([0-9a-fA-F]+)?[ ]+[TD] main} $exec_output] \
-         && ![regexp {^([0-9a-fA-F]+)?[ ]+T _main} $exec_output]} {
+    if {![regexp {^([0-9a-fA-F]+)?[ ]+[tT] _?main} $exec_output]} {
 	fail $test
 	return
     }
@@ -902,8 +901,7 @@ proc strip_executable_with_saving_a_symbol { prog flags test1 test2 } {
 	regsub "^\[0-9a-fA-F\]+\[ \]+T Main\[\n\r\]+" $exec_output "" exec_output
     }
 
-    if {![regexp {^([0-9a-fA-F]+)?[ ]+[TD] main} $exec_output] \
-         && ![regexp {^([0-9a-fA-F]+)?[ ]+[TD] _main} $exec_output]} {
+    if {![regexp {^([0-9a-fA-F]+)?[ ]+[Tt] _?main} $exec_output]} {
 	fail $test1
 	return
     }
diff --git a/libbacktrace/Makefile.am b/libbacktrace/Makefile.am
index 8874f41338a..bf9d30a382c 100644
--- a/libbacktrace/Makefile.am
+++ b/libbacktrace/Makefile.am
@@ -498,7 +498,7 @@ TESTS += mtest_minidebug
 
 %_minidebug: %
 	$(NM) -D $< -P --defined-only | $(AWK) '{ print $$1 }' | sort > $<.dsyms
-	$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort > $<.fsyms
+	$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D" || $$2 == "d") print $$1 }' | sort > $<.fsyms
 	$(COMM) -13 $<.dsyms $<.fsyms > $<.keepsyms
 	$(OBJCOPY) --only-keep-debug $< $<.dbg
 	$(OBJCOPY) -S --remove-section .gdb_index --remove-section .comment --keep-symbols=$<.keepsyms $<.dbg $<.mdbg
diff --git a/libbacktrace/Makefile.in b/libbacktrace/Makefile.in
index 2ba8dfa8428..5167ca80ad1 100644
--- a/libbacktrace/Makefile.in
+++ b/libbacktrace/Makefile.in
@@ -2459,7 +2459,7 @@ uninstall-am:
 
 @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@%_minidebug: %
 @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@	$(NM) -D $< -P --defined-only | $(AWK) '{ print $$1 }' | sort > $<.dsyms
-@HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@	$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort > $<.fsyms
+@HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@	$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D" || $$2 == "d") print $$1 }' | sort > $<.fsyms
 @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@	$(COMM) -13 $<.dsyms $<.fsyms > $<.keepsyms
 @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@	$(OBJCOPY) --only-keep-debug $< $<.dbg
 @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@	$(OBJCOPY) -S --remove-section .gdb_index --remove-section .comment --keep-symbols=$<.keepsyms $<.dbg $<.mdbg
-- 
2.38.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH V2] testsuite: support mold linker
  2022-12-05 13:48     ` [PATCH V2] " Martin Liška
@ 2022-12-05 14:08       ` Jan Beulich
  2022-12-05 14:24         ` Martin Liška
  2022-12-05 14:25         ` Jakub Jelinek
  0 siblings, 2 replies; 15+ messages in thread
From: Jan Beulich @ 2022-12-05 14:08 UTC (permalink / raw)
  To: Martin Liška; +Cc: binutils, Jakub Jelinek

On 05.12.2022 14:48, Martin Liška wrote:
> Mold linker demotes symbols like main to be local and the patch
> adjusts expected output from nm.
> 
> Moreover, simplify the patterns and remove accidental type 'D' that
> is supported value for _?main functions.

Hmm, in my v1 comment I've said "accidental" to the difference, not
to the presence of D. In fact I was expecting you to uniformly use
[TtDd] everywhere. See also adacfc818440 (sadly without any real
description). (That commit is also where [some of] the odd ([...]+)?
regexp constructs were introduced.) Cc-ing Jakub in case he recalls
background.

Furthermore I now even less understand ...

> --- a/libbacktrace/Makefile.am
> +++ b/libbacktrace/Makefile.am
> @@ -498,7 +498,7 @@ TESTS += mtest_minidebug
>  
>  %_minidebug: %
>  	$(NM) -D $< -P --defined-only | $(AWK) '{ print $$1 }' | sort > $<.dsyms
> -	$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort > $<.fsyms
> +	$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D" || $$2 == "d") print $$1 }' | sort > $<.fsyms

... this part of the change, where - as in v1 - you add a check for
'd', while a check for 't' (which supposedly is what you're after)
was already there.

Jan

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH V2] testsuite: support mold linker
  2022-12-05 14:08       ` Jan Beulich
@ 2022-12-05 14:24         ` Martin Liška
  2022-12-05 14:48           ` Jan Beulich
  2022-12-05 14:25         ` Jakub Jelinek
  1 sibling, 1 reply; 15+ messages in thread
From: Martin Liška @ 2022-12-05 14:24 UTC (permalink / raw)
  To: Jan Beulich; +Cc: binutils, Jakub Jelinek

On 12/5/22 15:08, Jan Beulich wrote:
> On 05.12.2022 14:48, Martin Liška wrote:
>> Mold linker demotes symbols like main to be local and the patch
>> adjusts expected output from nm.
>>
>> Moreover, simplify the patterns and remove accidental type 'D' that
>> is supported value for _?main functions.
> 
> Hmm, in my v1 comment I've said "accidental" to the difference, not
> to the presence of D. In fact I was expecting you to uniformly use
> [TtDd] everywhere. See also adacfc818440 (sadly without any real
> description). (That commit is also where [some of] the odd ([...]+)?
> regexp constructs were introduced.) Cc-ing Jakub in case he recalls
> background.

Oh, I'm also curious why 'D' was added in the revision.

> 
> Furthermore I now even less understand ...
> 
>> --- a/libbacktrace/Makefile.am
>> +++ b/libbacktrace/Makefile.am
>> @@ -498,7 +498,7 @@ TESTS += mtest_minidebug
>>  
>>  %_minidebug: %
>>  	$(NM) -D $< -P --defined-only | $(AWK) '{ print $$1 }' | sort > $<.dsyms
>> -	$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort > $<.fsyms
>> +	$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D" || $$2 == "d") print $$1 }' | sort > $<.fsyms
> 
> ... this part of the change, where - as in v1 - you add a check for
> 'd', while a check for 't' (which supposedly is what you're after)
> was already there.

This nm invocation is supposed to save dynamic symbols (.dyns) and normal symbols ('.fsyms'),
where .fsymc contains both data and functions.

The symbol which I need to properly list is:

mtest.c:int global = 1;

which gets 'b' with mold linker.

Martin

> 
> Jan


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH V2] testsuite: support mold linker
  2022-12-05 14:08       ` Jan Beulich
  2022-12-05 14:24         ` Martin Liška
@ 2022-12-05 14:25         ` Jakub Jelinek
  2022-12-05 14:41           ` [PATCH V3] " Martin Liška
  1 sibling, 1 reply; 15+ messages in thread
From: Jakub Jelinek @ 2022-12-05 14:25 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Martin Liška, binutils

On Mon, Dec 05, 2022 at 03:08:58PM +0100, Jan Beulich wrote:
> On 05.12.2022 14:48, Martin Liška wrote:
> > Mold linker demotes symbols like main to be local and the patch
> > adjusts expected output from nm.
> > 
> > Moreover, simplify the patterns and remove accidental type 'D' that
> > is supported value for _?main functions.
> 
> Hmm, in my v1 comment I've said "accidental" to the difference, not
> to the presence of D. In fact I was expecting you to uniformly use
> [TtDd] everywhere. See also adacfc818440 (sadly without any real
> description). (That commit is also where [some of] the odd ([...]+)?
> regexp constructs were introduced.) Cc-ing Jakub in case he recalls
> background.

Only thing I found was
https://sourceware.org/pipermail/binutils/2004-March/033799.html
so it was ppc64.  Seems even these days ppc64 function symbols are
printed as D by nm (those symbols are in .opd section, which contains
the function descriptors).

	Jakub


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH V3] testsuite: support mold linker
  2022-12-05 14:25         ` Jakub Jelinek
@ 2022-12-05 14:41           ` Martin Liška
  2022-12-05 14:50             ` Jan Beulich
  0 siblings, 1 reply; 15+ messages in thread
From: Martin Liška @ 2022-12-05 14:41 UTC (permalink / raw)
  To: binutils

Mold linker demotes symbols like main to be local and the patch
adjusts expected output from nm.

Moreover, simplify the regex patterns.
---
 binutils/testsuite/binutils-all/addr2line.exp | 4 ++--
 binutils/testsuite/binutils-all/objcopy.exp   | 6 ++----
 libbacktrace/Makefile.am                      | 2 +-
 libbacktrace/Makefile.in                      | 2 +-
 4 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/binutils/testsuite/binutils-all/addr2line.exp b/binutils/testsuite/binutils-all/addr2line.exp
index 66a2d5d32a0..957ae55df33 100644
--- a/binutils/testsuite/binutils-all/addr2line.exp
+++ b/binutils/testsuite/binutils-all/addr2line.exp
@@ -34,7 +34,7 @@ if { [target_compile $srcdir/$subdir/testprog.c tmpdir/testprog executable debug
 #testcase for default option.
 #Run nm command and input the main symbol address to addr2line.
 set output [binutils_run $NM "$opts tmpdir/testprog$exe"]
-if ![regexp -line "^(\[0-9a-fA-F\]+)? +T ${dot}main" $output contents] then {
+if ![regexp -line "^(\[0-9a-fA-F\]+)? +\[Tt\] ${dot}main" $output contents] then {
     fail "$testname"
 } else {
     set list [regexp -inline -all -- {\S+} $contents]
@@ -49,7 +49,7 @@ if ![regexp -line "^(\[0-9a-fA-F\]+)? +T ${dot}main" $output contents] then {
 
 #testcase for -f option.
 #Run nm command and input the fn function symbol address to addr2line.
-if ![regexp -line "^(\[0-9a-fA-F\]+)? +T ${dot}fn" $output contents] then {
+if ![regexp -line "^(\[0-9a-fA-F\]+)? +\[Tt\] ${dot}fn" $output contents] then {
     fail "$testname -f option"
 } else {
     set list [regexp -inline -all -- {\S+} $contents]
diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp
index de6f3aaaef2..e3388597f56 100644
--- a/binutils/testsuite/binutils-all/objcopy.exp
+++ b/binutils/testsuite/binutils-all/objcopy.exp
@@ -652,8 +652,7 @@ proc strip_test_with_saving_a_symbol { } {
 
     set exec_output [binutils_run $NM "$NMFLAGS $objfile"]
     set exec_output [prune_warnings $exec_output]
-    if {![regexp {^([0-9a-fA-F]+)?[ ]+[TD] main} $exec_output] \
-         && ![regexp {^([0-9a-fA-F]+)?[ ]+T _main} $exec_output]} {
+    if {![regexp {^([0-9a-fA-F]+)?[ ]+[TtDd] _?main} $exec_output]} {
 	fail $test
 	return
     }
@@ -902,8 +901,7 @@ proc strip_executable_with_saving_a_symbol { prog flags test1 test2 } {
 	regsub "^\[0-9a-fA-F\]+\[ \]+T Main\[\n\r\]+" $exec_output "" exec_output
     }
 
-    if {![regexp {^([0-9a-fA-F]+)?[ ]+[TD] main} $exec_output] \
-         && ![regexp {^([0-9a-fA-F]+)?[ ]+[TD] _main} $exec_output]} {
+    if {![regexp {^([0-9a-fA-F]+)?[ ]+[TtDd] _?main} $exec_output]} {
 	fail $test1
 	return
     }
diff --git a/libbacktrace/Makefile.am b/libbacktrace/Makefile.am
index 8874f41338a..bf9d30a382c 100644
--- a/libbacktrace/Makefile.am
+++ b/libbacktrace/Makefile.am
@@ -498,7 +498,7 @@ TESTS += mtest_minidebug
 
 %_minidebug: %
 	$(NM) -D $< -P --defined-only | $(AWK) '{ print $$1 }' | sort > $<.dsyms
-	$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort > $<.fsyms
+	$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D" || $$2 == "d") print $$1 }' | sort > $<.fsyms
 	$(COMM) -13 $<.dsyms $<.fsyms > $<.keepsyms
 	$(OBJCOPY) --only-keep-debug $< $<.dbg
 	$(OBJCOPY) -S --remove-section .gdb_index --remove-section .comment --keep-symbols=$<.keepsyms $<.dbg $<.mdbg
diff --git a/libbacktrace/Makefile.in b/libbacktrace/Makefile.in
index 2ba8dfa8428..5167ca80ad1 100644
--- a/libbacktrace/Makefile.in
+++ b/libbacktrace/Makefile.in
@@ -2459,7 +2459,7 @@ uninstall-am:
 
 @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@%_minidebug: %
 @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@	$(NM) -D $< -P --defined-only | $(AWK) '{ print $$1 }' | sort > $<.dsyms
-@HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@	$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort > $<.fsyms
+@HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@	$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D" || $$2 == "d") print $$1 }' | sort > $<.fsyms
 @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@	$(COMM) -13 $<.dsyms $<.fsyms > $<.keepsyms
 @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@	$(OBJCOPY) --only-keep-debug $< $<.dbg
 @HAVE_MINIDEBUG_TRUE@@NATIVE_TRUE@	$(OBJCOPY) -S --remove-section .gdb_index --remove-section .comment --keep-symbols=$<.keepsyms $<.dbg $<.mdbg
-- 
2.38.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH V2] testsuite: support mold linker
  2022-12-05 14:24         ` Martin Liška
@ 2022-12-05 14:48           ` Jan Beulich
  2022-12-05 14:52             ` Martin Liška
  0 siblings, 1 reply; 15+ messages in thread
From: Jan Beulich @ 2022-12-05 14:48 UTC (permalink / raw)
  To: Martin Liška; +Cc: binutils, Jakub Jelinek

On 05.12.2022 15:24, Martin Liška wrote:
> On 12/5/22 15:08, Jan Beulich wrote:
>> On 05.12.2022 14:48, Martin Liška wrote:
>> Furthermore I now even less understand ...
>>
>>> --- a/libbacktrace/Makefile.am
>>> +++ b/libbacktrace/Makefile.am
>>> @@ -498,7 +498,7 @@ TESTS += mtest_minidebug
>>>  
>>>  %_minidebug: %
>>>  	$(NM) -D $< -P --defined-only | $(AWK) '{ print $$1 }' | sort > $<.dsyms
>>> -	$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort > $<.fsyms
>>> +	$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D" || $$2 == "d") print $$1 }' | sort > $<.fsyms
>>
>> ... this part of the change, where - as in v1 - you add a check for
>> 'd', while a check for 't' (which supposedly is what you're after)
>> was already there.
> 
> This nm invocation is supposed to save dynamic symbols (.dyns) and normal symbols ('.fsyms'),
> where .fsymc contains both data and functions.
> 
> The symbol which I need to properly list is:
> 
> mtest.c:int global = 1;
> 
> which gets 'b' with mold linker.

Yet then 'b' != 'd', and this is unrelated to "main" (which is the only
thing you mention in the description)?

Jan

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH V3] testsuite: support mold linker
  2022-12-05 14:41           ` [PATCH V3] " Martin Liška
@ 2022-12-05 14:50             ` Jan Beulich
  2022-12-07  0:36               ` Fangrui Song
  0 siblings, 1 reply; 15+ messages in thread
From: Jan Beulich @ 2022-12-05 14:50 UTC (permalink / raw)
  To: Martin Liška; +Cc: binutils

On 05.12.2022 15:41, Martin Liška wrote:
> Mold linker demotes symbols like main to be local and the patch
> adjusts expected output from nm.
> 
> Moreover, simplify the regex patterns.

Okay.

Jan


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH V2] testsuite: support mold linker
  2022-12-05 14:48           ` Jan Beulich
@ 2022-12-05 14:52             ` Martin Liška
  2022-12-05 15:13               ` Jan Beulich
  0 siblings, 1 reply; 15+ messages in thread
From: Martin Liška @ 2022-12-05 14:52 UTC (permalink / raw)
  To: Jan Beulich; +Cc: binutils, Jakub Jelinek

On 12/5/22 15:48, Jan Beulich wrote:
> On 05.12.2022 15:24, Martin Liška wrote:
>> On 12/5/22 15:08, Jan Beulich wrote:
>>> On 05.12.2022 14:48, Martin Liška wrote:
>>> Furthermore I now even less understand ...
>>>
>>>> --- a/libbacktrace/Makefile.am
>>>> +++ b/libbacktrace/Makefile.am
>>>> @@ -498,7 +498,7 @@ TESTS += mtest_minidebug
>>>>  
>>>>  %_minidebug: %
>>>>  	$(NM) -D $< -P --defined-only | $(AWK) '{ print $$1 }' | sort > $<.dsyms
>>>> -	$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort > $<.fsyms
>>>> +	$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D" || $$2 == "d") print $$1 }' | sort > $<.fsyms
>>>
>>> ... this part of the change, where - as in v1 - you add a check for
>>> 'd', while a check for 't' (which supposedly is what you're after)
>>> was already there.
>>
>> This nm invocation is supposed to save dynamic symbols (.dyns) and normal symbols ('.fsyms'),
>> where .fsymc contains both data and functions.
>>
>> The symbol which I need to properly list is:
>>
>> mtest.c:int global = 1;
>>
>> which gets 'b' with mold linker.
> 
> Yet then 'b' != 'd',

Sure, 'd' should be there.

> and this is unrelated to "main" (which is the only
> thing you mention in the description)?

I mentioned 'symbols like main', so would it be better mentioning
'global symbols and variables'?

Thanks,
Martin

> 
> Jan


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH V2] testsuite: support mold linker
  2022-12-05 14:52             ` Martin Liška
@ 2022-12-05 15:13               ` Jan Beulich
  0 siblings, 0 replies; 15+ messages in thread
From: Jan Beulich @ 2022-12-05 15:13 UTC (permalink / raw)
  To: Martin Liška; +Cc: binutils, Jakub Jelinek

On 05.12.2022 15:52, Martin Liška wrote:
> On 12/5/22 15:48, Jan Beulich wrote:
>> On 05.12.2022 15:24, Martin Liška wrote:
>>> On 12/5/22 15:08, Jan Beulich wrote:
>>>> On 05.12.2022 14:48, Martin Liška wrote:
>>>> Furthermore I now even less understand ...
>>>>
>>>>> --- a/libbacktrace/Makefile.am
>>>>> +++ b/libbacktrace/Makefile.am
>>>>> @@ -498,7 +498,7 @@ TESTS += mtest_minidebug
>>>>>  
>>>>>  %_minidebug: %
>>>>>  	$(NM) -D $< -P --defined-only | $(AWK) '{ print $$1 }' | sort > $<.dsyms
>>>>> -	$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D") print $$1 }' | sort > $<.fsyms
>>>>> +	$(NM) $< -P --defined-only | $(AWK) '{ if ($$2 == "T" || $$2 == "t" || $$2 == "D" || $$2 == "d") print $$1 }' | sort > $<.fsyms
>>>>
>>>> ... this part of the change, where - as in v1 - you add a check for
>>>> 'd', while a check for 't' (which supposedly is what you're after)
>>>> was already there.
>>>
>>> This nm invocation is supposed to save dynamic symbols (.dyns) and normal symbols ('.fsyms'),
>>> where .fsymc contains both data and functions.
>>>
>>> The symbol which I need to properly list is:
>>>
>>> mtest.c:int global = 1;
>>>
>>> which gets 'b' with mold linker.
>>
>> Yet then 'b' != 'd',
> 
> Sure, 'd' should be there.
> 
>> and this is unrelated to "main" (which is the only
>> thing you mention in the description)?
> 
> I mentioned 'symbols like main', so would it be better mentioning
> 'global symbols and variables'?

Well, apologies - I didn't properly read that sentence, ignoring in
particular the "like". But of course your alternative text sounds
overall better to me ...

Jan

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH V3] testsuite: support mold linker
  2022-12-05 14:50             ` Jan Beulich
@ 2022-12-07  0:36               ` Fangrui Song
  2022-12-07  0:42                 ` Fangrui Song
  2022-12-07 13:01                 ` Martin Liška
  0 siblings, 2 replies; 15+ messages in thread
From: Fangrui Song @ 2022-12-07  0:36 UTC (permalink / raw)
  To: Jan Beulich; +Cc: Martin Liška, binutils

On 2022-12-05, Jan Beulich via Binutils wrote:
>On 05.12.2022 15:41, Martin Liška wrote:
>> Mold linker demotes symbols like main to be local and the patch
>> adjusts expected output from nm.
>>
>> Moreover, simplify the regex patterns.
>
>Okay.
>
>Jan
>

Not okai to me.  mold seems to wrongly make `main` STB_LOCAL while it
has default visibility which should stay STB_GLOBAL.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH V3] testsuite: support mold linker
  2022-12-07  0:36               ` Fangrui Song
@ 2022-12-07  0:42                 ` Fangrui Song
  2022-12-07 13:01                 ` Martin Liška
  1 sibling, 0 replies; 15+ messages in thread
From: Fangrui Song @ 2022-12-07  0:42 UTC (permalink / raw)
  To: Martin Liška; +Cc: Jan Beulich, binutils


On 2022-12-06, Fangrui Song wrote:
>On 2022-12-05, Jan Beulich via Binutils wrote:
>>On 05.12.2022 15:41, Martin Liška wrote:
>>>Mold linker demotes symbols like main to be local and the patch
>>>adjusts expected output from nm.
>>>
>>>Moreover, simplify the regex patterns.
>>
>>Okay.
>>
>>Jan
>>
>
>Not okai to me.  mold seems to wrongly make `main` STB_LOCAL while it
>has default visibility which should stay STB_GLOBAL.

Filed https://github.com/rui314/mold/issues/906

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH V3] testsuite: support mold linker
  2022-12-07  0:36               ` Fangrui Song
  2022-12-07  0:42                 ` Fangrui Song
@ 2022-12-07 13:01                 ` Martin Liška
  1 sibling, 0 replies; 15+ messages in thread
From: Martin Liška @ 2022-12-07 13:01 UTC (permalink / raw)
  To: Fangrui Song, Jan Beulich; +Cc: binutils

On 12/7/22 01:36, Fangrui Song wrote:
> On 2022-12-05, Jan Beulich via Binutils wrote:
>> On 05.12.2022 15:41, Martin Liška wrote:
>>> Mold linker demotes symbols like main to be local and the patch
>>> adjusts expected output from nm.
>>>
>>> Moreover, simplify the regex patterns.
>>
>> Okay.
>>
>> Jan
>>
> 
> Not okai to me.  mold seems to wrongly make `main` STB_LOCAL while it
> has default visibility which should stay STB_GLOBAL.

Sure, I noticed that but thought it's a correct optimization a linker can do.

Anyway, I'm ready to revert this once the mold issue is somehow resolved.

Thanks for heads up,
Martin

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2022-12-07 13:01 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-05 12:10 [PATCH] testsuite: support mold linker Martin Liška
2022-12-05 12:22 ` Jan Beulich
2022-12-05 13:46   ` Martin Liška
2022-12-05 13:48     ` [PATCH V2] " Martin Liška
2022-12-05 14:08       ` Jan Beulich
2022-12-05 14:24         ` Martin Liška
2022-12-05 14:48           ` Jan Beulich
2022-12-05 14:52             ` Martin Liška
2022-12-05 15:13               ` Jan Beulich
2022-12-05 14:25         ` Jakub Jelinek
2022-12-05 14:41           ` [PATCH V3] " Martin Liška
2022-12-05 14:50             ` Jan Beulich
2022-12-07  0:36               ` Fangrui Song
2022-12-07  0:42                 ` Fangrui Song
2022-12-07 13:01                 ` Martin Liška

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).