Compile and build tests with too many sections.
Shankar Easwaran
shankarke@gmail.com
Fri Jan 22 18:55:00 GMT 2016
I have a test which generates too many sections and we expect the linker to
resolve a COMMON symbol that exists in multiple files.
Test :-
cat > gen.py << \!
for i in range (0, 90000):
print "int foo%d() { return 0; }" % (i)
print "int mycommon[10];"
!
cat > gen2.py << \!
for i in range (0, 90000):
print "int bar%d() { return 0; }" % (i)
print "int mycommon[20];"
!
python gen.py > gen.c
python gen2.py > gen2.c
g++ -c -ffunction-sections gen.c
g++ -c -ffunction-sections gen2.c
ld gen.o gen2.o
gen2.o:(.bss+0x0): multiple definition of `mycommon'
gen.o:(.bss+0x0): first defined here
Further analyzing the problem, it looks like ths symbol mycommon gets
allocated in the section .bss as opposed to being a COMMON symbol.
Digging into the object file, When I see the generated file, the reserved
section index SHN_COMMON gets used up in the object file for symbols
outside COMMON symbols.
Isnt the section indices defined by SHN_COMMON and few others really
reserved, so when the ELF file is being written, ELF file should skip
assigning reserved section numbers for symbols, and use the next available
number ?
More information about the Binutils
mailing list