comp.lang.ada
 help / color / mirror / Atom feed
From: "Frank" <franjoe@frisurf.no>
Subject: call procedure in Linux-Ada-module from "normal" program
Date: Thu, 24 Aug 2006 18:33:21 +0200
Date: 2006-08-24T18:33:21+02:00	[thread overview]
Message-ID: <44edd4d1$1@news.broadpark.no> (raw)


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; 





             reply	other threads:[~2006-08-24 16:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-24 16:33 Frank [this message]
2006-08-24 18:22 ` call procedure in Linux-Ada-module from "normal" program Björn Persson
2006-08-24 19:46   ` Frank
2006-08-25 11:10 ` Manuel Gomez
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox