This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
ld: creating a dynamically linked executable ...
- From: kedar mhaswade <kedar dot mhaswade at gmail dot com>
- To: binutils at sourceware dot org
- Date: Thu, 11 Jul 2013 06:17:16 -0700
- Subject: ld: creating a dynamically linked executable ...
Still a newbie. Please be kind. Hope the question is clear.
I have a simple (GAS syntax) assembly program [1] which calls a C
function (printf) defined in standard C library. Aren't these the
right commands to create the executable?
1) as -g -o use-of-lib.o use-of-lib.s
2) ld -o use-of-lib use-of-lib.o -lc
I pass -lc to ld because I think that printf and exit functions are
defined in libc.so; and man ld shows that libc.so would be searched
for the function definitions. Strange thing is that above sequence of
commands produces no error and yet, the created executable
(use-of-lib) behaves weirdly [2] on my shell. This is baffling.
What am I missing?
Regards,
Kedar
uname -a for the computer:
Linux ubuntu-guest 3.2.0-29-generic-pae #46-Ubuntu SMP Fri Jul 27
17:25:43 UTC 2012 i686 i686 i386 GNU/Linux
[1] assembly program name: use-of-lib.s
.section .data
hw:
.ascii "hello world\n\0"
.section .text
.global _start
_start:
pushl $hw
call printf
pushl $0
call exit
[2]: weird behavior
$> as -g -o use-of-lib.o use-of-lib.s
$> ld -o use-of-lib use-of-lib.o -lc
$> ./use-of-lib
zsh: no such file or directory: ./use-of-lib