This is the mail archive of the binutils@sourceware.org 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]

Re: Question about archive search behavior vs. --defsym


Mark Mitchell <mark@codesourcery.com> writes:

> If you do something like this:
>
>   int main () { f(); }
>
> and don't define "f" anywhere, you can do:
>
>   gcc main.c -Wl,--defsym=f=4
>
> and your program will link, with the call being replaced with a call to 0x4.
>
> But, I was surprised to find that if "f" is defined in an archive it is
> still pulled in. Concretely:
>
> f.c
> ===
> void f() {}
>
> main.c
> ======
> int main () { f(); }
>
> $ gcc -c f.c
> $ ar cr libf.a f.o
> $ gcc main.c -Wl,--defsym=f=4 -L. -lf
>
> pulls in f.o from libf.a even though the symbol is already defined.
>
> This behavior was surprising to me.  Is this a bug?


It's a phase ordering problem.  Objects are pulled in from archives
before symbol assignments are processed.

I think this has to be considered a bug.

Ian


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