All of lore.kernel.org
 help / color / mirror / Atom feed
* Compile external module against linux source and use functionality in linux source
@ 2014-09-25  5:19 Arjun Pandey
  2014-09-25  6:36 ` Paul Bolle
  2014-09-25 12:27 ` Valdis.Kletnieks at vt.edu
  0 siblings, 2 replies; 9+ messages in thread
From: Arjun Pandey @ 2014-09-25  5:19 UTC (permalink / raw)
  To: kernelnewbies

Hi

I am trying to two things here.
1. Compile my module and export a function.
2. Use this exported function in modified kernel src and compile it.


Step 1 goes through fine. The module gets compiled fine.
However now when i try to compile the kernel i get linker error of
undefined reference to the function exported from the kernel module.

I can't find any documentation on this usecase.


Thanks
Arjun

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Compile external module against linux source and use functionality in linux source
  2014-09-25  5:19 Compile external module against linux source and use functionality in linux source Arjun Pandey
@ 2014-09-25  6:36 ` Paul Bolle
  2014-09-25  6:41   ` Arjun Pandey
  2014-09-25 12:27 ` Valdis.Kletnieks at vt.edu
  1 sibling, 1 reply; 9+ messages in thread
From: Paul Bolle @ 2014-09-25  6:36 UTC (permalink / raw)
  To: kernelnewbies

On Thu, 2014-09-25 at 10:49 +0530, Arjun Pandey wrote:
> However now when i try to compile the kernel i get linker error of
> undefined reference to the function exported from the kernel module.

I'm guessing you're compiling that module as, well, a module (ie,
CONFIG_EXAMPLE=m). What happens when you make it built-in
(CONFIG_EXAMPLE=y)?


Paul Bolle

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Compile external module against linux source and use functionality in linux source
  2014-09-25  6:36 ` Paul Bolle
@ 2014-09-25  6:41   ` Arjun Pandey
  2014-09-25  6:48     ` Paul Bolle
  0 siblings, 1 reply; 9+ messages in thread
From: Arjun Pandey @ 2014-09-25  6:41 UTC (permalink / raw)
  To: kernelnewbies

No i am just compiling the external module and using this
functionality in existing linux source code. I am not adding any
additional modules within the tree which use this function.

In my case i am trying to use the function directly in udp_rcv
function of net/ipv4/udp.c

Regards
Arjun

On Thu, Sep 25, 2014 at 12:06 PM, Paul Bolle <pebolle@tiscali.nl> wrote:
> On Thu, 2014-09-25 at 10:49 +0530, Arjun Pandey wrote:
>> However now when i try to compile the kernel i get linker error of
>> undefined reference to the function exported from the kernel module.
>
> I'm guessing you're compiling that module as, well, a module (ie,
> CONFIG_EXAMPLE=m). What happens when you make it built-in
> (CONFIG_EXAMPLE=y)?
>
>
> Paul Bolle
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Compile external module against linux source and use functionality in linux source
  2014-09-25  6:41   ` Arjun Pandey
@ 2014-09-25  6:48     ` Paul Bolle
       [not found]       ` <CAKpWUYnUyd4mErC2wRBGqhHXg35PHWeGf2dnNJk=LTsbDx=n7A@mail.gmail.com>
  0 siblings, 1 reply; 9+ messages in thread
From: Paul Bolle @ 2014-09-25  6:48 UTC (permalink / raw)
  To: kernelnewbies

[Manually corrected top-posting.]

On Thu, 2014-09-25 at 12:11 +0530, Arjun Pandey wrote:
> On Thu, Sep 25, 2014 at 12:06 PM, Paul Bolle <pebolle@tiscali.nl> wrote:
> > I'm guessing you're compiling that module as, well, a module (ie,
> > CONFIG_EXAMPLE=m). What happens when you make it built-in
> > (CONFIG_EXAMPLE=y)?
> >
> No i am just compiling the external module and using this
> functionality in existing linux source code. I am not adding any
> additional modules within the tree which use this function.

So, does the linker error disappear when you build your kernel with your
new module built-in (ie, the new module is part of the kernel image)?
 
> In my case i am trying to use the function directly in udp_rcv
> function of net/ipv4/udp.c


Paul Bolle

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Compile external module against linux source and use functionality in linux source
       [not found]         ` <1411628331.6613.11.camel@x220>
