当尝试使用objdump生成汇编代码(与源代码混合)时,
gcc -g -c test.c ;
objdump -S -M intel test.o > out.asm
我得到以下错误。
BFD: Dwarf Error: mangled line number section.
生成的输出程序集不会与源代码混合。有人能解释一下这是什么意思吗?有什么办法可以解决这个问题吗?
发布于 2012-11-29 04:40:59
"objdump -S -M“显然期望在.o文件中有一个".debug_abbrev .o”部分,而"gcc -g“显然没有编写它:
我认为你对此无能为力(你已经在使用"-g“来包含调试符号了)。我认为完全可以忽略这一点。
有问题的包是"binutils“。下面是完整的代码:
http://opensource.apple.com/source/binutils/binutils-20/src/bfd/dwarf2.c
/* In DWARF version 2, the description of the debugging information is
stored in a separate .debug_abbrev section. Before we read any
dies from a section we read in all abbreviations and install them
in a hash table. */
static struct abbrev_info**
read_abbrevs (abfd, offset)
bfd * abfd;
unsigned int offset;
{
struct abbrev_info **abbrevs;
char *abbrev_ptr;
struct abbrev_info *cur_abbrev;
unsigned int abbrev_number, bytes_read, abbrev_name;
unsigned int abbrev_form, hash_number;
struct dwarf2_debug *stash;
stash = elf_tdata(abfd)->dwarf2_find_line_info;
if (! stash->dwarf_abbrev_buffer)
{
asection *msec;
msec = bfd_get_section_by_name (abfd, ".debug_abbrev");
if (! msec)
{
(*_bfd_error_handler) (_("Dwarf Error: Can't find .debug_abbrev section."));
bfd_set_error (bfd_error_bad_value);
return 0;
}
发布于 2017-05-23 08:32:53
此问题通常在.debug_line部分显示由链接器(ld)编码问题引起的重定位表问题--重叠内存复制。工具链需要一个bug修复和重建。
它不会影响程序的加载和运行,但这个问题会因为地址/符号不匹配而导致无法调试。这是一个例子,代码在0x0038ca82处被损坏(在错误的链接器情况下)。
0038ca80 00 = op_code = DW_LNS_extended_op
0038ca81 05 = op length = 5 bytes
0038ca82 02 = extended_op_code = DW_LNE_set_address
0038ca83 nn nn nn nn = 4-byte address
在有问题链接的ELF中,扩展操作码(32未定义)
0038ca82 32 = extended_op_code = Unknown -> mangled line number section
问题% ld导致ELF (损坏的行号部分):
0038ca60 62 6c 69 63 2e 68 00 01 00 00 68 65 61 70 5f 6d |blic.h....heap_m|
0038ca70 67 72 5f 70 75 62 6c 69 63 2e 68 00 02 00 00 00 |gr_public.h.....|
0038ca80 00 05 32 00 40 18 02 94 32 00 40 00 01 01 00 05 |..2.@...2.@.....|
0038ca90 02 94 32 00 40 00 01 01 00 05 02 94 32 00 40 00 |..2.@.......2.@.|
0038caa0 01 01 00 05 32 00 40 15 02 b0 32 00 40 00 01 01 |....2.@...2.@...|
0038cab0 00 05 02 b0 32 00 40 00 01 01 00 05 02 b0 32 00 |....2.@.......2.|
0038cac0 40 00 01 01 00 05 02 c0 32 00 40 94 00 05 40 17 |@.......2.@...@.|
正常的ld结果ELF:
0038ca60 62 6c 69 63 2e 68 00 01 00 00 68 65 61 70 5f 6d |blic.h....heap_m|
0038ca70 67 72 5f 70 75 62 6c 69 63 2e 68 00 02 00 00 00 |gr_public.h.....|
0038ca80 00 05 02 80 32 00 40 38 00 05 02 80 32 00 40 18 |....2.@8....2.@.|
0038ca90 00 05 02 90 32 00 40 1a 00 05 02 94 32 00 40 00 |....2.@.....2.@.|
0038caa0 01 01 00 05 02 a0 32 00 40 49 00 05 02 a0 32 00 |......2.@I....2.|
0038cab0 40 15 00 05 02 ac 32 00 40 15 00 05 02 b0 32 00 |@.....2.@.....2.|
0038cac0 40 00 01 01 00 05 02 c0 32 00 40 94 00 05 02 c0 |@.......2.@.....|
https://stackoverflow.com/questions/13613820
复制相似问题