[PATCH] Fix riscv dwarf2-10 gas testsuite failure.

Jim Wilson jimw@sifive.com
Wed Nov 8 19:31:00 GMT 2017


On x86_64-linux, this testcase produces
  tmp.s: Error: view number mismatch
On riscv, this testcase produces
  tmp.s:26: Error: view number mismatch
The testcase accepts the first but not the second.

This testcase assumes that a .balign will produce an rs_align var frag, which
means symbol addresses can't be computed when we are processing the .loc view
directive.  So the error isn't detect until after relaxation, at which point we
have no line number info.

However, on riscv, we have linker relaxations that delete code, so we can't
handle alignment directives in the assembler, they must be deferred to the
linker.  This works by emitting the maximum possible nops that might be
required, and adding a linker relaxation that will then delete as many nops as
required to get the desired alignment.  In this case, no nops are needed so
none are emitted.  Since there is no var frag, we can compute symbol addresses
while processing the .loc view directive, immediately detect the error, and
print it with a line number.

Since the riscv handling is correct, it makes sense to fix the testcase to
accept an optional line number.

There are some cases where the riscv port might not handle views correctly.
If you have two views separated by a .balign 8, then the assembler will emit
one nop and the views will have different addresses.  If linker relaxation
causes the nop to be deleted, then the two views will have the same address
which is an error, but that won't be detected at link time.  I will worry about
this later if it actually happens in practice and causes trouble.

This was tested on x86_64-linux and riscv32-elf.  Both passed this test.

OK?

	gas/
	* testsuite/gas/elf/dwarf2-10.l: Accept optional line number in error.
---
 gas/testsuite/gas/elf/dwarf2-10.l | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gas/testsuite/gas/elf/dwarf2-10.l b/gas/testsuite/gas/elf/dwarf2-10.l
index b5f1f6549c..8a6cfe57fd 100644
--- a/gas/testsuite/gas/elf/dwarf2-10.l
+++ b/gas/testsuite/gas/elf/dwarf2-10.l
@@ -1,2 +1,2 @@
 [^:]*: Assembler messages:
-[^:]*: Error: view number mismatch
+[^:]*(:26)?: Error: view number mismatch
-- 
2.14.1



More information about the Binutils mailing list