This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[SH] Line numbers and delayed branches
- From: Andrew STUBBS <andrew dot stubbs at st dot com>
- To: binutils at sourceware dot org
- Date: Thu, 26 Oct 2006 17:13:41 +0100
- Subject: [SH] Line numbers and delayed branches
I have encountered a discrepancy between the source line numbers, as
specified by .loc directives, and the line numbers that are recorded in
the debug info.
I have a fix for this issue, but I am not confident that I have not
broken something else in some subtle way.
Given the following file, test.s:
--------------------------
.file 1 "test.c"
.text
.loc 1 2
nop
.loc 1 1000
bra 0f
nop
0:
--------------------------
I build and examine it like so:
$ ./gas/as-new -o test.o test.s
$ ./binutils/objdump -dl test.o
test.o: file format elf32-sh
Disassembly of section .text:
00000000 <.text>:
blah/test.c:2
0: 00 09 nop
2: a0 00 bra 0x6
blah/test.c:1000
4: 00 09 nop
Note that line '1000' starts one instruction late.
If I apply the attached patch I get the following change:
$ ./gas/as-new -o test.o test.s
$ ./binutils/objdump -dl test.o
test.o: file format elf32-sh
Disassembly of section .text:
00000000 <.text>:
blah/test.c:2
0: 00 09 nop
blah/test.c:1000
2: a0 00 bra 0x6
4: 00 09 nop
The line numbers are now how I would expect them to be.
Is this patch OK?
Andrew Stubbs
2006-10-26 Andrew Stubbs <andrew.stubbs@st.com>
* config/tc-sh.c (md_assemble): Define size of delayed branches.
Index: src/gas/config/tc-sh.c
===================================================================
--- src.orig/gas/config/tc-sh.c 2006-08-08 18:21:04.000000000 +0100
+++ src/gas/config/tc-sh.c 2006-10-26 17:00:16.000000000 +0100
@@ -2865,6 +2865,9 @@ md_assemble (char *str)
as_bad (_("Delayed branches not available on SH1"));
parse_exp (op_end + 1, &operand[0]);
build_relax (opcode, &operand[0]);
+
+ /* All delayed branches are currently 16 bit. */
+ size = 2;
}
else
{