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]

Re: AboutShareLib


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


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