Missing DW_at_low_pc information for compiled unit [AVR]
## Summary DW_at_low_pc and DW_at_high_pc information is missing (set to zero) for a compiled unit. This complicates finding of line information in fpdebug, since it relies on this information to identify the compiled unit containing the relevant code address. ## System Information - **Operating system:** embedded - **Processor architecture:** AVR - **Compiler version:** main (8abe70e25a777f8e04b5fd251d8464d5dd319200) - **Device:** Microcontroller Same issue is observed when using FPC 3.2.2. ## Steps to reproduce Inspect DWARF information for any program compiled for AVR. ## Example Project ``` program test; begin Halt(2); end. ``` Compile: ``` $ ~/fpc/installs/lib/fpc/3.3.1/ppcrossavr -Tembedded -Pavr -Wpavrsim -gw3 -viwn -l -al test.pp Free Pascal Compiler version 3.3.1 [2022/06/30] for avr Copyright (c) 1993-2022 by Florian Klaempfl and others Target OS: Embedded Compiling test.pp Assembling test Linking test 6 lines compiled, 0.1 sec, 2632 bytes code, 8535 bytes data ``` Inspect DWARF information: ``` $ avr-objdump -Wi test.elf test.elf: file format elf32-avr Contents of the .debug_info section: Compilation Unit @ offset 0x0: Length: 0x83 (32-bit) Version: 3 Abbrev Offset: 0x0 Pointer Size: 4 <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit) <c> DW_AT_name : test.pp <14> DW_AT_producer : Free Pascal 3.3.1 2022/06/30 <31> DW_AT_comp_dir : /home/christo/fpc/fpc-avr/src/tests/2022-07-01-unit/ <66> DW_AT_language : 9 (ANSI Pascal) <67> DW_AT_identifier_case: 3 (case_insensitive) <68> DW_AT_stmt_list : 0x0 <6c> DW_AT_low_pc : 0x0 <70> DW_AT_high_pc : 0x0 <1><74>: Abbrev Number: 2 (DW_TAG_subprogram) <75> DW_AT_name : $main <7b> DW_AT_prototyped : 1 <7c> DW_AT_external : 1 <7d> DW_AT_low_pc : 0x3a <81> DW_AT_high_pc : 0x4e <2><85>: Abbrev Number: 0 <1><86>: Abbrev Number: 0 ``` ## What is the current bug behavior? DW_AT_low_pc and DW_AT_high_pc is 0 for the compiled unit. ## What is the expected (correct) behavior? DW_AT_low_pc and DW_AT_high_pc should contain the lower and upper code addresses for the compiled unit. ## Speculation Inspecting the compiler generated assembler shows that labels are defined and used seemingly correctly, but the label information is lost when the object file is created with avr-as: ``` $ avr-objdump -Wi test.o test.o: file format elf32-avr Contents of the .debug_info section: Compilation Unit @ offset 0x0: Length: 0x83 (32-bit) Version: 3 Abbrev Offset: 0x0 Pointer Size: 4 <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit) <c> DW_AT_name : test.pp <14> DW_AT_producer : Free Pascal 3.3.1 2022/06/30 <31> DW_AT_comp_dir : /home/christo/fpc/fpc-avr/src/tests/2022-07-01-unit/ <66> DW_AT_language : 9 (ANSI Pascal) <67> DW_AT_identifier_case: 3 (case_insensitive) <68> DW_AT_stmt_list : 0x0 <6c> DW_AT_low_pc : 0x0 <70> DW_AT_high_pc : 0x0 <1><74>: Abbrev Number: 2 (DW_TAG_subprogram) <75> DW_AT_name : $main <7b> DW_AT_prototyped : 1 <7c> DW_AT_external : 1 <7d> DW_AT_low_pc : 0x0 <81> DW_AT_high_pc : 0x14 <2><85>: Abbrev Number: 0 <1><86>: Abbrev Number: 0 ```
issue