Hide Forgot
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:2.0) Gecko/20100101 Firefox/4.0 I'm compiling a c file, with only a single function and a fair few strings. The generated object file is 61.9MiB. For comparison my entire program is only 5MiB if I #include the file (as opposed to attempt to link). However, attempting to link against this giant object file fails. As does running nm on the object file. I will attach a standalone file which can be used to reproduce the problem Reproducible: Always Steps to Reproduce: $ gcc -c pronounce.h -o pronounce.o $ nm pronounce.o nm: pronounce.o: File format not recognized
Created attachment 490920 [details] Standalone file which can be used to reproduce problem
Hi Eric, This is because GCC is a little bit too smart. It knows that pronounce.h is a header file, not a C source file. So when you compile it, gcc turns it into a precompiled header, not an object file. Hence nm does not recognise it. Viz: % file pronounce.o pronounce.o: GCC precompiled header (version 013) for C % cp pronounce.h fred.c % gcc -c fred.c % nm fred.o 00329d20 r C.0.2193 0042e278 r __PRETTY_FUNCTION__.1399 U __assert_fail U memcpy 00000000 T pronounce U strcmp Cheers Nick
Gah! I'm an idiot. Sorry for the noise Thanks very much Eric