What can cause a variable to be present in linker map file but not ELF symbol table?

Viewed 145

A variable is declared as

volatile bool is_usage_mode_convenience_activated = true;

It shows up in the linker map file with proper address but I cannot find it in the ELF symbol table (examined with readelf -s).

The dwarf debug info (readelf --debug-dump=info) is as follows

<2><42019>: Abbrev Number: 104 (DW_TAG_variable)
    <4201a>   DW_AT_name        : (indirect string, offset: 0x433aa): is_usage_mode_convenience_activated
    <4201e>   DW_AT_decl_file   : 3
    <4201f>   DW_AT_decl_line   : 21
    <42020>   DW_AT_linkage_name: (indirect string, offset: 0x49717): _ZN20vehiclemodesprovider35is_usage_mode_convenience_activatedE
    <42024>   DW_AT_type        : <0x392a3>
    <42028>   DW_AT_external    : 1
    <42028>   DW_AT_declaration : 1

I expected a to find a DW_AT_location instead of DW_AT_declaration. There is no extern declaration for this variable in the program so the DW_TAG_variable does indeed describe the one and only declaration of the variable.

What circumstances can cause this? There is nothing strange with the variable declaration.

1 Answers

It actually was in the symbol table but since readelf only writes the n first chars grep missed it. Using a different tool which showed the entire symbol revealed that it did exist in the symbol table. Still strange though that it didn't have a location attribute.

Related