Thread View: comp.sys.mac.programmer.codewarrior
8 messages
8 total messages
Started by Mark Taylor
Mon, 12 Jul 2004 21:16
Which of two functions gets linked?
Author: Mark Taylor
Date: Mon, 12 Jul 2004 21:16
Date: Mon, 12 Jul 2004 21:16
9 lines
998 bytes
998 bytes
Hi all, When an identical function is defined in a .lib file and in a .c file, is there a way to control which one is linked in by the PowerPC Mach-O linker? It seems to be random and uncontrollable, but perhaps I am missing something? Thanks very much, - Mark Taylor
Re: Which of two functions gets linked?
Author: MW Ron
Date: Tue, 13 Jul 2004 18:42
Date: Tue, 13 Jul 2004 18:42
21 lines
1725 bytes
1725 bytes
In article <user02.20.mdt-0ED944.16165012072004@corp.supernews.com>,
Mark Taylor <user02.20.mdt@spamgourmet.com> wrote:
>Hi all,
>
>When an identical function is defined in a .lib file and in a .c file,
>is there a way to control which one is linked in by the PowerPC Mach-O
>linker? It seems to be random and uncontrollable, but perhaps I am
>missing something?
The source file should ALWAYS be used before the library even if the
link order is different are you seeing something other than that?
Ron
--
Metrowerks Community Forum is a free online resource for developers
to discuss CodeWarrior topics with other users and Metrowerks' staff
-- http://www.metrowerks.com/community --
Ron Liechty - MWRon@metrowerks.com - http://www.metrowerks.com
Re: Which of two functions gets linked?
Author: Mark Taylor
Date: Tue, 13 Jul 2004 19:43
Date: Tue, 13 Jul 2004 19:43
29 lines
1984 bytes
1984 bytes
In article <mwron-4EF244.14421113072004@news.newsguy.com>, MW Ron <mwron@metrowerks.com> wrote: > In article <user02.20.mdt-0ED944.16165012072004@corp.supernews.com>, > Mark Taylor <user02.20.mdt@spamgourmet.com> wrote: > > >Hi all, > > > >When an identical function is defined in a .lib file and in a .c file, > >is there a way to control which one is linked in by the PowerPC Mach-O > >linker? It seems to be random and uncontrollable, but perhaps I am > >missing something? > > The source file should ALWAYS be used before the library even if the > link order is different are you seeing something other than that? > > Ron No, in fact the library function was being used and the linker was dead stripping the function in the .c file. The desired behavior is for the .c function to override the library version. I took Adriaan's advice and I checked the link order list. It turned out that the .c file was the last item in the list since it was recently added to the project. Moving it ahead of the libraries fixed the problem. (Thanks, Adriaan!) Upon reading your message I take it that it should not work this way? - Mark
Re: Which of two functions gets linked?
Author: Miro Jurisic
Date: Tue, 13 Jul 2004 20:57
Date: Tue, 13 Jul 2004 20:57
17 lines
1634 bytes
1634 bytes
In article <user02.20.mdt-D089B9.14432713072004@corp.supernews.com>, Mark Taylor <user02.20.mdt@spamgourmet.com> wrote: > I took Adriaan's advice and I checked the link order list. It turned > out that the .c file was the last item in the list since it was recently > added to the project. Moving it ahead of the libraries fixed the > problem. (Thanks, Adriaan!) Upon reading your message I take it that > it should not work this way? AFAIK Ron is confused. There used to be a time when source files always trumped libraries, but that is no longer the case. meeroh -- If this message helped you, consider buying an item from my wish list: <http://web.meeroh.org/wishlist>
Re: Which of two functions gets linked?
Author: MW Ron
Date: Tue, 13 Jul 2004 21:27
Date: Tue, 13 Jul 2004 21:27
25 lines
2156 bytes
2156 bytes
In article <macdev-CCB0C5.16570413072004@senator-bedfellow.mit.edu>,
Miro Jurisic <macdev@meeroh.org> wrote:
>> I took Adriaan's advice and I checked the link order list. It turned
>> out that the .c file was the last item in the list since it was recently
>> added to the project. Moving it ahead of the libraries fixed the
>> problem. (Thanks, Adriaan!) Upon reading your message I take it that
>> it should not work this way?
>
>AFAIK Ron is confused. There used to be a time when source files always
>trumped
>libraries, but that is no longer the case.
As far as I know I'm confused too :), however, I'll assume that this
behavior has changed and submit it as a bug report, as I don't think
that is the desired behavior.
Ron
--
Metrowerks Community Forum is a free online resource for developers
to discuss CodeWarrior topics with other users and Metrowerks' staff
-- http://www.metrowerks.com/community --
Ron Liechty - MWRon@metrowerks.com - http://www.metrowerks.com
Re: Which of two functions gets linked?
Author: Ed Swartz
Date: Tue, 13 Jul 2004 22:03
Date: Tue, 13 Jul 2004 22:03
14 lines
1873 bytes
1873 bytes
> > > >AFAIK Ron is confused. There used to be a time when source files always > >trumped > >libraries, but that is no longer the case. > > As far as I know I'm confused too :), however, I'll assume that this > behavior has changed and submit it as a bug report, as I don't think > that is the desired behavior. I'm confused too. Ron's explanation matches the Win32 and all Codewarrior ELF linkers, but it seems the Mach-O linker is using this alternate ordering. -- Ed
Re: Which of two functions gets linked?
Author: MW Ron
Date: Wed, 14 Jul 2004 16:12
Date: Wed, 14 Jul 2004 16:12
39 lines
2554 bytes
2554 bytes
In article <user02.20.mdt-0ED944.16165012072004@corp.supernews.com>,
Mark Taylor <user02.20.mdt@spamgourmet.com> wrote:
>When an identical function is defined in a .lib file and in a .c file,
>is there a way to control which one is linked in by the PowerPC Mach-O
>linker? It seems to be random and uncontrollable, but perhaps I am
>missing something?
The linker builds 3 list of files:
files ending in ".o" (if 'Enforce link order for ".o" files' is off)
files which the IDE associates with a text file (sources)
all other files (dylibs, and libs)
The ".o" case only exists in Mach-O but the rest of the code is the same
for both PEF and our Mach-O linker. This ".o" handling is important
since crt1.o needs to be treated as if it was first, and our users were
not very careful about doing this so we by default put all ".o" files
first, if the user enables Enforce link order for ".o" files then they
have to make sure that crt1.o appears in the correct link order.
The 3 lists are merge together into a single list in the order of the
list above. The linker then walks that list in that order, the only
special case is dylibs appear in order but are not actually processed
until the frameworks are scanned.
If you know of any other situation then we would like a bug report on
this.
Ron
--
Metrowerks Community Forum is a free online resource for developers
to discuss CodeWarrior topics with other users and Metrowerks' staff
-- http://www.metrowerks.com/community --
Ron Liechty - MWRon@metrowerks.com - http://www.metrowerks.com
Re: Which of two functions gets linked?
Author: MW Ron
Date: Wed, 14 Jul 2004 16:16
Date: Wed, 14 Jul 2004 16:16
22 lines
1818 bytes
1818 bytes
In article <macdev-CCB0C5.16570413072004@senator-bedfellow.mit.edu>,
Miro Jurisic <macdev@meeroh.org> wrote:
>AFAIK Ron is confused. There used to be a time when source files always
>trumped
>libraries, but that is no longer the case.
not to be redundant, but in case you missed the earlier posting because
I posted out of order...
.o files trump source files, Source files trump .lib files , DLLs are
processed when frameworks are scanned.
Ron
--
Metrowerks Community Forum is a free online resource for developers
to discuss CodeWarrior topics with other users and Metrowerks' staff
-- http://www.metrowerks.com/community --
Ron Liechty - MWRon@metrowerks.com - http://www.metrowerks.com
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads