This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[committed v2] LD: Fix .startof.SECNAME/.sizeof.SECNAME tests for MIPS/IRIX


Correct .startof.SECNAME/.sizeof.SECNAME tests for MIPS/IRIX targets, 
complementing commit dc74becf498f ("ld: Add tests for -Ur") and commit 
da614360f520 ("ld: Add tests for .startof.SECNAME/.sizeof.SECNAME") with 
subsequent updates, and in reference to commit cbd0eecf261c ("Always 
define referenced __start_SECNAME/__stop_SECNAME") and commit 
7dba9362c172 ("Rewrite __start and __stop symbol handling").

These targets set the STT_OBJECT type for non-function symbol 
references, according to `elf_frob_symbol' code in gas/config/obj-elf.c:

#ifdef TC_MIPS
  /* The Irix 5 and 6 assemblers set the type of any common symbol and
     any undefined non-function symbol to STT_OBJECT.  We try to be
     compatible, since newer Irix 5 and 6 linkers care.  However, we
     only set undefined symbols to be STT_OBJECT if we are on Irix,
     because that is the only time gcc will generate the necessary
     .global directives to mark functions.  */

  if (S_IS_COMMON (symp))
    symbol_get_bfdsym (symp)->flags |= BSF_OBJECT;

  if (strstr (TARGET_OS, "irix") != NULL
      && ! S_IS_DEFINED (symp)
      && (symbol_get_bfdsym (symp)->flags & BSF_FUNCTION) == 0)
    symbol_get_bfdsym (symp)->flags |= BSF_OBJECT;
#endif

and consequently entries in the symbol table listing from `readelf' 
produced with these tests do not match the NOTYPE pattern expected, 
causing test suite failures:

FAIL: ld-elf/sizeofa
FAIL: ld-elf/sizeofc
FAIL: ld-elf/startofa
FAIL: ld-elf/startofc

specifically with the `mips-sgi-irix5' and `mips-sgi-irix6' targets.  

Given that it does not matter for the feature covered by these tests 
whether the type of the symbols produced is STT_NOTYPE or STT_OBJECT 
adjust the problematic cases to accept either type, removing the 
failures observed.

	ld/
	* testsuite/ld-elf/sizeofa.d: Also accept the OBJECT type for 
	the symbols examined.
	* testsuite/ld-elf/sizeofc.d: Likewise.
	* testsuite/ld-elf/startofa.d: Likewise.
	* testsuite/ld-elf/startofc.d: Likewise.
---
On Fri, 23 Jun 2017, Alan Modra wrote:

> None, except that I personally wouldn't have added ?: to the start of
> the regexp.  Or if I did, do the same for other regexps in the file..

 I suspect there's a small (though likely insignificant) TCL interpreter's 
performance improvement for non-capturing parentheses, though I think it's 
mostly the matter of style.

 The change I proposed was originally made against a snapshot from before 
your updates, so I wrote it as I do from scratch and then haven't updated 
other than mechanically when forward-porting.  I agree with you though in 
that consistency has value, so I have decided to adapt to your style -- 
being an earlier change here -- and for the record applied the change as 
below.

 Thanks for your review.

  Maciej

binutils-ld-test-sizeof-irix.diff
Index: binutils/ld/testsuite/ld-elf/sizeofa.d
===================================================================
--- binutils.orig/ld/testsuite/ld-elf/sizeofa.d	2017-06-22 16:42:57.428050133 +0100
+++ binutils/ld/testsuite/ld-elf/sizeofa.d	2017-06-23 04:37:44.076746574 +0100
@@ -6,7 +6,7 @@
  +Num: +Value +Size Type +Bind +Vis +Ndx Name
  +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND +
 #...
- +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +(LOC|GLOB)AL +DEFAULT +[0-9]+ +___?stop_scnfoo
+ +[0-9]+: +[a-f0-9]+ +0 +(NOTYPE|OBJECT) +(LOC|GLOB)AL +DEFAULT +[0-9]+ +___?stop_scnfoo
 #...
- +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +UND +.sizeof.scnfoo
+ +[0-9]+: +[a-f0-9]+ +0 +(NOTYPE|OBJECT) +GLOBAL +DEFAULT +UND +.sizeof.scnfoo
 #pass
Index: binutils/ld/testsuite/ld-elf/sizeofc.d
===================================================================
--- binutils.orig/ld/testsuite/ld-elf/sizeofc.d	2017-06-22 16:42:57.468187254 +0100
+++ binutils/ld/testsuite/ld-elf/sizeofc.d	2017-06-23 04:37:51.694839852 +0100
@@ -6,7 +6,7 @@
  +Num: +Value +Size Type +Bind +Vis +Ndx Name
  +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND +
 #...
- +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +UND +___?stop_scnfoo
+ +[0-9]+: +[a-f0-9]+ +0 +(NOTYPE|OBJECT) +GLOBAL +DEFAULT +UND +___?stop_scnfoo
 #...
- +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +UND +.sizeof.scnfoo
+ +[0-9]+: +[a-f0-9]+ +0 +(NOTYPE|OBJECT) +GLOBAL +DEFAULT +UND +.sizeof.scnfoo
 #pass
Index: binutils/ld/testsuite/ld-elf/startofa.d
===================================================================
--- binutils.orig/ld/testsuite/ld-elf/startofa.d	2017-06-22 16:42:57.486521736 +0100
+++ binutils/ld/testsuite/ld-elf/startofa.d	2017-06-23 04:38:00.954659573 +0100
@@ -6,7 +6,7 @@
  +Num: +Value +Size Type +Bind +Vis +Ndx Name
  +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND +
 #...
- +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +(LOCAL +DEFAULT +[0-9]+ +___?start_scnfoo|GLOBAL +DEFAULT +UND +.startof.scnfoo)
+ +[0-9]+: +[a-f0-9]+ +0 +(NOTYPE|OBJECT) +(LOCAL +DEFAULT +[0-9]+ +___?start_scnfoo|GLOBAL +DEFAULT +UND +.startof.scnfoo)
 #...
- +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +(UND +.startof.scnfoo|[0-9]+ +___?start_scnfoo)
+ +[0-9]+: +[a-f0-9]+ +0 +(NOTYPE|OBJECT) +GLOBAL +DEFAULT +(UND +.startof.scnfoo|[0-9]+ +___?start_scnfoo)
 #pass
Index: binutils/ld/testsuite/ld-elf/startofc.d
===================================================================
--- binutils.orig/ld/testsuite/ld-elf/startofc.d	2017-06-22 16:42:57.531742986 +0100
+++ binutils/ld/testsuite/ld-elf/startofc.d	2017-06-23 04:38:06.103684421 +0100
@@ -6,7 +6,7 @@
  +Num: +Value +Size Type +Bind +Vis +Ndx Name
  +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND +
 #...
- +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +UND +.startof.scnfoo
+ +[0-9]+: +[a-f0-9]+ +0 +(NOTYPE|OBJECT) +GLOBAL +DEFAULT +UND +.startof.scnfoo
 #...
- +[0-9]+: +[a-f0-9]+ +0 +NOTYPE +GLOBAL +DEFAULT +UND +___?start_scnfoo
+ +[0-9]+: +[a-f0-9]+ +0 +(NOTYPE|OBJECT) +GLOBAL +DEFAULT +UND +___?start_scnfoo
 #pass


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]