DWARF why opcode base of 5?

196 views
Skip to first unread message

Graham King

unread,
Feb 26, 2014, 11:25:37 PM2/26/14
to golan...@googlegroups.com
Running `dwarfdump` against a Go program (latest head) fails to output the .debug_line section:

dwarfdump ERROR: dwarf_srclines: DW_DLE_LINE_NUM_OPERANDS_BAD (56)

This is because in cmd/ld/dwarf.c OPCODE_BASE is set to 5. dwarfdump expects opcode base to be at least 9, and errors out if it isn't. The dwarf 2 spec lists 9 standard opcodes (http://dwarfstd.org/doc/dwarf-2.0.0.pdf - Section 6.2.5.2 Standard Opcodes).

This is my first time looking at DWARF data (for issue 7369). Why does Go use 5 here? Is it just that we're not using standard opcodes 5-9?

This is on Ubuntu 13.10, dwarfdump Apr 10 2012. objdump, by contrast, seems to handle an opcode base of 5 just fine.

Thanks in advance,
Graham

Russ Cox

unread,
Feb 26, 2014, 11:44:30 PM2/26/14
to Graham King, golang-dev
The person who wrote dwarf.c is unavailable. Does it start working better if you set opcode base to 10? If so I'm happy to make that change.

Russ

Graham King

unread,
Feb 27, 2014, 12:23:17 AM2/27/14
to Russ Cox, golang-dev
Yes, it does actually!

Changing opcode base to 10, and adding the opcode lengths, gets dwarfdump to start printing .debug_lines and everything after. I'll submit a patch.

l...@gmail.com

unread,
Mar 7, 2014, 1:37:30 AM3/7/14
to golan...@googlegroups.com, Graham King


On Wednesday, February 26, 2014 8:44:30 PM UTC-8, rsc wrote:
The person who wrote dwarf.c is unavailable.

not anymore!

I wrote dwarf.c using the DWARF 3 document, (going back to make it dwarf2 only later to make gdb6 on Mac OS X happy), and i recall that there was some text that specifically allowed the opcode base to mask some of the special opcodes.  Since we don't use some of them and having a greater range available gave more compact tables, i chose the lowest possible.  But i can totally believe that some tools disagree with me on the interpretation of the standard, and i'm not sure who is wrong.
 
Does it start working better if you set opcode base to 10? If so I'm happy to make that change.

the impact should be slightly larger pc/ln tables.
 

Russ
Reply all
Reply to author
Forward
0 new messages