Author Topic: ld link problem - "No such file or directory"  (Read 25418 times)

nobody

  • Guest
ld link problem - "No such file or directory"
« on: March 01, 2009, 11:53:33 PM »
Hi,

When I link my binaries to dynamic libraries using ld than the link operation finishes successfully and the executable is there.
But when I try to run it I get an error message saying:

bash: ./my_executable: No such file or directory

By searching on the net I have found some similar cases and they said that it was solved by using gcc or by specifying an other dynamic linker for ld.
On my system this solved the problem:
ld "-I/lib64/ld-2.9.so" ....

But I do not understand why and what is happening.
It would be nice if someone could give some information why the ld does not work for dynamic linking.

Thanks,
Csaba

nobody

  • Guest
Re: ld link problem - "No such file or directory"
« Reply #1 on: June 23, 2009, 08:10:50 PM »
Hi,

I have the same Problem, my code looks like this:
------------------------------------------
section .text

extern printf
global start

start:
     push message
   call printf

mov eax, 1
   mov ebx, 0
   int 80h

section .data
message:    db "output some text", 10, 0
----------------------------------------------------------

asm & link commands: nasm -f elf -g test.asm && ld -o test test.o -lc

my OS is openSuse 11.1 (32-Bit)

couldn't solve this problem so far.


Regards,
Andreas Monsch

nobody

  • Guest
Re: ld link problem - "No such file or directory"
« Reply #2 on: June 23, 2009, 08:16:45 PM »
Me again,

i tried to solve the problem with the same approach as Csaba and it seems to work.
But i also don't fully understand the cause of the problem.

P.S.
the link and asm command looks now like this: nasm -f elf -g test.asm && ld -o test test.o -lc -I/lib/ld-2.9.so

Regards,
Andreas Monsch

nobody

  • Guest
Re: ld link problem - "No such file or directory"
« Reply #3 on: June 23, 2009, 11:00:12 PM »
Well... if I understand what I'm reading (maybe so, maybe not), this seems to be set in "configure.host" in the "ld" directory of your binutils source.

If you don't want to mess with recompiling ld (understandably), you can observe what ld is looking for by default by observing your executable in a text editor - it's fairly early in the file. Mine says "/lib/ld-linux.so.1". The "correct" answer is "/lib/ld-linux.so.2" (set with the "-I" or "--dynamic-linker" switch). If "/lib/ld-2.9.so" works... whatever you've got is "right", I guess.

This has been going on for quite a while. It might not be unreasonable to ask the binutils guys to "get it right". In the meantime, we use whatever workaround we can find, I guess...

Best,
Frank