[Nasm-bugs] [Bug 3392448] New: NASM generates invalid debug_loc and debug_pubnames sections

no-reply at bugzilla-nasm.gorcunov.org no-reply at bugzilla-nasm.gorcunov.org
Tue Oct 31 21:36:30 PDT 2017


https://bugzilla.nasm.us/show_bug.cgi?id=3392448

            Bug ID: 3392448
           Summary: NASM generates invalid debug_loc and debug_pubnames
                    sections
           Product: NASM
           Version: 2.13.xx
          Hardware: All
                OS: All
            Status: OPEN
          Severity: normal
          Priority: Medium
         Component: Assembler
          Assignee: nobody at nasm.us
          Reporter: travis.downs at gmail.com
                CC: gorcunov at gmail.com, hpa at zytor.com, nasm-bugs at nasm.us
     Obtained from: Build from source archive using configure

Given the following dummy function:

GLOBAL func:function
func:
xor eax, eax
ret

compiled with -g -F dwarf -f elf64 the resulting .o file has invalid an invalid
(too short) debug_loc section:

dwarfdump -a cfi-test-asm.o

.debug_info

COMPILE_UNIT<header overall offset = 0x00000000>:
< 0><0x0000000b>  DW_TAG_compile_unit
                    DW_AT_low_pc                0x00000000
                    DW_AT_high_pc               0x00000000
                    DW_AT_stmt_list             0x00000000
                    DW_AT_name                  "cfi-test-asm.asm"
                    DW_AT_producer              "NASM 2.13.01"
                    DW_AT_language              DW_LANG_Mips_Assembler

LOCAL_SYMBOLS:
< 1><0x00000040>    DW_TAG_subprogram
                      DW_AT_low_pc                0x00000000

dwarfdump ERROR:  dwarf_loclist:  DW_DLE_DEBUG_LOC_SECTION_SHORT(194) (194)

CU Name = "cfi-test-asm.asm"
CU Producer = "NASM 2.13.01"
DIE OFF = 0x00000040 GOFF = 0x00000040, Low PC = 0x00000000, High PC =
0x00000000

Note that this error terminate the processing by dwarfdump of the file.

The pubnames section also has the wrong version:

dwarfdump -p cfi-test-asm.o 

.debug_pubnames

dwarfdump ERROR:  dwarf_get_globals:  DW_DLE_PUBNAMES_VERSION_ERROR (123)


After linking with a dummy main program in C, the "too short" error disappears
but the debug_loc entries still appear invalid:

$ dwarfdump -kl cfi-test

*** DWARF CHECK: .debug_loc: Address outside a valid .text range ***

CU Name = "cfi-test-asm.asm"
CU Producer = "NASM 2.13.01"
DIE OFF = 0x00000040 GOFF = 0x000000dc, Low PC = 0x004004f0, High PC =
0x004004f3
Offset = 0x00000000, Base = 0x004004f0, Low = 0x008008d0 (0x004003e0), High =
0x008008db (0x004003eb)

*** DWARF CHECK: .debug_loc: Address outside a valid .text range ***

CU Name = "cfi-test-asm.asm"
CU Producer = "NASM 2.13.01"
DIE OFF = 0x00000040 GOFF = 0x000000dc, Low PC = 0x004004f0, High PC =
0x004004f3
Offset = 0x00000011, Base = 0x004004f0, Low = 0x008008db (0x004003eb), High =
0x008008dc (0x004003ec)

DW_AT_frame_base            <loclist with 2 entries follows>
                        [ 0]<lowpc=0x004003e0><highpc=0x004003eb><from
.debug_loc offset 0x00000012>DW_OP_reg5
                        [ 1]<lowpc=0x004003eb><highpc=0x004003ec><from
.debug_loc offset 0x00000025>DW_OP_GNU_entry_value 0x00000001 DW_OP_stack_value


Based on the part of the output that reads :Low = 0x008008d0 (0x004003e0), High
= 0x008008db (0x004003eb) I think the problem is that the loc low/high values
are offsets from the CU offset, but nasm is encoding them absolutely, you get a
value in the 0x800000 range, rather than the correct 0x004003e0.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are watching all bug changes.


More information about the Nasm-bugs mailing list