From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,XPRIO autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,a99a6d8aa49592d5,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Frank" Newsgroups: comp.lang.ada Subject: call procedure in Linux-Ada-module from "normal" program Date: Thu, 24 Aug 2006 18:33:21 +0200 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 42.80-202-220.nextgentel.com X-Original-NNTP-Posting-Host: 42.80-202-220.nextgentel.com Message-ID: <44edd4d1$1@news.broadpark.no> X-Trace: news.broadpark.no 1156437201 80.202.220.42 (24 Aug 2006 18:33:21 +0200) Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!feeder.news-service.com!binfeed1.tudelft.nl!tudelft.nl!binfeed2.tudelft.nl!newsfeed.sunet.se!news01.sunet.se!News-Peer-Europe!news-peer-europe.sprintlink.net!news.net.hanse.com!nntp.gblx.net!nntp3.phx1!news.broadpark.no!not-for-mail Xref: g2news2.google.com comp.lang.ada:6345 Date: 2006-08-24T18:33:21+02:00 List-Id: 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;