Hi, not sure if this is a bug or not, but not quite sure where else to turn.
Using Red Hat EL 5.7 (IA64), GCC 4.1.2
uname -a: Linux [Hostname] 2.6.18-274.el5 #1 SMP Fri Jul 8 17:41:07 EDT 2011
ia64 ia64 ia64 GNU/Linux
gcc --version: gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-51)
When compiling a single .cc file that defines an approximately 16KB (static)
character array, the symbol for that variable is not stored in the object file
resulting in a subsequent linker error.
It does not happen for all my static array definitions, including some much
larger ones, and I am unable to see the pattern causing this so I am wondering
if it is a GCC bug related to the size of this definition?
The array definitions look like this:
namespace MyNameSpace
{
char Data1234[] = {
37,33,80,83,45,65,100,111,98,101,45,51,46,48,32,82,101,115,111,117,114,99,101,45,67,77,97,112,10,37,37,68,111,99,117,109,101,110,116,78,101
,101,100,101,100,82,101,115,111,117,114,99,101,115,58,32,80,114,111,99,83,101,116,32,40,67,73,68,73,110,105,116,41,10,37,37,73,110,99,108,117,100
...SNIP...
};
}; // namespace MyNameSpace
Test case 1 (that fails):
gcc -c test1.c
readelf -a test1.o
Symbol table '.symtab' contains 8 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000000 0 FILE LOCAL DEFAULT ABS
2: 0000000000000000 0 SECTION LOCAL DEFAULT 1
3: 0000000000000000 0 SECTION LOCAL DEFAULT 2
4: 0000000000000000 0 SECTION LOCAL DEFAULT 3
5: 0000000000000000 0 SECTION LOCAL DEFAULT 5
6: 0000000000000000 0 SECTION LOCAL DEFAULT 4
7: 0000000000000000 15494 OBJECT GLOBAL DEFAULT 2
Note how there is a 15494 byte entry with no name...
Test case 2 (that passes, i.e. no problem):
gcc -c test2.c
readelf -a test2.o
Symbol table '.symtab' contains 8 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000000 0 FILE LOCAL DEFAULT ABS test2.cc
2: 0000000000000000 0 SECTION LOCAL DEFAULT 1
3: 0000000000000000 0 SECTION LOCAL DEFAULT 2
4: 0000000000000000 0 SECTION LOCAL DEFAULT 3
5: 0000000000000000 0 SECTION LOCAL DEFAULT 5
6: 0000000000000000 0 SECTION LOCAL DEFAULT 4
7: 0000000000000000 17368 OBJECT GLOBAL DEFAULT 2
_ZN7ISYSpdf14CharmapData1
Note how there is a 17368 byte entry with its expected symbol name. This object
file is correct and will link without error.
I have compiled this code on Linux/x86/x86_64, FreeBSD/GCC and many other
compilers - this is the first time I have seen this when trying to build on
Linux/GCC/IA64.
To keep the size of this post down, I have linked the 2 .cc files used above to:
http://download.isys-search.com/tmp/source.zip
Any ideas, help or workarounds would be greatly appreciated.
Derek