@ 2014-09-25  7:00           ` Arjun Pandey
  2014-09-25  7:29             ` Paul Bolle
  0 siblings, 1 reply; 9+ messages in thread
From: Arjun Pandey @ 2014-09-25  7:00 UTC (permalink / raw)
  To: kernelnewbies

My bad. I just hit the default reply button :)

On Thu, Sep 25, 2014 at 12:28 PM, Paul Bolle <pebolle@tiscali.nl> wrote:
> On Thu, 2014-09-25 at 12:24 +0530, Arjun Pandey wrote:
>> I tried moving the module to kernel tree as well. Ideally this will be
>> out of tree module. That still didn't work.
>> I have included a header file with the extern function declaration in
>> the source file that i modified.
>> That didn't help either.
>
> You excluded kernelnewbies. Is that non purpose?
>
>
> Paul Bolle
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Compile external module against linux source and use functionality in linux source
  2014-09-25  7:00           ` Arjun Pandey
@ 2014-09-25  7:29             ` Paul Bolle
  2014-09-25  7:32               ` Arjun Pandey
  0 siblings, 1 reply; 9+ messages in thread
From: Paul Bolle @ 2014-09-25  7:29 UTC (permalink / raw)
  To: kernelnewbies

On Thu, 2014-09-25 at 12:30 +0530, Arjun Pandey wrote:
> On Thu, Sep 25, 2014 at 12:28 PM, Paul Bolle <pebolle@tiscali.nl> wrote:
> > On Thu, 2014-09-25 at 12:24 +0530, Arjun Pandey wrote:
> >> I tried moving the module to kernel tree as well. Ideally this will be
> >> out of tree module. That still didn't work.
> >> I have included a header file with the extern function declaration in
> >> the source file that i modified.
> >> That didn't help either.

Building a module built-in requires a bit more: changes to a kernel tree
Kconfig file and a Makefile. There must be a lot of documentation on
this. But I would do something like
    git grep -w tristate $(git ls-files "net/*Kconfig*")

and pick a few Kconfig symbols (ie, the things with lines reading
"config EXAMPLE"). The grep the tree again for their macros:
    git grep -w "CONFIG_EXAMPLE" net/

and figure out how things all fit together.

(My guess, of course, is that your linker error disappears when you
manege to build the module built-in. Once we know that, we can look
whether it's actually possible to achieve what you want to do with an
external module.)

Hope this helps.


Paul Bolle

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Compile external module against linux source and use functionality in linux source
  2014-09-25  7:29             ` Paul Bolle
@ 2014-09-25  7:32               ` Arjun Pandey
  0 siblings, 0 replies; 9+ messages in thread
From: Arjun Pandey @ 2014-09-25  7:32 UTC (permalink / raw)
  To: kernelnewbies

Thanks Paul. Let me try this out.

Regards
Arjun

On Thu, Sep 25, 2014 at 12:59 PM, Paul Bolle <pebolle@tiscali.nl> wrote:
> On Thu, 2014-09-25 at 12:30 +0530, Arjun Pandey wrote:
>> On Thu, Sep 25, 2014 at 12:28 PM, Paul Bolle <pebolle@tiscali.nl> wrote:
>> > On Thu, 2014-09-25 at 12:24 +0530, Arjun Pandey wrote:
>> >> I tried moving the module to kernel tree as well. Ideally this will be
>> >> out of tree module. That still didn't work.
>> >> I have included a header file with the extern function declaration in
>> >> the source file that i modified.
>> >> That didn't help either.
>
> Building a module built-in requires a bit more: changes to a kernel tree
> Kconfig file and a Makefile. There must be a lot of documentation on
> this. But I would do something like
>     git grep -w tristate $(git ls-files "net/*Kconfig*")
>
> and pick a few Kconfig symbols (ie, the things with lines reading
> "config EXAMPLE"). The grep the tree again for their macros:
>     git grep -w "CONFIG_EXAMPLE" net/
>
> and figure out how things all fit together.
>
> (My guess, of course, is that your linker error disappears when you
> manege to build the module built-in. Once we know that, we can look
> whether it's actually possible to achieve what you want to do with an
> external module.)
>
> Hope this helps.
>
>
> Paul Bolle
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Compile external module against linux source and use functionality in linux source
  2014-09-25  5:19 Compile external module against linux source and use functionality in linux source Arjun Pandey
  2014-09-25  6:36 ` Paul Bolle
