I download a binutils-2.19.1,and build an ARM version in cygwin by doing "./configure --target=arm-linux --prefix=/opt/armv6" first,then make. Then I got a strip-new.exe I use strip-new.exe to strip one .o file which the source file include inline function,and that inline function is also used by other source file then I call armlink using the stripped .o file,but fail,it reports "Error: L6275E: COMMON section xxx.o(xxxxx) does not define <Anonymous Sy mbol> (defined in xxxxxx.o(xxxxxx))" The following is a sample how to reproduce my problem,the attach mytestfiles.rar is the files this sample uses. my step is: tcc -c -cpu 5TEJ -apcs /interwork/ropi/norwpi -zo -littleend -g main.o main.c tcc -c -cpu 5TEJ -apcs /interwork/ropi/norwpi -zo -littleend -g test.o test.c tcc -c -cpu 5TEJ -apcs /interwork/ropi/norwpi -zo -littleend -g test2.o test2.c strip-new.exe -g test2.o -o test2-stripped.o armlink -o main.elf main.o test.o test2-stripped.o but fail,it reports: Error: L6275E: COMMON section test.o(i.TestInline) does not define <Anonymous Sy mbol> (defined in test2-stripped.o(i.TestInline)) Finished: 0 information, 0 warning and 1 error messages..
Created attachment 3915 [details] my test samples
My purpose is to using strip to remove debug info in some .o files,and accelerate the link speed. but when I strip one file which this file include inline function,the armlink will fail.even I add "-noremove" when call armlink,it still fails Then I wonder if it is a bug of srip?and how can I solve my problem? Thanks.
This would appear to be due to strip replacing section symbols in test2.o 18: 00000000 0 SECTION LOCAL DEFAULT 5 i.CallTestInline2 .. 24: 00000000 0 SECTION LOCAL DEFAULT 6 i.TestInline with 6: 00000000 0 SECTION LOCAL DEFAULT 1 7: 00000000 0 SECTION LOCAL DEFAULT 2 8: 00000000 0 SECTION LOCAL DEFAULT 4 You get one extra, for .comment, and the ones for i.CallTestInline2 and i.TestInline sections no longer have names. Presumably a bug in armlink fails to interpret these section symbols properly. This odd behaviour of strip is due to strip removing the section symbols (since they are not used in any relocs), but bfd/elf.c:elf_map_symbols adds back a section symbol for all normal sections. You may be able to work around this by telling strip to keep the original section symbols with the -K option.
I tried the -K option as following: strip-new -g -K i.TestInline test2.o -o test2-stripped.o but no useful,armlink still fail like before. and I tried : strip-new -g --keep-file-symbols test2.o -o test2-stripped.o but no useful,armlink also fails like before. and actually ,I don't know which symbols to keep in my actual work,there are a lot of .o files I need to strip. pls help me,thank you very much!
I checked strip -K myself, and, yes, it won't help. You still lose the name on any section symbols in elf.c:swap_out_syms. So I don't think there is any way you can use the GNU tools to strip debug sections in a way that suits armlink. Why don't you use GNU ld?
I don't know the GNU ld before. as you said,I tried ld. I tried many options like: -S -r --discard-none --no-strip-discarded --no-gc- sections,but finally when I use it to armlink,armlink still fails like before.
Not a bug in strip