Subject: Re: Where are Reg* implemented?
From: [email-masked] (William Greathouse)

1 Aug 1997 19:41:13 -0700
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
References: <[email-masked]>
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="------------FF4D925C2B9B569799E1B358"
>Received: from iago by mailserv.smva.com (AIX 3.2/UCB 5.64/4.03)
          id AA20568; Fri, 1 Aug 1997 17: 38:21 -0400
X-Mailer: Mozilla 4.01 [en] (Win95; I)
Original-To: gnu-win32 <[email-masked]>
X-Priority: 3 (Normal)
Original-Sender: [email-masked]

This is a multi-part message in MIME format.
--------------FF4D925C2B9B569799E1B358
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

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
--------------FF4D925C2B9B569799E1B358
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for William Greathouse
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             William Greathouse
n:              Greathouse;William
org:            SMV America Engineering
adr:            8380 Darrow Road;;;Twinsburg;OH;44087;
email;internet: [email-masked]
title:          Senior Engineer
tel;work:       (216) 425-1340  x4006
tel;fax:        (216) 405-7684
note:           [email-masked] -- Home Account
x-mozilla-cpt:  ;0
x-mozilla-html: TRUE
end:            vcard

--------------FF4D925C2B9B569799E1B358--

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".