This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: objcopy copies not only symbols asked?
- From: Fergus Henderson <fjh at cs dot mu dot OZ dot AU>
- To: "Gyurki, Istvan (MED)" <Istvan dot Gyurki at med dot ge dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 25 Feb 2003 00:01:37 +1100
- Subject: Re: objcopy copies not only symbols asked?
- References: <6EDD9DC298BF9C48AC3EF66EA92596BC0BC27205@frbucmsx03medge>
On 24-Feb-2003, Gyurki, Istvan (MED) <Istvan dot Gyurki at med dot ge dot com> wrote:
> I have a .o file about 1 meg size. I'd like to extract only one symbol from
> it, using:
> objcopy --strip-all -K symbolname from.o to.o
>
> objcopy does the job, however the new file containing only one symbol wil be
> about 800k.
> I do not think that the symbol takes up that much space, so for me it seems
> that objcopy only removes symbol reference, but does not actually eliminate
> everything.
>
> My question is; is there a way to create .o file containing only the
> required symbol, and not more?
If you build with -ffunction-sections and -fdata-sections, then you
may be able to use the linker to do this (e.g. "ld -r --gc-sections
-u symbolname -o to.o from.o"; I haven't actually tried this).
But if the object file was not built with -ffunction-sections and
-fdata-sections, then I think you're out of luck.
--
Fergus Henderson <fjh at cs dot mu dot oz dot au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.