call procedure in Linux-Ada-module from "normal" program




Hi
Debian sarge kernel 2.4.27, gcc-3.3

I've been tinkering with modules by using Ada.
The module compiles, and I manage to do insmod on it.
The symbols appears in ksyms; like "some_call_me".

Now I wish to call "some_call_me" from the test program (3) - is that
possible?

I compile it with "gnatmake test_somemodule.adb"
It fails during linking :

gnatbind -x test_somemodule.ali
gnatlink test_somemodule.ali
../test_somemodule.o(.text+0x1f): In function `_ada_test_somemodule':
: undefined reference to `some_call_me'
collect2: ld returned 1 exit status
gnatlink: cannot call /usr/bin/gcc-3.3
gnatmake: *** link failed.


How do I make the linker link with the kernel symbol?


Frank





-----------
1 (slightly edited in this post)
--------------------------------------------------------------------------------------------------------------
with Interfaces.C;

package SomeModule is

-- Module Variables

type Aliased_String is array (Positive range <>) of aliased Character;
pragma Convention (C, Aliased_String);

Kernel_Version: constant Aliased_String:="2.4.27-2-386" &
Character'Val(0);
pragma Export (C, Kernel_Version, "kernel_version");

Mod_Use_Count: Integer;
Pragma Export (C, Mod_Use_Count, "mod_use_count_");

-- Kernel Calls

procedure Printk( s : string );
pragma import( C, printk, "printk" );

-- Our Module Functions

function Init_Module return Interfaces.C.int;
pragma Export (C, Init_Module, "init_module");

procedure Cleanup_Module;
pragma Export (C, Cleanup_Module, "cleanup_module");

procedure Call_Me;
Pragma Export (C, Call_Me, "some_call_me");

end SomeModule;


with Interfaces.C;

with System.Machine_Code; use System.Machine_Code;

--with System.Storage_Elements;

with Interfaces; use Interfaces;

2 (slightly edited in this post)
--------------------------------------------------------------------------------------------------------------
package body SomeModule is



function Init_Module return Interfaces.C.int is
begin
Printk("Hello,World! Hi Frank" & Character'val(10) & character'val(0));
return 0;
end Init_Module;

procedure Cleanup_Module is
begin
Printk("Goodbye , World! Bye Frank!" & Character'val(10) &
character'val(0));
end Cleanup_Module;

procedure Call_Me
is
begin
Printk("Call me" & Character'val(10) & character'val(0));
end Call_Me;

end SomeModule;

3
-------------------------------------------------------------------------------------------------------------------------

procedure test_somemodule
is
procedure Call_Me;
pragma Import (C, Call_Me, "some_call_me");
begin
text_io.put_line("Test_Somemodule");
Call_Me;
end test_somemodule;


.



Relevant Pages

  • [RFC] New kernel-message logging API
    ... Backwards compatibility with printk(), syslog, etc. ... way the whole kernel can be converted to a new interface in one go. ... const char *format; ...
    (Linux-Kernel)
  • Re: Documentation of kernel messages (Summary)
    ... suggested solutions for documentation / translation of kernel messages ... the messages should _be_ documentation. ... Use printk format string as message identifier ...
    (Linux-Kernel)
  • Re: noisy edac
    ... > into the kernel. ... > offer the user two options: either printk() or be silent. ... looking in the logs it allows all of the errors to be detected and harvested. ...
    (Linux-Kernel)
  • Re: [RFC/PATCH] Documentation of kernel messages
    ... I was more modest, proposing that we ... We could generate the hash using the format string of the printk. ... exactly one kernel and the message catalog belongs therefore to exactly ... the translations could be managed by anyone outside of the normal/ ...
    (Linux-Kernel)
  • Re: noisy edac
    ... > to be printed in case of error, too (see Intel Chipset Specifications) ... the kernel should not be silent when errors are ... either printk() or be silent. ...
    (Linux-Kernel)