Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Templates - huge object file causes linker crash

I have a source file which extensively makes use of templates. I also have in that file explicit instantiations of different templates ... a lot of them. This file is compiled as part of a static library. I compile this library on multiple platforms\for multiple architecture: Win x86, Linux x86 and Linux ARM. For the Linux builds I use different compilers so the resulting files(I'm talking here in context of the ELF file itself) are different: for GCC the resulting object file is 8.4MB in size and has a bit more than 40000 ELF sections; for the ARM compiler(armcc) the resulting file is 12.7MB in size and has more than 90000 ELF sections(!); in both cases I have debug information.

What happens is that at link time the ARM linker chokes and dies trying to link that huge object file in the static library. After some investigation it seems that it cannot handle object files with more than 65536 ELF sections in it(I still have to get a confirmation from the compiler vendor, though ... or I'm doing something completely and utterly wrong). The solution I found to that is splitting the file into multiple smaller files(it's structure and what was inside allowed for that).

The question(s): is there any other alternative solution? Would it be possible for the compiler to generate extra code in the object file(in the context of the templates) before the linking phase?

like image 840
celavek Avatar asked Nov 13 '22 18:11

celavek


1 Answers

With the ARM RVCT compiler (armcc), try adding --remove_unneeded_entities to the command line. This might or might not have much effect depending on which version of the compiler you are using, but its worth a try

like image 99
NullPointer Avatar answered Dec 15 '22 16:12

NullPointer