Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

linux x86-64 NASM assembly [HELP!]

Name: Anonymous 2009-09-12 17:07

When I link against libc (using ld file.o -lc), a.out doesn't work. I can't execute it with ./a.out (no such file or directory), bash a.out (cannot execute binary file), and trying ldd a.out gives me «no such file or directory» too.
What am I doing wrong? inb4 “using assembly”

Name: Anonymous 2009-09-12 17:10

>>1
You fool, bash runs shell scripts not executables!

There's the assembler and the linker step. Find in which the error occurs, give us a better description of what went wrong and which messages you got for error feedback.

Name: Anonymous 2009-09-12 17:22

>>2
You're right, I'm ashamed. It's just some advice I found while searching through the Internet a bit.

I'm pretty sure that something goes wrong with the linking.
I tried one of my earlier exercises, which doesn't use any external libraries. a.out from ld hw64.o works fine; a.out from ld hw64.o -lc gives me the same error when I try to run it.
And I don't get any error messages during assembling and linking.

Name: Anonymous 2009-09-12 17:36

Also, just checked, when I don't link it using ld but just run gcc printf.o, everything works fine. Now trying to figure out which of those options I need to use.

Name: Anonymous 2009-09-12 19:43

disregard this thread, I decided to just change my _start to main and use gcc.
still, if anyone knows the reason using ld the way I did doesn't work, I'd appreciate your input.

Name: Anonymous 2009-09-13 3:28

Link with the startup objects.

Name: Anonymous 2009-09-13 5:14

Put in the header yourself and build a flat binary.

Name: Anonymous 2009-09-13 13:41

>>1
yeah i had that problem before. i fixed it by linking again libc.a instead of libc.so.

Name: Anonymous 2009-09-13 17:11

>>8
You've statically linked against the standard C library? HIBT?

Name: Anonymous 2009-09-14 7:25

>>9
no. Static linking will only pull in the needed functions so it's  not a big deal - It's not your binary will have a whole copy of libc within it.

Name: Anonymous 2011-01-31 21:07

<-- check em dubz

Name: tray 2012-03-14 15:22

you better be

Don't change these.
Name: Email:
Entire Thread Thread List