This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


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

Re: Where are Reg* implemented?


Ku Wei wrote:
> 
> Good point Jason about the ld man page. However, we are discuessing
> gcc
> or g++, not ld.
> 
> It is clear that we need to put the main() entry ( in one of the .c or
> .cxx files) as the first of the source file list ( including .o and
> .c).
> However, the libraries are not 'source files' to g++. Instead, they
> are
> assigned as 'options' by '-l'. Therefore, it is really the compiler's
> responsibility to add these options to correct position in parameter
> list
> passed to 'ld' later.

You said the operative word -- "options".  Libraries (-l) are _not_
options in the normal sense.  They are "special" object modules to
include in the final output.

> 
> For example, for IBM AIX C compiler, you are only allowed to put
> parameters "before" the source file list: xlC [options] files
> On the other hand, g++ allows two different syntex: g++
> [option|filenam] ...

AIX will allow you to put -l at the end (as is typical of most
compiler/linkers) as it is not an option but a shorthand representation
of a special object file to search during linking.

It is also necessary to note that AIX does not implement ld in a
"normal" manner -- it will search all object modules in a circular
fashion, left to right and back to the front, until all references are
resolved (or a complete pass does not resolve a symbol).  Typical
linkers do one pass left to right to resolve references -- each object
is evaluated once for unresolved external references, which must be
resolved by an object to its right on the link line.  In this case it
would not make sense to include the library before the main object, as
no portion of the library would be incorporated in to the output,
because no external references exist when it is scanned.

> Anyway, why use same name in your own code as the name in libraries to
> confuse the linker ?
> 
> Sincerely,
> Wei Ku
> 

Enjoy the debate,
Bill
begin:          vcard
fn:             William Greathouse
n:              Greathouse;William
org:            SMV America Engineering
adr:            8380 Darrow Road;;;Twinsburg;OH;44087;
email;internet: wgreathouse@smva.com
title:          Senior Engineer
tel;work:       (216) 425-1340  x4006
tel;fax:        (216) 405-7684
note:           wgg@netcom.com -- Home Account
x-mozilla-cpt:  ;0
x-mozilla-html: TRUE
end:            vcard


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