Translating pexe to nexe on the ARM machine

286 views
Skip to first unread message

Adam Lessnau

unread,
Feb 8, 2012, 12:02:43 PM2/8/12
to Native-Client-Discuss
Hi,

I am curious what is the current status of PNaCl in matter of
translating on the ARM machine? Especially:

1) Is it possible to convert a pexe file into the nexe file directly
on the ARM machine (without cross-compiling)?
a) using some variation of the pnacl-translate command
b) using some method from some library?
2) Does PNaCl for ARM support JIT?
a) without sand-boxing
b) with sand-boxing

If any of above option is not supported, is there any plan to
implement it? Any schedule?

Best regards,
Adam

David Sehr

unread,
Feb 8, 2012, 1:22:19 PM2/8/12
to native-cli...@googlegroups.com
Adam,

Thanks for your interest.  We're working on the things you describe, and I can give a brief update.
1) We have ARM nexes that do translation from pexe to nexe.  (There are two -- one for bitcode to object, one for object to nexe)
    As pnacl-translate is a python script, it should certainly be possible to use these nexes to do on-ARM translation.
2) As of today we haven't ported any JITs to ARM, but ARM native client does support dynamic code insertion/modification, just as x86 does, so JITs should be supported.

We're busily trying to get a pre-alpha SDK ready, and the initial hookup for in-browser translation (for x86 only so far) is also nearing test readiness.
ARM in-browser translation hasn't yet been tested, but will be soon.

We would be very interested to hear what applications and which ARM platforms you are hoping to target with pnacl.

Cheers,

David

--
You received this message because you are subscribed to the Google Groups "Native-Client-Discuss" group.
To post to this group, send email to native-cli...@googlegroups.com.
To unsubscribe from this group, send email to native-client-di...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/native-client-discuss?hl=en.


Havard Sande

unread,
Feb 9, 2012, 3:48:38 AM2/9/12
to Native-Client-Discuss
David Sehr wrote:
> 2) As of today we haven't ported any JITs to ARM, but ARM native client
> does support dynamic code insertion/modification, just as x86 does, so JITs
> should be supported.

Last time I checked code modification was not supported on ARM - hence
my feature request/patch at:
http://code.google.com/p/nativeclient/issues/detail?id=2499

Håvard

Adam Lessnau

unread,
Feb 10, 2012, 6:47:48 AM2/10/12
to Native-Client-Discuss
Hi,

> 1) We have ARM nexes that do translation from pexe to nexe...
Great. Could you share detailed instruction how to do it (name of
commands, how to get them, how to execute, etc...)?

> As pnacl-translate is a python script, it should certainly be possible to use these nexes to do on-ARM translation
I don't think I will be able to use a python on the target platform,
therefore I am interested in a pure nexe command or even the library
functions (so it will be possible to make translation inside a other
program without executing a shell/exec/fork commands).

> 2) As of today we haven't ported any JITs to ARM, but ARM native client...
I see. Might I ask whether you have any plans to add a full support
for JIT compliant with sandboxing on ARM? If so, what will be a
schedule?

> We would be very interested to hear what applications and which ARM platforms you are hoping to target with pnacl.
I am afraid, at this very moment I am not allowed to share any
detailed information about the target platform and the project which I
am working on. I hope the below information will be sufficient:
- processor will be ARMv7
- very likely we will use a toolchain in the glibc version
- application will be translate from pexe to nexe on the above ARM
platform
- application will be started inside a sandbox

Cheers,
Adam

David Sehr

unread,
Feb 10, 2012, 9:26:23 AM2/10/12
to native-cli...@googlegroups.com
Havard,

You are correct.  I misspoke with regard to ARM code modification.  Sorry for the confusion.

David

Victor Khimenko

unread,
Feb 10, 2012, 11:09:33 AM2/10/12
to native-cli...@googlegroups.com
On Fri, Feb 10, 2012 at 3:47 PM, Adam Lessnau <ales...@gmail.com> wrote:
Hi,

> We would be very interested to hear what applications and which ARM platforms you are hoping to target with pnacl.
I am afraid, at this very moment I am not allowed to share any
detailed information about the target platform and the project which I
am working on. I hope the below information will be sufficient:
- processor will be ARMv7
- very likely we will use a toolchain in the glibc version

