-D__hpux -D__unix -D__ia64=1 -D_BIG_ENDIAN=1 -D_ILP32 -D__HP_cc=60200 \ -D__STDC_EXT__ -D_HPUX_SOURCE -D_INCLUDE_LONGLONG -D_INLINE_ASM \ -D_BIND_LIBCALLS -D_Math_errhandling=MATH_ERREXCEPT -D_FLT_EVAL_METHOD=O \ -ucode hdriver=optlevel%1% -plusolistoption -O106const! -plusolistoption \

-O113moderate! -plusooption -Oq01,al,ag,cn,sz,ic,vo,Mf,Po,es,rs,Rf,Pr,sp,\ in,cl,om,vc,pi,fa,pe,rr,pa,pv,nf,cp,1x,Pg,ug,1u,lb,uj,dn,sg,pt,kt,em,np,ar,\ rp,dl,fs,bp,wp,pc,mp,1r,cx,cr,pi,so,Rc,fa,ft,fe,ap,st,lc,Bl,sr,ib,pl,sd,ll,\ rl,dl,Lt,ol,fl,lm,ts,rd,dp,If! func.c LPATH=/usr/lib/hpux32:/opt/langtools/lib/hpux32

/usr/ccs/bin/ld -o a.out -u__exit -umain main.o func.o -lm -lc

removing /var/tmp/AAAa02486

This example shows that the cc driver calls the actual C compiler (/opt/ansic/lbin/ecom) for each source file. Then the driver calls the linker (/usr/ccs/bin/ld) on the object files created by the compiler (main.o and func.o).

The next-to-last line in the above example is the command line that the compiler used to invoke the linker, /usr/ccs/bin/ld. When building a share-bound executable, the startup functions are handled by the dynamic loader dld. By default, the dynamic loader is found in /usr/lib/hpux32. Thus, in most cases, the ld command does not include crtO.o. In the ld command line, ld combines the two object files created by the compiler (main.o and func.o). It also searches the libm (-lm)and libc (-lc)libraries.

On PA-RISC systems, the same compile command invokes the PA32 linker. The output is shown below.

$ cc -Aa -v main.c func.c -lm

cc:CCOPTS is not set. main.c:

/opt/langtools/lbin/cpp.ansi main.c /var/tmp/ctmAAAa10102 \

-D__hp9000s700 -D__hp9000s800 -D__hppa -D__hpux \

-D__unix -D_PA_RISC1_1 cc: Entering Preprocessor.

/opt/ansic/lbin/ccom /var/tmp/ctmAAAa10102 main.o -O0 -Aa func.c:

/opt/langtools/lbin/cpp.ansi func.c /var/tmp/ctmAAAa10102 \

-D__hp9000x700 -D__hp9000s800 -D__hppa -D__hpux \

-D__unix -D_PA_RISC1_1 cc: Entering Preprocessor.

/opt/ansic/lbin/ccom /var/tmp/ctmAAAa10102 func.o -O0 -Aa

cc:LPATH is /usr/lib/pa1.1:/usr/lib:/opt/langtools/lib: /usr/ccs/bin/ld /opt/langtools/lib/crt0.o -u main main.o func.o -lm -lc

cc:Entering Link editor.

The next-to-last line in the above example is the command line the compiler used to invoke the PA32 mode linker, /usr/ccs/bin/ld. In this command, ld combines a startup file (crt0.o) and the two object files created by the compiler (main.o and func.o) Also, ld searches the libm and libc libraries.

For PA64 and IPF executables, the startup functions are handled by the dynamic loader. In most cases, the ld command line does not include crt0.o.

20 Compiling and Linking Programs on HP-UX