toolchain
toolchain copied to clipboard
GCC produces corrupted debug info if the source code uses std::vector
Steps to reproduce:
- Put this code into a new file named
main.cpp
:
#include <vector>
int main(int argc, char const *argv[]) {
std::vector<int> int_vector;
return 0;
}
- Compile the source file with GCC 2021.09-eng009 or newer using the following command:
arc-elf32-g++ -mcpu=hs4x -g -O0 -o main.elf main.cpp
- Invoke objdump using this command:
arc-elf32-objdump -W ./main.elf > objdump.txt
objdump will print the following warnings:
arc-elf32-objdump: Warning: There is a hole [0x23 - 0x35] in .debug_loc section.
arc-elf32-objdump: Warning: There is a hole [0x115f - 0x1171] in .debug_loc section.
arc-elf32-objdump: Warning: There is a hole [0x11fb - 0x120b] in .debug_loc section.
...
arc-elf32-objdump: Warning: There is a hole [0xc0a1 - 0xc0b5] in .debug_loc section.
arc-elf32-objdump: Warning: There is a hole [0xc7fb - 0xc80d] in .debug_loc section.
arc-elf32-objdump: Warning: There is a hole [0xd951 - 0xd963] in .debug_loc section.
arc-elf32-objdump: Warning: Corrupt offset (0x0000008b) in range entry 1
arc-elf32-objdump: Warning: Corrupt offset (0x0000009e) in range entry 2
arc-elf32-objdump: Warning: Corrupt offset (0x0000009e) in range entry 3
...
arc-elf32-objdump: Warning: Corrupt offset (0x00001f81) in range entry 561
arc-elf32-objdump: Warning: Corrupt offset (0x00001f8d) in range entry 562
arc-elf32-objdump: Warning: Corrupt offset (0x00001f99) in range entry 563
Simplified:
.text
.align 4
.global main
.type main, @function
main:
.LVL0:
.LVL1:
.file 1 "main.c"
.loc 1 89 7 is_stmt 0 view .LVU23
.LFE1009:
.size main, .-main
.section .debug_loclists,"",@progbits
.4byte @[email protected]_loc2 # Length of Location Lists
.Ldebug_loc2:
.2byte 0x5 # DWARF version number
.byte 0x4 # Address Size
.byte 0 # Segment Size
.4byte 0 # Offset Entry Count
.Ldebug_loc0:
.LVUS0:
.uleb128 0 # View list begin (*.LVUS0)
.uleb128 .LVU23 # View list end (*.LVUS0)
.uleb128 .LVU23 # View list begin (*.LVUS0)
.uleb128 0 # View list end (*.LVUS0)
.LLST0:
.byte 0x6 # DW_LLE_base_address (*.LLST0)
.4byte @.LVL0 # Base address (*.LLST0)
.byte 0x4 # DW_LLE_offset_pair (*.LLST0)
.uleb128 .LVL0-.LVL0 # Location list begin address (*.LLST0)
.uleb128 .LVL1-.LVL0 # Location list end address (*.LLST0)
.uleb128 0x1 # Location expression size
.byte 0x50 # DW_OP_reg0
.byte 0x4 # DW_LLE_offset_pair (*.LLST0)
.uleb128 .LVL1-.LVL0 # Location list begin address (*.LLST0)
.uleb128 .LFE1009-.LVL0 # Location list end address (*.LLST0)
.uleb128 0x4 # Location expression size
.byte 0xa3 # DW_OP_entry_value
.uleb128 0x1
.byte 0x50 # DW_OP_reg0
.byte 0x9f # DW_OP_stack_value
.byte 0 # DW_LLE_end_of_list (*.LLST0)
.Ldebug_loc3:
It looks related to this. By all means the error looks more estetical than functional, and it should not trigger any error during debugging.
@claziss do we need to do anything here or may just close it now?
Mainline issue. errors reduced to:
arc-elf32-objdump: Warning: There is a hole [0x849 - 0x85b] in .debug_loclists section.
arc-elf32-objdump: Warning: There is a hole [0x18bf - 0x18d1] in .debug_loclists section.
Closing this