This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: AboutShareLib
- To: Yu Xuanwei <yxw at chinacluster dot com>
- Subject: Re: AboutShareLib
- From: Robert Lipe <robertlipe at usa dot net>
- Date: Thu, 15 Feb 2001 20:59:23 -0600
- Cc: binutils <binutils at sources dot redhat dot com>, gcc at gcc dot gnu dot org
- References: <000f01c097bc$ef3d6d40$6400000a@sinocluster.com>
Yu Xuanwei wrote:
> Here I have some questions about compiler and linker operation, or not.
Since you don't state what processor or OS you're using, you'll probably
get only vague answers.
> 1. ELF offers flexible shared libraries for us. Then how about COFF?
There was a way to do shared libraries with COFF, but it was an
Incredibly Painful Process. If you have (and like) ELF, you'll find
COFF to be like negative time travel.
> 2. When I link my *.a with my *.o in the case of static linking, will
> non-referred functions wrapped in *.a be linked into final a.out(ELF)?
Not if your linker is functioning correctly. Look at the symbol table
in your executable and confirm it.
> In libfoo.a:
> /*function and function1 never call each other*/
> function(){}
> function1(){}
>
> In my myprog.c (compiled to myprog.o)
> main(){
> function();
> return 0;
> }
>
> Then after static linking to build myprog.out(final binary), the unuseful
> function1() assembly exists in myprog.out or not?
Depends if function and function were defined in the same file and
whether your linker is working correctly.
> 3. In default situation, which level of optimization will get rid of
> unuseful assembly if it does exist in myprog.out?
Optimization (as in -O flags to the compiler) doesn't apply to the
ability of a linker to not suck in unused objects in an archive.
RJL