This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] LD/testsuite: Fix undefined symbol tests for MIPS and S+core targets
- From: "Maciej W. Rozycki" <macro at imgtec dot com>
- To: <binutils at sourceware dot org>
- Cc: Alan Modra <amodra at gmail dot com>
- Date: Fri, 22 Sep 2017 01:05:11 +0100
- Subject: [PATCH] LD/testsuite: Fix undefined symbol tests for MIPS and S+core targets
- Authentication-results: sourceware.org; auth=none
Fix commit 647d4de92e06 ("Test undefined symbols in shared libraries")
and remove "undefined symbols in shared lib (dyn reloc)" test failures
for MIPS and S+core targets.
This test assumes 3 dynamic relocation entries, however the respective
psABIs define an extra single dummy *_NONE relocation at the beginning
of the dynamic relocation table, which results in test output like the
following for MIPS:
Relocation section '.rel.dyn' at offset 0x33c contains 4 entries:
Offset Info Type Sym.Value Sym. Name
00000000 00000000 R_MIPS_NONE
00010364 00000903 R_MIPS_REL32 00000000 undef_pfun
00010360 00000a03 R_MIPS_REL32 00000000 undef_data
00010368 00000b03 R_MIPS_REL32 00000000 undef_notype
and S+core:
Relocation section '.rel.dyn' at offset 0x274 contains 4 entries:
Offset Info Type Sym.Value Sym. Name
00000000 00000000 R_SCORE_NONE
5ffe0464 00000e12 R_SCORE_REL32 00000000 undef_notype
5ffe045c 00000f12 R_SCORE_REL32 00000000 undef_data
5ffe0460 00001012 R_SCORE_REL32 00000000 undef_pfun
targets respectively, and also n64 MIPS targets pad relocation triplets
they use with extra *_NONE relocations, resulting in output like this:
Relocation section '.rel.dyn' at offset 0x4c0 contains 4 entries:
Offset Info Type Sym. Value Sym. Name
000000000000 000000000000 R_MIPS_NONE
Type2: R_MIPS_NONE
Type3: R_MIPS_NONE
000000010508 000900001203 R_MIPS_REL32 0000000000000000 undef_pfun
Type2: R_MIPS_64
Type3: R_MIPS_NONE
000000010500 000a00001203 R_MIPS_REL32 0000000000000000 undef_data
Type2: R_MIPS_64
Type3: R_MIPS_NONE
000000010510 000b00001203 R_MIPS_REL32 0000000000000000 undef_notype
Type2: R_MIPS_64
Type3: R_MIPS_NONE
Expect the right number of *_NONE relocations then, and adjust the total
number of relocations expected accordingly.
ld/
* testsuite/ld-undefined/undefined.exp: Correct the dyn reloc
test for MIPS and S+core targets.
---
Hi,
This test also fails for `bfin-elf' and `bfin-uclinux':
There are no relocations in this file.
FAIL: undefined symbols in shared lib (dyn reloc)
and `i370-linux':
.../ld/ld-new: BFD (GNU Binutils) 2.29.51.20170919 assertion fail .../bfd/elf32-i370.c:988
[repeated 12 times]
FAIL: undefined symbols in shared lib
which I gather are genuine failures, so I haven't addressed them with this
patch.
This change corrects test results for `mips*-*-*' targets as well as
`score-elf', and causes no regressions against my usual targets. I will
apply it shortly unless I hear objections.
Maciej
---
ld/testsuite/ld-undefined/undefined.exp | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
binutils-mips-ld-test-undefined-reloc.diff
Index: binutils/ld/testsuite/ld-undefined/undefined.exp
===================================================================
--- binutils.orig/ld/testsuite/ld-undefined/undefined.exp 2017-08-24 20:36:16.000000000 +0100
+++ binutils/ld/testsuite/ld-undefined/undefined.exp 2017-09-21 20:54:39.451148187 +0100
@@ -195,10 +195,30 @@ if { ![is_elf_format] || ![check_shared_
set exec_output [run_host_cmd "$READELF" "-r tmpdir/fundef.so"]
set exec_output [prune_warnings $exec_output]
- # we ought to get two .rel{a}.plt and three .rel{a}.dyn relocs
+ # We ought to get two .rel{a}.plt and three .rel{a}.dyn relocs,
+ # except for MIPS targets whose psABI mandates an extra
+ # R_MIPS_NONE relocation, also used to pad n64 relocation
+ # triplets, and S+core targets using an extra R_SCORE_NONE
+ # relocation, so adjust for that.
+ switch -glob $target_triplet {
+ "mips64*-*-openbsd*" {
+ set none_count 6
+ set reloc_count 4
+ }
+ "mips*" -
+ "score*" {
+ set none_count 1
+ set reloc_count 4
+ }
+ "*" {
+ set none_count 0
+ set reloc_count 3
+ }
+ }
+
if { ($asflags == "" || [regexp ".* contains 2 .*" $exec_output])
- && [regexp ".* contains 3 .*" $exec_output]
- && ![regexp "_NONE" $exec_output]} then {
+ && [regexp ".* contains $reloc_count .*" $exec_output]
+ && [regexp -all "_NONE" $exec_output] == $none_count } then {
pass "$testname (dyn reloc)"
} else {
fail "$testname (dyn reloc)"