Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Jumped to invalid address in trampoline" #3

Open
Erhannis opened this issue Feb 3, 2022 · 4 comments
Open

"Jumped to invalid address in trampoline" #3

Erhannis opened this issue Feb 3, 2022 · 4 comments

Comments

@Erhannis
Copy link

Erhannis commented Feb 3, 2022

I've finally gotten nestedvm to compile (I'd add MAKEINFO=true to the make dist ... arguments, in the README), but I have yet to successfully run a translated class. For instance, I have a test cc.c in /tmp/:

#include <stdio.h>

int test(int x) {
    return x*4;
}

int main(int argc, char **argv) {
    printf("hello moon!\n");
    return test(1717);
}

And in upstream/install/bin/ I run

./mips-unknown-elf-gcc -o /tmp/cc /tmp/cc.c

and get

/home/erhannis/Documents/workspace/nestedvm/install/bin/../lib/gcc/mips-unknown-elf/4.8.5/../../../../mips-unknown-elf/bin/ld: warning: cannot find entry symbol _start; defaulting to 0000000000010000

but it seeeems to work. So I run either

java -jar nestedvm.jar /tmp/cc

or

java -jar compiler.jar -outfile /tmp/cc.class cc /tmp/cc
java -cp /tmp/:unix_runtime.jar cc

and in either case I get similar errors

org.ibex.nestedvm.Runtime$ExecutionException: Jumped to invalid address in trampoline (r2: -1 pc: -559038737) at (unknown)
	at cc.trampoline(/tmp/cc)
	at cc._execute(/tmp/cc)
	at org.ibex.nestedvm.Runtime.__execute(Runtime.java:511)
	at org.ibex.nestedvm.Runtime.execute(Runtime.java:528)
	at org.ibex.nestedvm.Runtime.run(Runtime.java:550)
	at org.ibex.nestedvm.Runtime.run(Runtime.java:543)
	at org.ibex.nestedvm.Runtime.run(Runtime.java:542)
	at cc.main(/tmp/cc)
Process exited on signal 4

or

Instansiated: nestedvm.runtimecompiled@156643d4
org.ibex.nestedvm.Runtime$ExecutionException: Jumped to invalid address in trampoline (r2: -1 pc: -559038737) at (unknown)
	at nestedvm.runtimecompiled.trampoline(Unknown Source)
	at nestedvm.runtimecompiled._execute(Unknown Source)
	at org.ibex.nestedvm.Runtime.__execute(Runtime.java:511)
	at org.ibex.nestedvm.Runtime.execute(Runtime.java:528)
	at org.ibex.nestedvm.UnixRuntime.executeAndExec(UnixRuntime.java:501)
	at org.ibex.nestedvm.UnixRuntime.runAndExec(UnixRuntime.java:495)
	at org.ibex.nestedvm.RuntimeCompiler.main(RuntimeCompiler.java:69)
Process exited on signal 4

Any idea what's up?
(I'd also gotten similar results with an effectively-empty main method, but this was the code I'd most recently tested, anyway.)

@Erhannis
Copy link
Author

Erhannis commented Feb 3, 2022

Oh - it should be noted perhaps that I installed openjdk-8-jdk rather than openjdk-7-jdk, because that's what was available. Would that cause this, do you think?

@zacura
Copy link

zacura commented Feb 9, 2022

@Erhannis Initially I got the same errors, but reading the Makefile pointed me into the correct command line for using nestedvm. Here is how I got my Hello World (test.c) compiled to a Java class (output to build/com/test directory):

Compile C source

mips-unknown-elf-gcc -O3 -mmemcpy -ffunction-sections -fdata-sections -falign-functions=512 -fno-rename-registers -fno-schedule-insns -fno-delayed-branch -march=mips1 -specs=/usr/local/nestedvm/mips-unknown-elf/lib/crt0-override.spec -I. -Wall -Wno-unused -c -o build/com/test/Test.o test.c

Link to a MIPS binary

mips-unknown-elf-gcc -o build/com/test/Test.mips build/com/test/Test.o -march=mips1 -specs=/usr/local/nestedvm/mips-unknown-elf/lib/crt0-override.spec --static -Wl,--gc-sections

Compile to a Java class

java -cp "/usr/local/nestedvm/share/java/nestedvm-compiler.jar:build" org.ibex.nestedvm.Compiler -outformat class -d build com.test.Test build/com/test/Test.mips

Running the resulting Java application

java -cp /usr/local/nestedvm/share/java/nestedvm-runtime.jar:build com.test.Test

@Erhannis
Copy link
Author

Erhannis commented Feb 9, 2022

Holy COW. You'd think something like that would be in the README. It works, though! Good find. I'll update the README and make a pull request, in case @bgould ever sees it, I guess, haha.

@Erhannis
Copy link
Author

Erhannis commented Feb 9, 2022

Pull request: #4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants