This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: why ld return with error?


ali hagigat <hagigatali@gmail.com> writes:

> I have the following files:
> prog3.c
> #include <stdio.h>
> main(){
> 	printf("uuuuuu\n");
> }
> prog3.ld
> ASSERT(1,"there is not an error");
> Then :
> gcc -c prog3.c -o prog3.o
> ld prog3.o prog3.ld -o prog3
>
> ld: warning: cannot find entry symbol _start; defaulting to 0000000008048074
> prog3.o: In function `main':
> prog3.c:(.text+0x11): undefined reference to `puts'
> ------------------------------------------------------------------------
> I want to force gcc (or ld) to use its built-in functions as printf
> and puts(not to use the standard library functions like libc.a or
> libc.so). how can i do it?

gcc by default optimizes printf of a string constant ending in a newline
to call puts instead.  To disable that, use -fno-builtin-printf when
compiling.

I don't understand what you mean when you say that you want gcc to use
its built-in functions as printf rather than the standard library
functions.  gcc has no built-in printf function.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]