This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Compile and build tests with too many sections.
- From: Shankar Easwaran <shankarke at gmail dot com>
- To: binutils at sourceware dot org
- Date: Fri, 22 Jan 2016 18:54:52 +0000 (UTC)
- Subject: Compile and build tests with too many sections.
- Authentication-results: sourceware.org; auth=none
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 ?