kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: alexei@alexeicolin.com (Alexei Colin)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Link an out-of-tree module into vmlinux
Date: Fri, 28 Sep 2012 15:10:56 -0400	[thread overview]
Message-ID: <5065F640.30302@alexeicolin.com> (raw)
In-Reply-To: <CABi1daGthoYmfnpDHfXVNA6PfHWFB8btKwtnOdsS4n3CH5AToQ@mail.gmail.com>

Thank you for your reply. I am pursuing a slightly unusual goal:

On 09/28/2012 02:01 PM, Dave Hylands wrote:
> On Fri, Sep 28, 2012 at 9:01 AM, Alexei Colin <alexei@alexeicolin.com>
wrote:
>> Does the build system support building built-in components of vmlinux
>> out-of-tree?
>>
>> That is, I know that these two are possible:
>> (1) build out-of-tree code as a loadable kernel module (.ko) (use the
>> M=/path/to/out-of-tree/dir)
>> (2) build an in-tree module as a statically built-in component of
>> vmlinux instead of as a LKM (use the CONFIG_<module>=y, or otherwise add
>> the object files to obj-y instead of obj-m)
>>
>> The question is can you build an an _out-of-tree_ module as a statically
>> built-in component of vmlinux?
>

> You can build the entire kernel out-of-tree, and by that I mean have
> the object files go into a different tree than the source files.
Yes, the "O=" usage is clear, and I do use it.

> It depends on what you mean by "out-of-tree"
Sorry, by out-of-tree, I meant to refer to source code. For example, in
(1) above, the module's *code* can be out-of-tree: it can live outside
of the kernel source directory ($KDIR). The modules object files would
go into same place as its source.

> You can't build the static portions separate from the rest of the
> kernel, i.e. all of the objects are in the same tree, either the
> source tree, or some other tree.
In the case of out-of-tree modules, though, the objects do not have to
go to the same tree where the rest of the objects go. They end up in the
location specified by 'M='. That's were my inspiration comes from. In
fact 'M=' and 'obj-y' bring me half way there: I get a built-in.o in the
'M=' location. All I need the next step to be: link 'vmlinux' as usual,
except include the built-in.o from the 'M='.

To clarify: can I statically link some code into the kernel, but keep
this code (and its object files) in a directory that's not a descendant
of KDIR?

I can already accomplish this by editting root makefile and adding value
of an MBUILTIN variable to vmlinux-dirs list, e.g. via core-y, then, do
'make M=my-out-of-tree-dir && make MBUILTIN=my-out-of-tree-dir vmlinux'.
But I hoped there's some already supported MBUILTIN-like var that does
this in one step and without hacking the root makefile.

I realize that this is strange and has implications on prerequisite
checks -- introduces a strange dependency of vmlinux on something
outside of KDIR, which doesn't happen for modules, of course, because
vmlinux doesn't depend on them. But, this seems solvable by persisting
what went into the vmlinux link and invalidating if that list changes.

Thanks again.

-alexei

      reply	other threads:[~2012-09-28 19:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-28 16:01 Link an out-of-tree module into vmlinux Alexei Colin
2012-09-28 18:01 ` Dave Hylands
2012-09-28 19:10   ` Alexei Colin [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=5065F640.30302@alexeicolin.com \
    --to=alexei@alexeicolin.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).