public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* ld: circle-references in libraries
@ 2006-07-07  5:50 Wolfgang Haidinger
  2006-07-07  7:42 ` Stefan Karlsson
  0 siblings, 1 reply; 2+ messages in thread
From: Wolfgang Haidinger @ 2006-07-07  5:50 UTC (permalink / raw)
  To: binutils

Hi volks!

When you have circle-references in libraries ld generates an 
undefined-reference-error.

For example:
main -> A0 -> B0 -> A1
Whereas libA.a contains all A*, libB.a all B* functions, and f1 -> f2 
means f1 calls function f2.
Then the result is an error: In function 'B0': undefined reference to 
'A1'.

To state the -l option multiple, like -lA -lB -lA will work, but is this a 
good idea? Why is this work: "rotating through all libs until no more 
object file is added", not done by the linker itself? Or is there any 
option to advise the linkter to do so?

Grüße
Wolfgang Haidinger
---
Wolfgang Haidinger
B&R Industrie-Elektronik GmbH
BU Controls, Safety
Tel: +43 (0)7748 6586 1121
eMail: wolfgang dot haidinger at br-automation dot com

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: ld: circle-references in libraries
  2006-07-07  5:50 ld: circle-references in libraries Wolfgang Haidinger
@ 2006-07-07  7:42 ` Stefan Karlsson
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Karlsson @ 2006-07-07  7:42 UTC (permalink / raw)
  To: binutils

Wolfgang Haidinger wrote:

> To state the -l option multiple, like -lA -lB -lA will work, but is this a 
> good idea? Why is this work: "rotating through all libs until no more 
> object file is added", not done by the linker itself? Or is there any 
> option to advise the linkter to do so?
> 

Excerpt from the manual (section 2.1):

-( archives -)
--start-group archives --end-group

     The archives should be a list of archive files. They may be either 
explicit file names, or `-l' options.

     The specified archives are searched repeatedly until no new 
undefined references are created. Normally, an archive is searched only 
once in the order that it is specified on the command line. If a symbol 
in that archive is needed to resolve an undefined symbol referred to by 
an object in an archive that appears later on the command line, the 
linker would not be able to resolve that reference. By grouping the 
archives, they all be searched repeatedly until all possible references 
are resolved.

     Using this option has a significant performance cost. It is best to 
use it only when there are unavoidable circular references between two 
or more archives.


I think this is what you want.

-- 
Stefan


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-07-07  7:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-07  5:50 ld: circle-references in libraries Wolfgang Haidinger
2006-07-07  7:42 ` Stefan Karlsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).