This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Why objcopy/strip doesn't accept wildcard when localize/keep/weaken symbols.


I need to localized all symbols in an object except some specific one in
order to avoid symbol conflict in linking.

For example,

ld -r -o objcopy-r.o objcopy.o other-objs.o ....

Then I want localize all symbols except 'main' and redefine the 'main' to
'objcopy_main'. So I hope to do:

objcopy -w -L !objcopy_main --redefine-sym main=objcopy_main objcopy-r.o
objcopy-ok.o

And do this to some other these objects and get  strip-ok.o, readelf-ok.o
.....

Then I can make a simple main function to call them just like 'busybox'.
This work can help me to reduce the
total binary size in embedded system (Especially for the static-only
machine).

But now, objcopy doesn't support wildcard for symbols. If I want to do the
previous work. the only way is write
a script to localize each symbol respectively. Is it too trouble?

So I read the source of object copy, and create a patch to add a new option
'--wildcard' to 'objcopy'. That works
for me now. :)  The patch should be applied to CVS tree of binutils.

I think this feature is valuable so I sent it here and hope it can be useful
for others.

Charles   April  29.

Attachment: binutils-objcopy.patch
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]