Prevent linking of crt0.o - HP UX

This is a discussion on Prevent linking of crt0.o - HP UX ; Hello all, I am trying to build a shared library. The compiler driver invokes the linker and the linker string looks as below:- /usr/ccs/bin/ld /opt/langtools/lib/crt0.o -u main -b -B symbolic +vnocompatwarnings -z +s +h libxxx.sl -o libxxx.sl -Fl libyyy.a -L. ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: Prevent linking of crt0.o

  1. Prevent linking of crt0.o

    Hello all,

    I am trying to build a shared library. The compiler driver invokes the
    linker and the linker string looks as below:-

    /usr/ccs/bin/ld /opt/langtools/lib/crt0.o -u main -b -B symbolic
    +vnocompatwarnings -z +s +h libxxx.sl -o libxxx.sl -Fl libyyy.a -L. +s
    -ldld -lc

    And, I get the following error:-
    /usr/ccs/bin/ld: DP relative code in file /opt/langtools/lib/crt0.o -
    shared library must be position independent. Use +z or +Z to recompile.

    The object files in the archive libyyy.a are all built in PIC mode.
    AFAIK, we can't change the startup file crt0.o, so is there a way out?

    Secondly, what I feel is that crt0.o should not be linked while
    building a shared library. It is exclusively for building executables.
    I am unable to figure out from where is this crt0.o is getting linked.
    Is it because of the usage of "-u main" option?

    Machine specifics:-
    HP-UX 11.00 PA-RISC 2.0
    Compiler: HP92453-01 A.11.01.21505.GP (Native compiler)

    Kindly suggest.
    Thanks,
    Anunay


  2. Re: Prevent linking of crt0.o

    Anunay wrote:
    > /usr/ccs/bin/ld /opt/langtools/lib/crt0.o -u main -b -B symbolic
    > +vnocompatwarnings -z +s +h libxxx.sl -o libxxx.sl -Fl libyyy.a -L. +s
    > -ldld -lc
    >
    > And, I get the following error:-
    > /usr/ccs/bin/ld: DP relative code in file /opt/langtools/lib/crt0.o -
    > shared library must be position independent. Use +z or +Z to recompile.
    >


    You should be linking with /opt/langtools/lib/scrt0.o
    while creating shared library.

    --vishwas

  3. Re: Prevent linking of crt0.o

    vishwas wrote:-
    > You should be linking with /opt/langtools/lib/scrt0.o
    > while creating shared library.


    So, how do i get rid of that "position independent" error?


  4. Re: Prevent linking of crt0.o

    "Anunay" writes:

    > I am trying to build a shared library. The compiler driver invokes the
    > linker and the linker string looks as below:-
    >
    > Compiler: HP92453-01 A.11.01.21505.GP (Native compiler)


    Your compiler is too old, and doesn't understand '-b' flag.

    This is one (rare) case where you have to bypass the compiler driver
    and link your shared library directly with 'ld'.

    Cheers,
    --
    In order to understand recursion you must first understand recursion.
    Remove /-nsp/ for email.

  5. Re: Prevent linking of crt0.o

    Paul Pluzhnikov wrote:
    : "Anunay" writes:
    : > I am trying to build a shared library.
    : > Compiler: HP92453-01 A.11.01.21505.GP (Native compiler)

    : Your compiler is too old, and doesn't understand '-b' flag.
    : This is one (rare) case where you have to bypass the compiler driver
    : and link your shared library directly with 'ld'.

    Yes, PHSS_21505 doesn't understand -b and using -Wl,-b just confuses the
    linker and cc.

  6. Re: Prevent linking of crt0.o

    Marty Freitas wrote:-
    > Yes, PHSS_21505 doesn't understand -b and using -Wl,-b just confuses the
    > linker and cc.


    Which patch should I install to update the compiler?


  7. Re: Prevent linking of crt0.o

    Anunay wrote:
    : Which patch should I install to update the compiler?

    You can't. The last patch for that version of the compiler is PHSS_25171
    and that still doesn't support -b.

    You must purchase a new compiler. Or if you have a compiler support contract
    you can get the latest update:
    http://www.hp.com/go/c
    http://h21007.www2.hp.com/dspp/tech/...1,1255,00.html

+ Reply to Thread