[SH] Line numbers and delayed branches

Andrew STUBBS andrew.stubbs@st.com
Thu Oct 26 23:31:00 GMT 2006


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
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: linenumbers.patch
URL: <https://sourceware.org/pipermail/binutils/attachments/20061026/62d17d1c/attachment.ksh>


More information about the Binutils mailing list