GLibC is not yet ported to nacl-arm. And we don't even know when (and if) this effort will be started.
 
- application will be translate from pexe to nexe on the above ARM
platform
- application will be started inside a sandbox

Cheers,
   Adam

Derek Schuff

unread,
Aug 27, 2012, 1:44:00 PM8/27/12
to native-cli...@googlegroups.com
It sounds like you just want to create ARM nexes, and you don't need
to actually do that translation on an ARM board. The PNaCl SDK does
not have a stable release yet but you can download pre-release SDK
package from the builders directly at
http://build.chromium.org/p/client.nacl.sdk/console (The Pnacl
packages are the right 3 columns of the column group labeled 'multi'.
Find a green build for the linux/mac/win platform you want, click on
the box, find the 'Archive build' step at the top, and click the
download link). Presumably you already have that if you are creating
pexes in the first place. The pnacl-translate script in the package is
used to translate pexe to nexe
So you could do something like the following:

$ /path/to/sdk/bin/pnacl-translate -arch arm program.pexe -o program.arm.nexe

If you really do want to do translation on the arm board, that's
possible too. The sandboxed translator binaries have been split into
their own package to allow this usage (that's how we run our tests
with sandboxed translation outside the browser on arm boards). You can
build or download the pnacl translator package; however it is meant
mostly for testing and it is not designed to be used outside the
native client source tree (in particular, it does not contain
sel_ldr). Let me know if you want more details on that, and/or give us
some more detail on what you are actually trying to do.
-Derek



On Mon, Aug 27, 2012 at 10:19 AM, NaClLearner
<shreyas....@gmail.com> wrote:
> Hi David,
>
> I am also facing similar kind of issue. Can you please enlighten me on how
> to llc.nexe and ld.nexe (for ARM arch) on client machine to convert pexe to
> nexe. It would be great help if you provide command line arguements. My
> target is a ARM board and i want to do the conversion outside browser.
>
> Thanks in advance.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/native-client-discuss/-/2N3MEy9Tj3YJ.

NaClLearner

unread,
Aug 27, 2012, 1:54:28 PM8/27/12
to native-cli...@googlegroups.com
Thanks Derek, 
I am able to do translation using pnacl-translate utility but i want to know more if it is possible to do it at run time directly on client machine. I have arm-v7 board as target and host machine as Ubuntu 10.04. I want to actually translate pexe to nexe directly on arm board. I recently read about NaCl and found it very interesting. It would be very helpful if you 
could please explain " If you really do want to do translation on the arm board, that's 

possible too. The sandboxed translator binaries have been split into 
their own package to allow this usage (that's how we run our tests 
with sandboxed translation outside the browser on arm boards). You can 
build or download the pnacl translator package
 "

Derek Schuff

unread,
Aug 27, 2012, 2:24:24 PM8/27/12
to native-cli...@googlegroups.com
So the way to do this currently is the following:
1. check out the nacl repo on the arm board (see e.g.
http://www.chromium.org/nativeclient/how-tos/how-to-use-git-svn-with-native-client)
2. The gclient sync you used to get the nacl repo should also have
fetched you the sandboxed translator package. check out
/path/to/nacl/native_client/toolchain/pnacl_translator
3. Now you need to get sel_ldr and nacl_helper_bootstrap to run the
llc and ld nexes. The way to do this is to build them on an x86 linux
machine. From a checked-out nacl repo, do:
./scons platform=arm sel_ldr nacl_helper_bootstrap
Then copy the sel_ldr and nacl_helper_bootstrap binaries from the
scons-out/opt-linux-arm/staging/ directory into the corresponding
directory on the arm board.

That's it! simple, no?
no... obviously it's not something we usually do manually. All this
has been tested on armv7 pandaboards running Ubuntu 11.10 and 12.04.
No guarantees outside of that. In principle you could build sel_ldr
and nacl_helper_bootstrap on the arm board as well using the local
system compiler, but scons is currently not set up for that AFAIK
> --
> You received this message because you are subscribed to the Google Groups
> "Native-Client-Discuss" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/native-client-discuss/-/0jvuXColMHsJ.

NaClLearner

unread,
Aug 27, 2012, 2:37:31 PM8/27/12
to native-cli...@googlegroups.com
Hi Derek,

I already built sel_ldr and nacl_helper_bootstrap using  ./scons platform=arm sel_ldr nacl_helper_bootstrap.
I thought of first using qemu environment, so i used run.py
run.py llc.nexe helloWorld.pexe
helloWorld.pexe is the one i want to convert to nexe at run time. Following are my doubts:
1) Can we use qemu environment?
2) i could see irt.nexe getting loaded, is that required here?
3) run.py llc.nexe helloWorld.pexe failed with no segment gap error. What should be the expected output?

