Re: How to use -nostdlib?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2015-05-13 at 22:19 -0500, Peng Yu wrote:
> I tried the following commands which are supposed to work, but didn't.
> Does anybody know what is wrong? Thanks.
> 
> https://blogs.oracle.com/ksplice/entry/hello_from_a_libc_free
> 
> $ cat test.c
> #include <stdio.h>
> int main() {
>   printf("Hello World\n");
> }
> $ gcc -nostdlib -o test_nostdlib test.c
> /usr/bin/ld: warning: cannot find entry symbol _start; defaulting to
> 0000000000400144
> /tmp/ccZBi5G9.o: In function `main':
> test.c:(.text+0xa): undefined reference to `puts'
> collect2: error: ld returned 1 exit status
> 

It isn't supposed to work. If you look at the linked example, that one
doesn't call printf. Comment out the printf call and this should link as
expected. Restoring "puts" (used by printf) without using the standard
libraries is a more advanced subject.

-- Brian





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux