Operating System - HP-UX
1833883 Members
1485 Online
110063 Solutions
New Discussion

ld: Invalid loader fixup in text space needed in output file for symbol

 
SOLVED
Go to solution
Andrew Herrmann
Occasional Advisor

ld: Invalid loader fixup in text space needed in output file for symbol

I hate to ask so many questions, but...

I created a simple "hello world" program and compiled/linked as follows:

aCC -c +z main.cpp -o main.o
ld -v -b -t -o main.sl main.o -l:libc.a

Everything works beautifully.

I then take more complex c++ code, compiling and linking as above. However, with the more complex code, I receive the following error:

ld: Invalid loader fixup in text space needed in output file for symbol "$00000037" in input file: "/usr/lib/libc.a(doprnt.o)"

I used nm on libc to reveal the following information:

doprnt.o:
U $$div2I
U $$divI_10
U $$divI_5
U $$mul2U
U $$rem2I
00002ed8 t $00000037
00000980 t $00000038

So, what in my code would cause this error? And more importantly, how do I fix it?

Thanks,

Andy
6 REPLIES 6
Umapathy S
Honored Contributor

Re: ld: Invalid loader fixup in text space needed in output file for symbol

Can you brief exactly where you got the error.

In the first place I dont understand why are you creating a shared library by including the libc archive library.

Make sure that you create the shared library with the necessary object files only and executble with libc.sl instead of libc.a.

Hope this helps

Umapathy
Arise Awake and Stop NOT till the goal is Reached!
Andrew Herrmann
Occasional Advisor

Re: ld: Invalid loader fixup in text space needed in output file for symbol

Basically I'm trying to build a shared library that will run independent of the aCC shared libraries. In other words, I don't want to have to distribute all the libraries to users who might not have them installed.

I figured that I could link the static (archive) libraries into my shared library. I'm guessing that the linker is having a problem because libc.a was not compiled with PIC.

So, I guess here are my questions:

1) Is it safe to assume that the shared libraries will be there, or do I need to distribute these?

if so:

2) Is there any way to build my shared library so that it's not necessary for the end user to have the C++ shared libraries?

3) What's the best way to generate a complete list of all shared libraries that are required?

Thanks,

Andy
Umapathy S
Honored Contributor
Solution

Re: ld: Invalid loader fixup in text space needed in output file for symbol

Andy,
With my experience I am trying my best to help you.

Whenever you distribute a software, you may list your dependencies (ofcourse OS is the first thing).

Mostly all Operating systems will have the necessary libraries (except development API libraries) in place if its properly installed. I dont think you can distribute libc along with your application. Copyright violation !!!!

We need to have a baseline to start our work and there comes the dependencies and you can safely assume that libc.sl will be there (ofcourse the user should have necessary patches installed).

Its the developer who should know how to build and distribute. So we should know which libraries we are linking with. Try ldd on the shared-lib/executable after building.

Hope this helps and I am not going away from what you want

cheers
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
Mike Stroyan
Honored Contributor

Re: ld: Invalid loader fixup in text space needed in output file for symbol

Look at this link for guidelines on distributing code that uses aCC-
http://docs.hp.com/hpux/onlinedocs/2213/distributing.htm#distributing

It is a bad idea to link a shared library with either libc.a or libc.sl. You really should be depending on the a.out to be linked with the right libc.sl for your library. If you try to bring in libc.sl and the a.out didn't have it, you will just cause a dld.sl error about loading "thread local storage".
Andrew Herrmann
Occasional Advisor

Re: ld: Invalid loader fixup in text space needed in output file for symbol

Even if I don't explicitly add the libc library (-lc), it seems to be required (see dump from chatr below). Based on the link you gave me, it looks like some of these files require aCC.

dynamic ../sl1/libsl1.sl
dynamic ../sl2/libsl2.sl
dynamic ../sl3/libsl3.sl
dynamic /usr/lib/librwtool.2
dynamic /usr/lib/libstd.2
dynamic /usr/lib/libstream.2
dynamic /usr/lib/libCsup.2
dynamic /usr/lib/libm.2
dynamic /usr/lib/libcl.2
dynamic /usr/lib/libc.2
static /usr/lib/libdld.2

Any thoughts?
Mike Stroyan
Honored Contributor

Re: ld: Invalid loader fixup in text space needed in output file for symbol

If you create a program with aCC then it will automatically link the program with the C++ runtime libraries and libc. Programs should be linked with libc.
If you create a shared library with "aCC -b" then it will not link the library with the C++ runtime libraries or libc.
You should use "aCC -b" to link shared libraries that contain C++ code. Don't use "ld -b".
If you want to create a shared library that contains aCC built code and allow it to be used by programs built and linked by cc, then you need to link in extra C++ runtime libraries as described in the link I pointed to.