If i am doing it the wrong way can you please guide me through the actual command that needs to be issued?

On Wednesday, February 8, 2012 10:32:43 PM UTC+5:30, Adam Lessnau wrote:

Derek Schuff

unread,
Aug 27, 2012, 2:51:45 PM8/27/12
to native-cli...@googlegroups.com
Sorry, I forgot to give you the command line for running the
translator. You can't run llc.nexe directly, you still use the pnacl
translator script around it. On a real arm board you would do:
$ toolchain/pnacl_translator/bin/pnacl-translate --pnacl-sb -arch arm
helloworld.pexe -o helloworld.arm.nexe
(the --pnacl-sb flag indicates that the sandboxed translator should be
used, and is required when running on arm hardware).

1) You can use qemu. In fact the translator driver script has builtin
support for using the version that comes with the nacl source. so on
an x86 machine you would use the same command line:
$ toolchain/pnacl_translator/bin/pnacl-translate --pnacl-sb -arch arm
helloworld.pexe -o helloworld.arm.nexe
(note that in addition to sel_ldr and nacl_helper_bootstrap you also
need to build sel_universal to use this)

2) No IRT is required (or supported, see #3) for the llc.nexe and
ld.nexe. run.py will try to use it by default (you can specify
--irt=none to avoid this) but as mentioned you don't use run.py on
llc.nexe anyway.

3) Normal nexes are linked with a gap in between the text and rodata
segments, where the IRT is loaded. that's the error you get when you
try to use an IRT with a nexe which is not built with that segment
gap.
> --
> You received this message because you are subscribed to the Google Groups
> "Native-Client-Discuss" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/native-client-discuss/-/6OQvw3nm-EQJ.

NaClLearner

unread,
Aug 27, 2012, 3:10:01 PM8/27/12
to native-cli...@googlegroups.com
Thanks Derek, but the issue is pnacl-translate tool will require python on ARM board. Is it possible to perform translation without using pnacl-translate as i dont want to install python on target board. Also, I have built sel_ldr and nacl_helper_bootstrap on host machine and copied on target. 


On Wednesday, February 8, 2012 10:32:43 PM UTC+5:30, Adam Lessnau wrote:

Derek Schuff

unread,
Aug 27, 2012, 5:51:16 PM8/27/12
to native-cli...@googlegroups.com
It's possible but not easy. the sandboxed translator is designed for
integration into chrome rather than standalone use. The sel_universal
binary emulates the part that communicates with the llc and ld nexes
to drive the translation, and it is driven by a script which is
generated by the pnacl-translate driver, using the pnacl-translate
flags and some baked-in flags.
To really do translation on the arm board without python, you could do
the following:
run the sandboxed translator under the emulator on x86:
$ toolchain/pnacl_translator/bin/pnacl-translate --pnacl-sb
--pnacl-use-emulator --pnacl-driver-verbose -arch arm
helloworld.pexe -o helloworld.arm.nexe
Using --pnacl-driver-verbose will print the command line to run
sel_universal and also the stdin that is fed to sel_universal. Using
both of those for llc and ld, you could run the corresponding commands
on the arm board (minus run_under_qemu_arm of course).
> --
> You received this message because you are subscribed to the Google Groups
> "Native-Client-Discuss" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/native-client-discuss/-/qVo8fFZfBGEJ.

shreyas naphaday

unread,
Aug 28, 2012, 1:46:29 AM8/28/12
to native-cli...@googlegroups.com
Thanks Derek, that worked like a charm. :-)
Reply all
Reply to author
Forward
0 new messages