Having simple file
a.cpp:
//a.cpp
extern const int n = 8;
const int b = 10;
Compiling with:
g++ -c a.cpp -fPIC
And checking with readelf -sw
:
Symbol table '.symtab' contains 11 entries:
Num: Value Size Type Bind Vis Ndx Name
...
6: 0000000000000004 4 OBJECT LOCAL DEFAULT 4 _ZL1b
...
9: 0000000000000000 4 OBJECT GLOBAL DEFAULT 4 n
...
Why is the b
const int name mangled, but the extern global variable const int n
name not mangled?
Does standard define this behaviour (not mangling the name) or is it g++
feature?