Objdump / GCC - BFD:Dwarf Error:错误的行号部分

问题描述 投票:0回答:2

在尝试使用objdump生成汇编代码(与源代码混合)时,

gcc -g -c test.c ;
objdump -S -M intel test.o > out.asm

我收到以下错误。

BFD: Dwarf Error: mangled line number section.

生成的输出程序集不与源代码混合。有人可以澄清这意味着什么吗?有没有什么办法解决这一问题 ?

debugging gcc assembly objdump dwarf
2个回答
0
投票

“objdump -S -M”显然期望.o文件中的“.debug_abbrev部分”部分,而“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;
    }

0
投票

此问题通常显示.debug_line部分中的重定位表问题是由链接器(ld)编码问题引起的 - 重叠的内存副本。工具链需要修复错误并重建。

它不会影响程序加载和运行,但由于地址/符号不匹配,此问题将导致无法进行调试。下面是一个示例,代码在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  |[email protected].@.....|
0038ca90  02 94 32 00 40 00 01 01  00 05 02 94 32 00 40 00  |[email protected].@.|
0038caa0  01 01 00 05 32 00 40 15  02 b0 32 00 40 00 01 01  |[email protected].@...|
0038cab0  00 05 02 b0 32 00 40 00  01 01 00 05 02 b0 32 00  |[email protected].|
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  |[email protected].@.|
0038ca90  00 05 02 90 32 00 40 1a  00 05 02 94 32 00 40 00  |[email protected].@.|
0038caa0  01 01 00 05 02 a0 32 00  40 49 00 05 02 a0 32 00  |[email protected].|
0038cab0  40 15 00 05 02 ac 32 00  40 15 00 05 02 b0 32 00  |@[email protected].|
0038cac0  40 00 01 01 00 05 02 c0  32 00 40 94 00 05 02 c0  |@.......2.@.....|
© www.soinside.com 2019 - 2024. All rights reserved.