Re: [rvm-research] Resolving External References

Erik Brangs <[email protected]> Wed, 6 Dec 2017 19:37:11 +0100
Newsgroups gmane.comp.java.jikes.rvm.devel
Message-ID <[email protected]>
Hi,

On 06.12.2017 08:15, Khaled Z Mahmoud wrote:
> I have done a new fresh PoC on a newly cloned git repository.
> Below is my diff.
as Robin has mentioned, you need to add your .c file to the commands used to build the bootloader. The build assumes that syscalls are placed into the existing files. If you need a new file, you have to add it to the build.xml in the appropriate places. I've attached a diff that should show a complete example.

Kind regards,

Erik Brangs

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

_______________________________________________
Jikesrvm-researchers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jikesrvm-researchers
addExampleSysCall.diff (text/x-patch, 3.1 KB)
diff --git a/build.xml b/build.xml
index 37f2daf03..6cfc98f88 100644
--- a/build.xml
+++ b/build.xml
@@ -1956,6 +1956,9 @@ const char *rvm_target_configuration = "${target.file}";
     <CompileCtoObj cfile="${bl.dir}/sysVarArgs.c"
                        objfile="${build.base}/${target.obj-prefix}sysVarArgs${target.obj-ext}"
                        cargs="${rvm.c.args}"/>
+    <CompileCtoObj cfile="${bl.dir}/test.c"
+                   objfile="${build.base}/${target.obj-prefix}test${target.obj-ext}"
+                   cargs="${rvm.c.args}"/>
 
     <CreateLibrary outdir="${build.base}" dllname="jvm" srcdir="${bl.dir}">
       <ObjectFiles>
@@ -1975,6 +1978,7 @@ const char *rvm_target_configuration = "${target.file}";
         <arg value="${build.base}/${target.obj-prefix}sysThread_${target.arch}${target.obj-ext}"/>
         <arg value="${build.base}/${target.obj-prefix}sysTime${target.obj-ext}"/>
         <arg value="${build.base}/${target.obj-prefix}sysVarArgs${target.obj-ext}"/>
+        <arg value="${build.base}/${target.obj-prefix}test${target.obj-ext}"/>
       </ObjectFiles>
     </CreateLibrary>
 
@@ -2029,6 +2033,7 @@ const char *rvm_target_configuration = "${target.file}";
         <arg value="${build.base}/${target.obj-prefix}sysThread_${target.arch}${target.obj-ext}"/>
         <arg value="${build.base}/${target.obj-prefix}sysTime${target.obj-ext}"/>
         <arg value="${build.base}/${target.obj-prefix}sysVarArgs${target.obj-ext}"/>
+        <arg value="${build.base}/${target.obj-prefix}test${target.obj-ext}"/>
       </ObjectFiles>
     </CreateDLL>
 
diff --git a/rvm/src/org/jikesrvm/runtime/BootRecord.java b/rvm/src/org/jikesrvm/runtime/BootRecord.java
index 88996d9e0..0d0ffd8fa 100644
--- a/rvm/src/org/jikesrvm/runtime/BootRecord.java
+++ b/rvm/src/org/jikesrvm/runtime/BootRecord.java
@@ -406,4 +406,6 @@ public class BootRecord {
   public Address sysPerfEventDisableIP;
   public Address sysPerfEventReadIP;
 
+  // test
+  public Address testIP;
 }
diff --git a/rvm/src/org/jikesrvm/runtime/SysCall.java b/rvm/src/org/jikesrvm/runtime/SysCall.java
index d275602a4..a293c22cb 100644
--- a/rvm/src/org/jikesrvm/runtime/SysCall.java
+++ b/rvm/src/org/jikesrvm/runtime/SysCall.java
@@ -481,5 +481,9 @@ public abstract class SysCall {
 
   @SysCallTemplate
   public abstract void sysStackAlignmentTest();
+
+  @SysCallTemplate
+  public abstract int test();
+
 }
 
diff --git a/tools/bootloader/sys.h b/tools/bootloader/sys.h
index 1a99b5769..4d8731580 100644
--- a/tools/bootloader/sys.h
+++ b/tools/bootloader/sys.h
@@ -258,6 +258,8 @@ EXTERNAL void sysPerfEventCreate(int id, const char *eventName);
 EXTERNAL void sysPerfEventEnable();
 EXTERNAL void sysPerfEventDisable();
 EXTERNAL void sysPerfEventRead(int id, long long *values);
+// test
+EXTERNAL int test();
 // sysSignal
 EXTERNAL int inRVMAddressSpace(Address addr);
 EXTERNAL void dumpProcessAddressSpace();
diff --git a/tools/bootloader/test.c b/tools/bootloader/test.c
new file mode 100644
index 000000000..7af83318a
--- /dev/null
+++ b/tools/bootloader/test.c
@@ -0,0 +1,5 @@
+#include "sys.h"
+
+EXTERNAL int test() {
+    return 0;
+}