From: Nadav Har'El <n...@scylladb.com>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master
apps: trivial (and non-working) fpc example application
This is a trivial hello-world Free Pascal application.
It does't currently work because of missing syscall instruction support.
https://github.com/cloudius-systems/osv/issues/590
Hopefully it will begin working when OSv adds syscall instruction support.
Stack trace we get in fpc initialization function:
4 0x0000000000482754 in invalid_opcode (ef=0xffff800002a2b088)
at arch/x64/exceptions.cc:320
5 <signal handler called>
6 0x0000100000c07b72 in SYSTEM_$$_FPSYSCALL$INT64$INT64$INT64$$INT64 ()
7 0x0000100000c0839a in SYSTEM_$$_FPGETRLIMIT$LONGINT$PRLIMIT$$LONGINT ()
8 0x0000000c000ff3b0 in ?? ()
9 0x0000100000c2a357 in SYSTEM_$$_CHECKINITIALSTKLEN$QWORD$$QWORD ()
10 0x0000000000000000 in ?? ()
Note that to see these function names, you'll need to remove the strip
command from the script ppash.sh automatically generated by fpc, and run
it again.
This example was based on
http://wiki.lazarus.freepascal.org/Free_Pascal_on_OSv
but I wanted to not need the special linking instructions.
Signed-off-by: Nadav Har'El <n...@scylladb.com>
Message-Id: <1472143611-31621-1-git-send-email-...@scylladb.com>
---
diff --git a/fpc-example/Makefile b/fpc-example/Makefile
--- a/fpc-example/Makefile
+++ b/fpc-example/Makefile
@@ -0,0 +1,11 @@
+.PHONY: module
+module: fpc-hello
+
+
+fpc-hello: fpc-hello.pas
+ fpc -fPIC -XD -Xc -s -ofpc-hello fpc-hello.pas
+ # if we drop -init and -fini from link line, it works. Like this it
doesn't, currently.
+ sh ppas.sh
+
+clean:
+ rm -f fpc-hello fpc-hello.o link.res ppas.sh
diff --git a/fpc-example/README b/fpc-example/README
--- a/fpc-example/README
+++ b/fpc-example/README
@@ -0,0 +1 @@
+Doesn't work - check out https://github.com/cloudius-systems/osv/issues/590
diff --git a/fpc-example/fpc-hello.pas b/fpc-example/fpc-hello.pas
--- a/fpc-example/fpc-hello.pas
+++ b/fpc-example/fpc-hello.pas
@@ -0,0 +1,20 @@
+library hello;
+
+uses
+ unixtype;
+
+// use the C function 'write'
+function CWrite(fd : cInt; buf:pChar; nbytes : unixtype.TSize): TSsize;
external name 'write';
+
+// start function for OSv
+function main: longint; cdecl;
+const
+ MyText: PChar = 'It works!';
+begin
+ CWrite(StdOutputHandle,MyText,strlen(MyText));
+ main:=0;
+end;
+
+exports main name 'main'; // OSv searches for 'main' in the library
+
+end.
diff --git a/fpc-example/module.py b/fpc-example/module.py
--- a/fpc-example/module.py
+++ b/fpc-example/module.py
@@ -0,0 +1,3 @@
+from osv.modules import api
+
+default = api.run("/fpc-hello")
diff --git a/fpc-example/usr.manifest b/fpc-example/usr.manifest
--- a/fpc-example/usr.manifest
+++ b/fpc-example/usr.manifest
@@ -0,0 +1 @@
+/fpc-hello: ${MODULE_DIR}/fpc-hello
--
You received this message because you are subscribed to the Google Groups "OSv
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.