Operating System - HP-UX
1748074 Members
5344 Online
108758 Solutions
New Discussion юеВ

ld error: $global$ (data) (probably missing /usr/ccs/lib/crt0.o)

 
SOLVED
Go to solution
Andrew Herrmann
Occasional Advisor

ld error: $global$ (data) (probably missing /usr/ccs/lib/crt0.o)

I'm trying to create a dynamic executable using ld (B.11.33 020617). For the linker options, I'm using +s and -dynamic. Based on my understanding of the man pages for crt0.o, it shouldn't even look for this file with the switch -dynamic.

All of the shared libraries that will be used by this dynamic executable were compiled with aCC using the -c and +z options.

The interesting thing is that if I use aCC instead of ld to build the dynamic executable, it works fine. The problem with this is that the location of the shared libraries is fixed. I need to be able to use the +s option with ld so that the LD_LIBRARY_PATH can be used to set the location of the shared libraries at run-time.

If anyone has any ideas on this, I'd greatly appreciate it. I've tried just about everything ... The error message just doesn't make any sense to me.

FWIW: The file /usr/ccs/lib/crt0.o does exist ($Revision: 92453-07 linker linker crt0.o B.11.33 020617 $)

Thanks in advance..
7 REPLIES 7
Adam J Markiewicz
Trusted Contributor

Re: ld error: $global$ (data) (probably missing /usr/ccs/lib/crt0.o)

Hi

And what about option '-b'?
This actually tells the linker to create share library instead of executable...

Good luck
Adam
I do everything perfectly, except from my mistakes
Adam J Markiewicz
Trusted Contributor
Solution

Re: ld error: $global$ (data) (probably missing /usr/ccs/lib/crt0.o)

Hi again

I made a little more investigation.
How about this: Make yor executable with aCC, then:
chatr +s enable $(EXE)

man chatr
quite usefull tool to postprocess.

Good luck
Adam
I do everything perfectly, except from my mistakes
Andrew Herrmann
Occasional Advisor

Re: ld error: $global$ (data) (probably missing /usr/ccs/lib/crt0.o)

FYI: I used the -b option with ld when linking the shared libraries.

Compiling with aCC and then using chatr works perfectly! Thanks for your help

Andy
Umapathy S
Honored Contributor

Re: ld error: $global$ (data) (probably missing /usr/ccs/lib/crt0.o)

hi Andrew,
Adam deserves a 10 for his replies. Please assign the points and make the thread complete so that others can also see it.

thanks,
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
Xin An Chen
New Member

Re: ld error: $global$ (data) (probably missing /usr/ccs/lib/crt0.o)

I also got exactly the same problem, after I used chatr suggested by Adam, I got another problem as follows:

Bad magic number for shared library.

...

Exec format error

If I only use aCC to compile the executable, everything is just fine.

Could you please tell me how to resolve this problem?

Thanks very much!

Xin An
ranganath ramachandra
Esteemed Contributor

Re: ld error: $global$ (data) (probably missing /usr/ccs/lib/crt0.o)

your understanding that the linker should not bother about crt0 for '-dynamic' links is not correct (at least for PA32). PA32 dynamic executables still need crt0.o for program startup (e.g. to load the dynamic loader).

when you dont give the compiler the '-b' option, it assumes that you want to build an executable. so when calling the linker, the compiler will include the crt0.o as the first object file in the link line. you may have missed this out when you linked using ld directly. you can use the compiler's -v flag to see what link line it uses. however it is recommended that you use the compiler for linking, unless you are very sure of what you are doing.
 
--
ranga
[i work for hpe]

Accept or Kudo

ranganath ramachandra
Esteemed Contributor

Re: ld error: $global$ (data) (probably missing /usr/ccs/lib/crt0.o)

about your reason for using ld directly: you can pass anything to the linker using the -Wl flag on the compiler command line. so '+s' can be passed as '-Wl,+s' and '-h hiddensym' can be passed as '-Wl,-h,hiddensym' (i.e. replace spaces with commas).

you can pass multiple such sets of options to the linker using as many '-Wl's as you like on the compile line.
 
--
ranga
[i work for hpe]

Accept or Kudo