Bug 10111 - strip .o using inline func, then armlink fails
Summary: strip .o using inline func, then armlink fails
Status: RESOLVED OBSOLETE
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.19
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-29 02:20 UTC by lijiyou
Modified: 2022-11-25 03:11 UTC (History)
1 user (show)

See Also:
Host: cygwin
Target: arm-elf
Build:
Last reconfirmed:


Attachments
my test samples (4.01 KB, patch)
2009-04-29 02:24 UTC, lijiyou
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description lijiyou 2009-04-29 02:20:13 UTC
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..
Comment 1 lijiyou 2009-04-29 02:24:18 UTC
Created attachment 3915 [details]
my test samples
Comment 2 lijiyou 2009-04-29 02:26:07 UTC
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.
Comment 3 Alan Modra 2009-04-29 06:14:58 UTC
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.
Comment 4 lijiyou 2009-04-29 09:34:26 UTC
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!
Comment 5 Alan Modra 2009-04-29 12:54:58 UTC
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?
Comment 6 lijiyou 2009-04-30 01:28:03 UTC
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.
Comment 7 Alan Modra 2022-11-25 03:11:50 UTC
Not a bug in strip