Closed retif closed 4 months ago
Thanks, I need to update GCC and test. Up to version 12, the line table was still version 3. In the meantime, you will need to compile/link with the "-gdwarf-4" option.
Can you give me more information on the command line options for GCC?
I use GCC 13.2.1 (like you), and a build a sample program with this:
arm-none-eabi-gcc -gdwarf-5 -mcpu=cortex-m3 -mthumb -o blinky.elf blinky.c -nostartfiles -Wl,-T,STM32F103x8.ld
With objdump, I can confirm that the symbolic information is in DWARF version 5:
arm-none-eabi-objdump --dwarf=info blinky.elf
blinky.elf: file format elf32-littlearm
Contents of the .debug_info section:
Compilation Unit @ offset 0:
Length: 0x9da (32-bit)
Version: 5
Unit Type: DW_UT_compile (1)
Abbrev Offset: 0
Pointer Size: 4
<0><c>: Abbrev Number: 21 (DW_TAG_compile_unit)
<d> DW_AT_producer : (indirect string, offset: 0x5b): GNU C++17 13.2.1 20231009 -mcpu=cortex-m3 -mthumb -mfloat-abi=soft -march=armv7-m -gdwarf-5
<11> DW_AT_language : 12 (ANSI C99)
<12> DW_AT_name : (indirect string, offset: 0x366): blinky.c
<16> DW_AT_comp_dir : (indirect string, offset: 0x147): d:\Tools\BlackMagicProbe\blinky\stm32bluepill
<1a> DW_AT_low_pc : 0x8000150
<1e> DW_AT_high_pc : 0xb0
<22> DW_AT_stmt_list : 0
<1><26>: Abbrev Number: 5 (DW_TAG_base_type)
<27> DW_AT_byte_size : 1
-- More --
However, the line number table (.debug_line
) still uses version 3 in my case:
arm-none-eabi-objdump --dwarf=rawline blinky.elf
blinky.elf: file format elf32-littlearm
Raw dump of debug contents of section .debug_line:
Offset: 0
Length: 719
DWARF Version: 3
Prologue Length: 606
Minimum Instruction Length: 2
Initial value of 'is_stmt': 1
Line Base: -5
Line Range: 14
Opcode Base: 13
Opcodes:
Opcode 1 has 0 args
Opcode 2 has 1 arg
Opcode 3 has 1 arg
Opcode 4 has 1 arg
Opcode 5 has 1 arg
-- More --
I have tried compiling in C++ mode, but with the same result (.debug_line
table still in version 3).
So there appears to be a compiler option that causes GCC to emit the .debug_line
table in version 5.
I am running these tests on Windows, by the way.
I found a way to create a version 5 .debug_line
table: add the option -Wa,-gdwarf-5
.
It turns out that the .debug_line
table is often created by the assembler.
Support for DWARF version 5 is added in commit 67feb1954b3f9b8586104c6fc6f75db6ade88161.