PolarBear
PolarBear

Reputation: 41

name field of static variable in elf file

I'm just curious about the name field for a static variable. I have this code

int main ()
{
 static uint8_t var_1[10] = {1};
 static uitn8_t var_2[10] = {0};
  
return 1;
}

if I use readelf -a foo | grep var_2 I see the following:

38: 0000601058  10  OBJECT  LOCAL  DEFAULT  26  var_2.2482

I was wondering what that .2482 means, is it some sort index for variables. I'm also using gcc. thanks

Upvotes: 0

Views: 473

Answers (1)

Lundin
Lundin

Reputation: 213810

Compilers, linkers, object files, debuggers etc utilize a concept widely known as "name mangling" to ensure that identifiers used in a program are unique and to distinguish between them internally - because a programming language may allow the same name for an identifier in several places. "Name mangling" isn't really standardized but each tool tend to use its own name mangling scheme.

Upvotes: 1

Related Questions