@ 2014-09-25 12:27 ` Valdis.Kletnieks at vt.edu
  2014-09-26  6:24   ` Arjun Pandey
  1 sibling, 1 reply; 9+ messages in thread
From: Valdis.Kletnieks at vt.edu @ 2014-09-25 12:27 UTC (permalink / raw)
  To: kernelnewbies

On Thu, 25 Sep 2014 10:49:33 +0530, Arjun Pandey said:

> Step 1 goes through fine. The module gets compiled fine.
> However now when i try to compile the kernel i get linker error of
> undefined reference to the function exported from the kernel module.
>
> I can't find any documentation on this usecase.

In general, things that are built-into the kernel with CONFIG_FOO=y
are *not* allowed or able to reference symbols that are in a module.

This is because a module can potentially not be loaded (consider system
boot before you're up far enough to do a modprobe, as an important
special case), at which point trying to call the non-existent module
gets you an oops or panic.

So you can't find any doc on it because it's not supported.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 848 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140925/bd4aba7e/attachment.bin 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Compile external module against linux source and use functionality in linux source
  2014-09-25 12:27 ` Valdis.Kletnieks at vt.edu
@ 2014-09-26  6:24   ` Arjun Pandey
  0 siblings, 0 replies; 9+ messages in thread
From: Arjun Pandey @ 2014-09-26  6:24 UTC (permalink / raw)
  To: kernelnewbies

Hi Valdis

That makes sense :)
Moving the module to the kernel makes it work.

Thanks
Arjun

On Thu, Sep 25, 2014 at 5:57 PM,  <Valdis.Kletnieks@vt.edu> wrote:
> On Thu, 25 Sep 2014 10:49:33 +0530, Arjun Pandey said:
>
>> Step 1 goes through fine. The module gets compiled fine.
>> However now when i try to compile the kernel i get linker error of
>> undefined reference to the function exported from the kernel module.
>>
>> I can't find any documentation on this usecase.
>
> In general, things that are built-into the kernel with CONFIG_FOO=y
> are *not* allowed or able to reference symbols that are in a module.
>
> This is because a module can potentially not be loaded (consider system
> boot before you're up far enough to do a modprobe, as an important
> special case), at which point trying to call the non-existent module
> gets you an oops or panic.
>
> So you can't find any doc on it because it's not supported.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-09-26  6:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-25  5:19 Compile external module against linux source and use functionality in linux source Arjun Pandey
2014-09-25  6:36 ` Paul Bolle
2014-09-25  6:41   ` Arjun Pandey
2014-09-25  6:48     ` Paul Bolle
     [not found]       ` <CAKpWUYnUyd4mErC2wRBGqhHXg35PHWeGf2dnNJk=LTsbDx=n7A@mail.gmail.com>
     [not found]         ` <1411628331.6613.11.camel@x220>
2014-09-25  7:00           ` Arjun Pandey
2014-09-25  7:29             ` Paul Bolle
2014-09-25  7:32               ` Arjun Pandey
2014-09-25 12:27 ` Valdis.Kletnieks at vt.edu
2014-09-26  6:24   ` Arjun Pandey

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.