Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!abyss From: abyss@Apple.COM (Ananthan Srinivasan) Newsgroups: comp.unix.aux Subject: -The weirdness of the crt*.o files- Message-ID: <43470@apple.Apple.COM> Date: 31 Jul 90 18:27:48 GMT Organization: Apple Computer Inc., Cupertino, CA Lines: 25 To see all the right crt*.o files that need to be used to keep 'ld' happy, write a dummy program (dummy.c) and compile it using "cc -v". On A/UX 2.0 you will see that 'ld' is invoked as foll: "/bin/ld /lib/crt1.o /lib/crt2.o dummy.o -lc /lib/crtn.o /usr/lib/shlib.ld" On A/UX 1.* this is "/bin/ld /lib/crt0.o dummy.o -lc /usr/lib/shared.ld". The new crt files in A/UX 2.0 - crt1.o, crt2.o and crtn.o replace the old crt0.o file and provide the mechanism to support shared libraries. The files crt1.o and crt2.o need to be specified as the first 2 object files to be linked and crtn.o needs to the last object file to be linked. (The link directive files - /usr/lib/shlib.ld or /usr/lib/shared.ld are not object files, they contain specifications for the layout of the final executable - a.out. /usr/lib/shlib.ld needs to be used if any shared libraries are being linked if not /usr/lib/shared.ld works fine. The 'cc' front end (which calls 'cpp', 'as' and 'ld') has been modified in A/UX 2.0 so that all the proper crt files are used if an executable is to be obtained. However if the final linking of several objects is done explicitly, the appropriate crt files (crt0.o for A/UX 1.* and crt1.o, crt2.o & crtn.o for A/UX 2.0) need to be used in the right order. [Note: Linking in different libraries using the -l option with 'cc' results in the appropriate libraries being added after '-lc (libc) and before '/lib/crtn.o' in A/UX 2.0] Srinivasan, A.B.