kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: unixman.linuxboy@gmail.com (Sarbojit Ganguly)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Incremental Linking
Date: Wed, 23 May 2012 22:21:14 +0530	[thread overview]
Message-ID: <CAP2rAF877t2gtE8sQYqMkjRrEUq1aPyYxjYprNt6_p9R4jC0kw@mail.gmail.com> (raw)
In-Reply-To: <CABi1daFX5vhCQAUPcvE58wiKCBVzYyBxm-V6JZMNVbAwigcwSg@mail.gmail.com>

Hello Dave,

I tried to explain this feature (no doubt you have explain it
perfectly) but he is looking for _how_ kernel module gets loaded and
somehow (I wonder how!) dubs the entire process as "incremental link"
!

On 23 May 2012 21:47, Dave Hylands <dhylands@gmail.com> wrote:
> Hi Somanath,
>
> On Tue, May 22, 2012 at 2:56 AM, somanath sahoo <bapi_mvit2004@yahoo.com> wrote:
>> Hi,
>>
>> As newbie in linux kernel,?I would like to?understand?the concept of
>> "incremental linking?" w.r.t to linux kernel module.
>
> Incremental linking is basically just taking some objects files,
> linking them together to produce a larger object file. The object file
> still has undefined references. It will also coalesce sections of the
> same name. The kernel likes to use sections for storing pointers to
> initcall functions and other things like that.
>
> Some people might also call this partial linking. The kernel uses this
> technique for the main portion of the kernel as well. If you look
> through your build directory, you will find a whole bunch of
> built-in.o files. Each one of these is a partially linked object file
> containing all of the object files from the current directory and
> built-in.o files from directories below.
>
> With kernel modules, there are some special automatically generated C
> files which also get linked in (IIRC that have a name like foo.mod.c)
>
> A kernel module is conceptually identical to a shared library (which
> is also partially linked and may contain unresolved references).
>
> You can do incremental linking ?by doing:
>
> echo "int foo1(void) { return 1; }" > foo1.c
> echo "int foo2(void) { return 2; }" > foo2.c
> gcc -c foo1.c
> gcc -c foo2.c
> ld -r -o foo.o foo1.o foo2.o
>
> You'll now have foo.o which has both foo1.o and foo2.o partially
> linked together, which you can see by using:
>
> nm foo.o
>
> --
> Dave Hylands
> Shuswap, BC, Canada
> http://www.davehylands.com
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

  reply	other threads:[~2012-05-23 16:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-22  9:56 Incremental Linking somanath sahoo
2012-05-22 15:17 ` Jonathan Neuschäfer
2012-05-23  5:39   ` somanath sahoo
     [not found]     ` <CAP2rAF8dY4tS3aZ_+OBnv2eNK07wMvhjoC=TEaQF8AGXgc=5vg@mail.gmail.com>
     [not found]       ` <1337757675.30429.YahooMailNeo@web161202.mail.bf1.yahoo.com>
2012-05-23  7:50         ` Sarbojit Ganguly
2012-05-23  7:51           ` Sarbojit Ganguly
2012-05-22 17:40 ` Mulyadi Santosa
2012-05-23 16:17 ` Dave Hylands
2012-05-23 16:51   ` Sarbojit Ganguly [this message]
2012-05-23 17:03     ` Dave Hylands
2012-05-28  7:58     ` Jim Cromie

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=CAP2rAF877t2gtE8sQYqMkjRrEUq1aPyYxjYprNt6_p9R4jC0kw@mail.gmail.com \
    --to=unixman.linuxboy@gmail.com \
    --cc=kernelnewbies@lists.kernelnewbies.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).