linux-kbuild.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: murtuja bharmal <murtuja_bharmal@yahoo.com>
Cc: linux-kbuild@vger.kernel.org
Subject: Re: help required for KBUILD
Date: Mon, 11 Feb 2008 15:10:51 +0100	[thread overview]
Message-ID: <20080211141051.GD20959@uranus.ravnborg.org> (raw)
In-Reply-To: <193302.60802.qm@web95116.mail.in2.yahoo.com>

Hi Murtuja.

On Mon, Feb 11, 2008 at 07:25:06AM +0000, murtuja bharmal wrote:
> Sudo Code for kernel module compilation using KBUILD
> SYSTEM. 
> 
> If module versioing is enabled. 

I assume you are aware that all these steps are taken care
of by kbuild and that you do not need to do them manually
neither to understand them to use them?

This is also true for external modules.

> 
> step1. 
> 
> create a .tmp_<moudule name>.o file from <module
> name>.c using gcc. 
> 
> step2. 
> 
> if objdump -h .tmp_<module name>.o | grep -q
> __ksymtab; then 
> 
> gcc -D GENKSYMS
> ..............|scripts/genksyms/genksyms >
> .tmp_<module name>.ver 
> 
> ld -m elf_i386 -r -o <module name>.o .tmp_<module
> name>.o .tmp_<module name>.ver 
> 
> else 
> 
> mv -f .tmp_<module name>.o <module name>.o 
> 

Correct -this is also explained in Makefile.build like this:
# When module versioning is enabled the following steps are executed:
# o compile a .tmp_<file>.o from <file>.c
# o if .tmp_<file>.o doesn't contain a __ksymtab version, i.e. does
#   not export symbols, we just rename .tmp_<file>.o to <file>.o and
#   are done.
# o otherwise, we calculate symbol versions using the good old
#   genksyms on the preprocessed source and postprocess them in a way
#   that they are usable as a linker script
# o generate <file>.o from .tmp_<file>.o using the linker to
#   replace the unresolved symbols __crc_exported_symbol with
#   the actual value of the checksum generated by genksyms


> Step 3. 
> 
> LINUXDIR/scripts/mod/modpost .............. vmlinux
> <module name>.o 
> 
> #the above command create file <module name>.mod.c 
> 
> Step 4. 
> 
> gcc ....................... - o <module name>.mod.o
> <module name>.mod.c 
> 
> Step 5. 
> 
> ld -m elf_i386 -r -o <module name>.ko <module name>.o
> <module name>.mod.o 
> 
> 
> 
> In step 2 it is checking for 
> __ksymtab on .tmp_<module name>.o header.
> 
> Can anybody tell me when __ksymtab in included in
> module object header.
> Is it only added when we have EXPORT_SYMBOL Macro in
> kernel module code or any other reason.
Correct - it is only included if there is an exported symbol,
as an exported symbol place some info in a section named ksymtab_*.

> And what is .tmp_<module name>.ver file.
If you look at it you will see it caontains the CRC values for the
exported symbols - the values are then checked later when the module
is loaded by the module for consitency.

	Sam

      reply	other threads:[~2008-02-11 14:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-11  7:25 help required for KBUILD murtuja bharmal
2008-02-11 14:10 ` Sam Ravnborg [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=20080211141051.GD20959@uranus.ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=murtuja_bharmal@yahoo.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 NNTP newsgroup(s).