In the DWARF-4 standard, we find: ... 3.1.1 Normal and Partial Compilation Unit Entries 11. A DW_AT_main_subprogram attribute, which is a flag whose presence indicates that the compilation unit contains a subprogram that has been identified as the starting function of the program. ... and: ... 3.3 Subroutine and Entry Point Entries A subroutine entry may contain a DW_AT_main_subprogram attribute which is a flag whose presence indicates that the subroutine has been identified as the starting function of the program. ... In dwarf2out.c, we only add the attribute to the subprogram DIE: ... if (dwarf_version >= 4 || !dwarf_strict) add_AT_flag (subr_die, DW_AT_main_subprogram, 1); ... but not to the CU DIE.
Confirmed.