linux-assembly.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Maciej Hrebien <m_hrebien@wp.pl>
To: linux-assembly@vger.kernel.org
Subject: Re: linking with ld
Date: Sun, 15 Sep 2002 15:34:50 +0200	[thread overview]
Message-ID: <3D848C7A.ADFEE75D@wp.pl> (raw)
In-Reply-To: 3D83F713.4860A455@students.mimuw.edu.pl

Mateusz Srebrny wrote:
> 
> Hi,
> 
> I have question about ld.
> Precisely:
> I have an ELF object (produced by nasm) defining global procedure named
> start.
> I want to link it with object made by 'gcc -c' on file loking like this:
> 
> #include <stdio.h>
> 
> extern void start(void);
> 
> int main() {
>   start();
>   return 0;
> }
> 
> I tried 'ld main.o start.o -o main -lc'...

You can link it using gcc, not ld directly like this: gcc -o mail
main.o start.o. It should work just fine.

> it complained sth about not defining _start label, and then refused to
> execute main file (which was produced despite ld warnings)...

_start is the default entry point. If You won't create any global label
named _start in Your code then the ld doesn't know what to put in ELF
header as a starting point. You may set it explicitly using ld's -e
option which i think is the good solution if You can't link with gcc
like in above example.
 
> I wanted to do it with ld, 'couse I thought that linker is to link
> things...
> Of course linking it with gcc works, but again I thought that compiler
> is to compile things to objects...

gcc works with ld. gcc sends its results to ld.
 
> and the info for ld doesn't offer help in the matter... (at least I
> don't see it there)
> 
> I would be grateful for your help...
>         Mateusz Srebrny
> 
> PS the question "why do I want to link a nasm object with a C one?" is
> very difficult to answer... i just have to do it...

-- 
Maciej Hrebien


      reply	other threads:[~2002-09-15 13:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-14 14:31 debugging in linux Hernan
2002-09-14 22:51 ` lx
2002-09-15  2:57   ` linking with ld Mateusz Srebrny
2002-09-15 13:34     ` Maciej Hrebien [this message]

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=3D848C7A.ADFEE75D@wp.pl \
    --to=m_hrebien@wp.pl \
    --cc=linux-assembly@vger.kernel.org \
    /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 NNTP newsgroup(s).