I have a local static variable, something like this:

void function(void) {
    static unsigned char myVariable = 0;

I dump the symbol table using readelf as follows:

readelf -s myprogram.elf

and I get the symbol table, that contains myVariable as follows:

409: 00412668     1 NOTYPE  LOCAL  DEFAULT   16 myVariable.9751

My question is: what does the number mean after the name of the variable and the dot? And is there any detailed documentation about the output format of readelf? The man page does not contain information about the format of the symbol table, and I cannot find anything about this. (I'm using Xilinx's ARM GNU tools, but I guess, this is kind of the same for other platforms as well) Thanks!

1 Answer 1


That's not an artifact of readelf's output; myVariable.9751 is really that symbol's name. In order to distinguish static variables defined in different scopes/functions, the compiler has to decorate their names in some way:

$ cat a.c
static int var;
int foo(void){
        static int var;
        if(var++ > 3){ static int var; return var++; } else return var++;
int bar(void){ static int var; return var++; }
int baz(void){ return var++; }
$ cc -Wall -o - -S a.c | grep local.*var
        .local  var
        .local  var.1759
        .local  var.1760
        .local  var.1764

Notice that the dot (.) cannot be used in C as part of an identifier, so var.num is not going to collide with any other variable defined by the user.

As to readelf documentation, there isn't much else beyond the man page and reading the source code; but you can also use objdump -tT instead of readelf -s; maybe you'll find its man page better.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .