On Thu, Sep 12, 2024 at 05:10:01PM -0500, Lorenzo Gomez wrote: > Thanks so much for the detailed explanation. So clearly all the macros are > there as we can see from readelf. I ran it myself and can see all the > macros as David pointed out. And just to make sure I understand, this is > what I took away: > > 1. All the macros are in the file as we can see from readelf output. > 2. As per the DWARF5 spec it states "As described in Section 3.1.1 on page > 60, the macro information for a given compilation unit is represented in > the .debug_macro section of an object file." > Meaning that there should be only *one*.debug_macro section, not more > than 1 as gcc is structuring it.
Generally, in binaries/executables there is (at most) one .debug_* section of each kind with the different additions concatenated. In object files, there can be many, that is something eventually linked into the output section. E.g. for comdat functions the producer could in ELF emit separate .debug_info contributions in the comdat of the specific function. So, IMO nothing is violated, there is no bug, that is how .debug_macro was meant to be used from the beginning (when what we implemented in GCC as a DWARF 4 extension was then with small changes standardized in DWARF 5). If you are trying to look at debug info in object files rather than binaries/shared libraries, you need to apply relocations, and the DW_MACRO_import ops have relocations to those corresponding .debug_macro contributions; .debug_info compilation unit(s) also has DW_AT_macros attribute which should have relocation pointing to the .debug_macro contribution where the macros for that compilation unit start. And each DW_AT_import there includes everything in the referenced contribution. Jakub -- Dwarf-discuss mailing list Dwarf-discuss@lists.dwarfstd.org https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss