public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: ali hagigat <hagigatali@gmail.com>
To: Ian Lance Taylor <iant@google.com>, binutils@sourceware.org
Subject: Re: why ld return with error?
Date: Mon, 31 Jan 2011 08:28:00 -0000	[thread overview]
Message-ID: <AANLkTimZX_pPpF=iL9pqGhDyW1zpgH_mhHCGY0L=2gY8@mail.gmail.com> (raw)
In-Reply-To: <mcr1v3tmtiu.fsf@google.com>

Thank you for the reply. I think that GCC compiler collection has the
definitions and C code of some standard libraries. It means that the
code of printf exists inside the code of gcc and gcc does not need to
go to /usr/bin on hard disk to find libc.a and then find the defintion
and the body of printf.
Is that right? or I am mistaken?
If I am mistaken what will be the meaning of -fno-builtin then? I
think the code of built-in functions exist inside the code segment of
gcc when it is invoked.
Regards

On Mon, Jan 31, 2011 at 10:47 AM, Ian Lance Taylor <iant@google.com> wrote:
> 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
>

  reply	other threads:[~2011-01-31  8:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-31  5:02 ali hagigat
2011-01-31  7:17 ` Ian Lance Taylor
2011-01-31  8:28   ` ali hagigat [this message]
2011-01-31  9:00     ` Dave Korn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='AANLkTimZX_pPpF=iL9pqGhDyW1zpgH_mhHCGY0L=2gY8@mail.gmail.com' \
    --to=hagigatali@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=iant@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).