comp.lang.ada
 help / color / mirror / Atom feed
* call procedure in Linux-Ada-module from "normal" program
@ 2006-08-24 16:33 Frank
  2006-08-24 18:22 ` Björn Persson
  2006-08-25 11:10 ` Manuel Gomez
  0 siblings, 2 replies; 4+ messages in thread
From: Frank @ 2006-08-24 16:33 UTC (permalink / 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; 





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

* Re: call procedure in Linux-Ada-module from "normal" program
  2006-08-24 16:33 call procedure in Linux-Ada-module from "normal" program Frank
@ 2006-08-24 18:22 ` Björn Persson
  2006-08-24 19:46   ` Frank
  2006-08-25 11:10 ` Manuel Gomez
  1 sibling, 1 reply; 4+ messages in thread
From: Björn Persson @ 2006-08-24 18:22 UTC (permalink / raw)


Frank wrote:
> 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?

There are a number of ways to communicate with Linux, but you can't just 
call a procedure like that. That's true for all programming languages. A 
kernel isn't just another library.

I suggest that you look around for information on system calls, trap 
instructions and IOCTLs. You'll probably only find examples in C, but 
when you know how to do what you want in C, I'm sure someone here can 
help you translate it to Ada.

-- 
Bj�rn Persson                              PGP key A88682FD
                    omb jor ers @sv ge.
                    r o.b n.p son eri nu



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

* Re: call procedure in Linux-Ada-module from "normal" program
  2006-08-24 18:22 ` Björn Persson
@ 2006-08-24 19:46   ` Frank
  0 siblings, 0 replies; 4+ messages in thread
From: Frank @ 2006-08-24 19:46 UTC (permalink / raw)


Hi!
Thank you for answer - I suspected this was the case.

Frank 





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

* Re: call procedure in Linux-Ada-module from "normal" program
  2006-08-24 16:33 call procedure in Linux-Ada-module from "normal" program Frank
  2006-08-24 18:22 ` Björn Persson
@ 2006-08-25 11:10 ` Manuel Gomez
  1 sibling, 0 replies; 4+ messages in thread
From: Manuel Gomez @ 2006-08-25 11:10 UTC (permalink / raw)


Maybe this text is useful for you, but don't know if you already follow
those steps.

Section "Writing Linux Modules" from the "The Big Online Book of Linux
Ada Programming":
http://www.pegasoft.ca/resources/boblap/16.html#16.16

Frank ha escrito:

> 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".
>




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

end of thread, other threads:[~2006-08-25 11:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-24 16:33 call procedure in Linux-Ada-module from "normal" program Frank
2006-08-24 18:22 ` Björn Persson
2006-08-24 19:46   ` Frank
2006-08-25 11:10 ` Manuel Gomez

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