<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Masashi Yoshimura on Medium]]></title>
        <description><![CDATA[Stories by Masashi Yoshimura on Medium]]></description>
        <link>https://medium.com/@masashi.yoshimura?source=rss-dc386ecee2ae------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Masashi Yoshimura on Medium</title>
            <link>https://medium.com/@masashi.yoshimura?source=rss-dc386ecee2ae------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 03:06:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@masashi.yoshimura/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[elfconv v1.0.0: Real-world Linux applications running fast in your browser]]></title>
            <link>https://medium.com/nttlabs/elfconv-v1-0-0-real-world-linux-applications-running-fast-in-your-browser-80e6572b3a89?source=rss-dc386ecee2ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/80e6572b3a89</guid>
            <dc:creator><![CDATA[Masashi Yoshimura]]></dc:creator>
            <pubDate>Tue, 31 Mar 2026 06:00:41 GMT</pubDate>
            <atom:updated>2026-03-31T06:00:41.633Z</atom:updated>
            <content:encoded><![CDATA[<h3>Background</h3><p>In recent years, browsers have become powerful enough to run many rich applications, such as video, games, 3D rendering, and even LLMs.</p><p>At the same time, access to system resources is heavily restricted for security reasons. Because of this, many native applications cannot run directly in the browser.</p><p>To address this limitation, projects such as <a href="https://github.com/copy/v86">v86</a> and <a href="https://github.com/container2wasm/container2wasm">container2wasm</a> run CPU emulators on top of WebAssembly and boot a guest OS. This makes it possible to run almost any native application in the browser. However, since these approaches rely on CPU emulation, they suffer from significant performance overhead.</p><h3>elfconv v1.0.0 Release</h3><p><a href="https://github.com/yomaytk/elfconv">elfconv</a> converts Linux applications into WebAssembly ahead of time (AOT), allowing them to run much faster than emulator-based solutions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*jdcJKILXlx8NdVkM4we-xg.png" /></figure><p>elfconv enables several use cases:</p><ol><li>Running Linux applications that rely heavily on Linux features (e.g., shells or compilers) directly in the browser</li><li>Moving server-side Linux applications to the client, improving privacy and reducing server load</li><li>Building browser applications using existing Linux libraries distributed via tools like apt</li></ol><p>There are already several projects that port native applications to WebAssembly, such as <a href="https://github.com/pyodide/pyodide">Pyodide</a>, <a href="https://github.com/electric-sql/pglite">PGLite</a>, and <a href="https://github.com/ffmpegwasm/ffmpeg.wasm">ffmpeg.wasm</a>. However, these ports usually require significant manual effort, and keeping up with upstream changes can also be challenging. elfconv has the potential to make this process much easier.</p><p>For more details about performance and optimization techniques, please refer to our previous blog post: <a href="https://medium.com/nttlabs/some-performance-improvements-in-the-binary-translator-that-converts-linux-applications-c6b26945cf39">elfconv: Linux Apps to High-Performance Wasm Binary Translator</a></p><p>After continuous improvements, we are happy to announce the release of <a href="https://github.com/yomaytk/elfconv/releases/tag/v1.0.0"><strong>elfconv v1.0.0</strong></a>! 🚀</p><p>In this post, we introduce the main updates in this version.</p><h3>1. Enhanced demos</h3><p>In this release, we added browser demos that run <strong>GNU Bash</strong> and <strong>Python</strong>. These demos run Linux applications <strong>built from upstream source code without any modifications</strong>.</p><p>This shows that elfconv is moving beyond toy programs and benchmarks, and is becoming capable of running real-world Linux applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l1HpQJ6wXpZ2b43ja9N07Q.png" /></figure><h3>2. Multi-process support in the browser</h3><p>We implemented support for clone and execve system calls. This makes it possible to run multi-process programs in the browser, including GNU Bash as shown in the demos.</p><p>Technically, <strong>each Linux process is mapped to a Web Worker.</strong> A lightweight runtime called <strong>js-kernel</strong> acts like an operating system, handling file systems and process management. Each Web Worker communicates only with js-kernel.</p><p>In addition, Wasm memory for each worker is managed by js-kernel, and resources are isolated across workers. This design provides resource isolation similar to Linux processes.</p><p>Overall, this architecture closely resembles the Linux process model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E9vlbgmmxFUyk9X_AbJpdg.png" /></figure><h3>3. Host file system mounting</h3><p>Many native applications depend on external data and files. To support this, we added a feature to mount the host file system into the browser’s MEMFS. This feature is based on emscripten --preload-file function.</p><p>By setting environment variables MOUNT_SETTINGat build time, specific directories can be mounted and accessed by the application. We can generate the Wasm with mounting the host file system as follows.</p><pre>outdir/$ TARGET=aarch64-wasm INITWASM=1 MOUNT_SETTING=&quot;/host/dir@/mount/point&quot; ./elfconv.sh /path/to/elf</pre><h3>4. <strong>Improved Linux syscall support</strong></h3><p>In elfconv, Linux system calls for browsers are implemented in as a large switch statement.</p><p>Up to v1.0.0, we added and improved many syscalls (e.g., ppoll, ioctl, pipe2). As a result, commands such as ps, vi, and top now work in busybox.</p><h3>5. Build system overhaul</h3><p>The elfconv build system is based on <a href="https://github.com/lifting-bits/remill">remill</a>. Previously, remill only supported limited environments (ubuntu 22.04 + LLVM 16) and depended on <a href="https://github.com/lifting-bits/cxx-common">cxx-common</a>, which had not been maintained for over two years.</p><p>With the introduction of a new <a href="https://github.com/yomaytk/elfconv/tree/main/dependencies">superbuild system</a> by <a href="https://github.com/mrexodia">Duncan Ogilvie</a>, support for many Linux platforms has improved, and the dependency on cxx-common has been reduced.</p><p>We also improved the container-based build environment, significantly reducing build time and image size. As a result, the build process is now much more stable.</p><h3><strong>Future work</strong></h3><p>We are mainly working on <strong>supporting Linux shared objects</strong>. Once implemented, this will allow many pre-built binaries distributed through package managers to be ported directly to WebAssembly.</p><p>We also welcome any issues or pull requests to elfconv.</p><p>we at NTT are looking for people interested in working with us in open source communities, especially in areas such as WebAssembly and systems software. Please visit &lt;<a href="https://www.rd.ntt/e/sic/recruit/">https://www.rd.ntt/e/sic/recruit/</a>&gt; for more information!</p><p>私たちNTTは、WebAssemblyやシステムソフトウェアの分野において、オープンソースコミュニティと共に活動する仲間を募集しています。ぜひ弊社の採用情報ページ (<a href="https://www.rd.ntt/sic/recruit/">https://www.rd.ntt/sic/recruit/</a>) をご覧ください。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80e6572b3a89" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nttlabs/elfconv-v1-0-0-real-world-linux-applications-running-fast-in-your-browser-80e6572b3a89">elfconv v1.0.0: Real-world Linux applications running fast in your browser</a> was originally published in <a href="https://medium.com/nttlabs">nttlabs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[elfconv: Linux Apps to High-Performance Wasm Binary Translator]]></title>
            <link>https://medium.com/nttlabs/some-performance-improvements-in-the-binary-translator-that-converts-linux-applications-c6b26945cf39?source=rss-dc386ecee2ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/c6b26945cf39</guid>
            <category><![CDATA[compiler-optimization]]></category>
            <category><![CDATA[binary-translation]]></category>
            <category><![CDATA[webassembly]]></category>
            <dc:creator><![CDATA[Masashi Yoshimura]]></dc:creator>
            <pubDate>Mon, 14 Apr 2025 07:58:44 GMT</pubDate>
            <atom:updated>2025-04-17T10:41:14.967Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://github.com/yomaytk/elfconv"><strong><em>elfconv</em></strong></a> is a binary translator that converts Linux applications into executable binaries for different platforms. In the current implementation, elfconv primarily supports conversion from ELF/AArch64 to WebAssembly (Wasm) and ELF/x86–64, with a particular focus on conversion to Wasm. In this article, <strong>I will introduce the recent significant performance improvements for elfconv</strong>.</p><h4>Why convert Linux applications?</h4><p>Currently, Linux is widely used as a major OS in laptops, servers, embedded systems, and many other environments, and a lot of Linux applications have been developed. Consequently, a lot of Linux application binary assets exists, and reusing them can lead to reductions in development costs, among other things. However, with the increasing diversity of computing platforms nowadays, porting Linux applications is very challenging. In particular, <strong>performance degradation poses a major problem during porting</strong>; for example, emulators such as <a href="https://www.qemu.org/">QEMU</a> can experience performance slowdowns of several tens of times compared to the original binaries. Moreover, while <a href="https://en.wikipedia.org/wiki/Rosetta_(software)">Apple’s Rosetta 2</a> can convert binaries into executable versions that perform very close to the original, it does not support the conversion of Linux applications.</p><h4>How does elfconv work?</h4><p>The architecture of elfconv is as shown in Fig. 1. It converts ELF binaries into equivalent LLVM bitcode and then compiles and links that bitcode file together with a runtime program using an existing compiler to produce an executable binary for the target architecture. The conversion to LLVM bitcode is performed using a library called <a href="https://github.com/lifting-bits/remill"><strong><em>Remill</em></strong></a>. The runtime program primarily handles the initialization of CPU registers and memory areas, memory management, and the implementation of Linux system calls.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y3Dd1YxVdFjkrTgM67k5ow.png" /><figcaption><strong>Fig 1. Overview of elfconv</strong></figcaption></figure><p>In our recent work, we have implemented two performance improvements.</p><h4>Benchmark test for elfconv</h4><p>First, I present the current performance evaluation for several test programs. For comparison, we use Wasm applications generated directly from source code by <a href="https://github.com/emscripten-core/emscripten">Emscripten</a> or <a href="https://github.com/WebAssembly/wasi-sdk">WASI-SDK</a>, with their performance set as 100%. elfconv converts ELF/AArch64 binaries generated by gcc or clang from the same source code into Wasm applications. The three programs used are as follows:</p><ul><li><strong>Prime Nums:</strong> Calculates all prime numbers below 30,000,000 and measures the execution time.</li><li><a href="https://github.com/AndrewCarterUK/mnist-neural-network-plain-c"><strong>mnist-NN</strong></a><strong>:</strong> A neural network that trains on the MNIST handwritten digit dataset, with the execution time taken for 30 training steps being measured.</li><li><a href="https://netlib.org/benchmark/hpl/"><strong>LINPACK</strong></a><strong>:</strong> A benchmark test that utilizes floating-point arithmetic (array size is fixed to 100).</li></ul><p>Benchmark tests were performed on Wasm for both browsers and WASI. The results are shown in Fig. 2 and Fig. 3 (Environment: Linux 6.8.0–57-generic Ubuntu22.04 aarch64).</p><p><strong>Wasm for Browser (using Emscripten)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JhGzkma_-PQBs-zoQs2n7Q.png" /><figcaption><strong>Fig 2. elfconv Benchmark Test (Wasm for Browser)</strong></figcaption></figure><p><strong>Wasm for WASI (using WasmEdge)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uOBqhM74N__h7B99v-YUdg.png" /><figcaption><strong>Fig 3. elfconv Benchmark Test (Wasm for WASI)</strong></figcaption></figure><p>As shown in these tables, both Wasm for Browser and Wasm for WASI are able to run with acceptable performance degradation! Moreover, compared to before the performance improvements, there has been a significant enhancement in performance. In the following sections, I will explain the implemented performance improvements.</p><h4>How can we significantly improve performance?</h4><p>We implemented two main performance improvement methods. The first is <strong>speeding up memory accesses</strong> in the runtime program. The second is <strong>optimizing CPU register calculations in LLVM IR</strong> — an optimization pass that transforms the LLVM IR generated by Remill into a higher-performance version.</p><h4>1. Speeding up memory accesses</h4><p>Each machine code contained in an ELF binary accesses various memory areas, such as the ELF sections, the stack, and the heap. Additionally, virtual addresses are assigned to the byte sequences of each section in an ELF binary (for example, the following AArch64 instruction accesses the virtual address 0x490000 + 3056)</p><pre>adrp x22, 490000 &lt;tunable_list+0x528&gt;<br>ldr x0, [x22, #3056]</pre><p>Therefore, these virtual addresses need to be converted to actual memory addresses. In the previous implementation, memory areas were allocated for each data section, stack, and heap, and they were mapped to the corresponding virtual address space (see Fig. 4).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P6lMpcmi7AYcOKDxcBnFlw.png" /><figcaption>Fig 4. Previous Memory Allocation</figcaption></figure><p>Therefore, during memory access, it was necessary to calculate which memory region the target virtual address belonged to. Moreover, since this address translation was performed by a function containing several control constructs, a function call was incurred each time memory was accessed, resulting in a performance bottleneck. To address this, we allocated all of these individual memory regions into <strong>one large memory area (by default, 512MiB in size)</strong>, thereby reducing the address translation to a simple offset calculation and eliminating the corresponding function calls (see Fig. 5).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0VMzVrroFyhTQtKRJmiEuA.png" /><figcaption>Fig 5. Current Memory Allocation</figcaption></figure><p>This is a <a href="https://github.com/yomaytk/elfconv/pull/95">simple improvement</a>, but it improves performance <strong>by 6.4 ~ 9.07 times</strong> in LINPACK benchmark tests. Although this approach might result in errors for programs that executes mmap system call with MAP_FIXED, it can be considered a viable implementation for many applications. In addition, in the future, by supporting <a href="https://github.com/WebAssembly/memory64">Wasm’s memory64</a>, methods that directly utilize the original virtual addresses might also become feasible.</p><h4><strong>2. Optimizing CPU register calculations in LLVM IR</strong></h4><p>As mentioned earlier, elfconv uses a library called Remill to convert ELF binaries into LLVM bitcode. <a href="https://github.com/lifting-bits/remill">Remill</a> converts each machine codes into an LLVM IR code block that performs an equivalent operation, and it supports several CPU architectures (primarily AArch64, as well as AArch32, x86–64, SPARC32/64). Before explaining our performance improvement methods, let’s describe how Remill transforms machine codes into LLVM IR.</p><p>For example, consider the following two AArch64 instructions. First, Remill converts each machine instruction into one LLVM IR basic block (LLVM IR basic block; sequence of LLVM IR instructions with no branches in except to the entry and no branches out except at the exit, and an LLVM IR program can be represented as a control flow graph where the basic blocks form the nodes and the branch relationships form the edges).</p><pre>add x29, sp, #0x30<br>stp x21, x22, [sp, #80]</pre><p>For these two AArch64 instructions, Remill converts them into code as shown below. The add instruction is transformed into a basic block labeled 17 and the stp instruction is transformed into a basic block labeled 20 .</p><pre>17:                                               ; preds = %L_indirectbr, %12<br>  %18 = load i64, ptr %SP, align 8<br>  %19 = call i64 @_ZN12_GLOBAL__N_13ADDImmEEDaT_T0_(i64 %18, i64 48)<br>  store i64 %19, ptr %X29, align 8<br>  br label %20<br><br>20:                                               ; preds = %L_indirectbr, %17<br>  %21 = load i64, ptr %X21, align 8<br>  %22 = load i64, ptr %X22, align 8<br>  %23 = load i64, ptr %SP, align 8<br>  %24 = add i64 %23, 80<br>  call void @_ZN12_GLOBAL__N_111StorePair64EP14RuntimeManagermm3MVIIDv1_oE(ptr %runtime_manager, i64 %21, i64 %22, i64 %24)<br>  br label %25<br><br>25:<br>...</pre><p>In the add instruction, variables such as SP and X29 are used, while in the stp instruction, variables X21 , X22 and SP are used. As you might suspect, these represent CPU registers. Because almost every machine code uses some CPU registers for its operations, a data structure to represent them is necessary. Remill defines a structure representing various CPU registers, and in LLVM IR, these are used in computations (for example, struct GPR represents AArch64’s general-purpose registers x0 through x30 , and struct NZCV represents the NZCV flag registers).</p><pre>struct alignas(8) GPR final {<br>// General Purpose Register (X0~X30) of aarch64<br> volatile uint64_t _0;<br> Reg x0;<br> volatile uint64_t _1;<br> Reg x1;<br> volatile uint64_t _2;<br> Reg x2;<br> volatile uint64_t _3;<br> Reg x3;<br> volatile uint64_t _4;<br> Reg x4;<br>...<br><br>union NZCV {<br>  uint64_t flat;<br>  struct {<br>    uint64_t _0 : 28;<br>    uint64_t v : 1;  // Result overflowed, bit 28.<br>    uint64_t c : 1;  // Result produced a carry.<br>    uint64_t z : 1;  // Result is zero.<br>    uint64_t n : 1;  // Result is negative, bit 31.<br>    uint64_t _1 : 32;<br>  } __attribute__((packed));<br>} __attribute__((packed));</pre><p>Additionally, in the add instruction, a function named @ZN12_GLOBAL__N_13ADDImmEEDaT_T0 is called, and in the stp instruction, a function named @_ZN12_GLOBAL__N_111StorePair64EP14RuntimeManagermm3MVIIDv1_oE is called. These functions are <em>semantic functions</em> that represent the actual behavior of each machine code (for instance, in the case of add , the function performs the operation of adding two arguments and returning the result). Remill defines such a function for each machine code. After the semantic function is executed, control jumps to the basic block corresponding to the next machine code to execute. This summarizes the transformation performed by Remill.</p><p>Next, I will explain the method of performance improvements (only the concept). As mentioned earlier, Remill represents the original CPU registers as a structure, which means that<strong> all register operations are replaced with operations on memory</strong>. Therefore, in elfconv, to perform CPU register operations as directly on the registers as possible, we have implemented a method that <strong>propagates the global data representing the CPU registers as virtual registers within LLVM IR functions</strong> (virtual registers; variables in LLVM IR that begin with %, which are more likely to be assigned to physical registers by LLVM’s register allocator). Additionally, although LLVM provides a similar optimization pass called <em>mem2reg</em>, it only applies to local variables within functions and cannot be applied to global data such as the CPU registers structure.</p><p>Because Remill converts each machine codes into independent basic blocks, every time it accesses the same CPU register, it executes store and load LLVM IR instructions, which results in memory accesses (as shown by X4, X5 and X6 in the Fig 6; the semantic function calls and branch instructions are omitted).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T-00Z0qKehLq-0OaWguF5g.png" /><figcaption>Fig 6: Conversion to CFG by Remill (semantic fucntion calling and the branch are omitted)</figcaption></figure><p>Thus, in our implemented performance improvements — as illustrated in Fig. 7 — we utilize phi instructions, which propagate virtual registers between basic blocks, to transform the instruction sequence in such a way that store and load operations are minimized, thereby reducing the number of memory accesses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l83s5VTbNBu15ARKqSOxQw.png" /><figcaption>Fig 7: CFG Transformation with Reduced Memory Accesses</figcaption></figure><p>Before the improvement, the code executed four load instructions and three store instructions; after the inprovement, only one load instruction is executed, significantly reducing memory accesses. Although this example is simple, in practice, we need to support complex control flow graphs containing numerous branches and loops. With <a href="https://github.com/yomaytk/elfconv/pull/53">the implementation</a> of this improvement, it improves performance <strong>by 1.7 times</strong> in LINPACK benchmark tests.</p><p>With these improvements, performance has increased significantly, and some benchmark tests have demonstrated performance that is sufficiently practical. However, testing is still not comprehensive, and further benchmark measurements across various use cases will be necessary. Additionally, the current implementation still lacks many features — for example, support for shared objects, conversion for ELF/x86–64 (many instructions remain unsupported even in AArch64), and conversion to Mach-O binaries. We plan to focus on implementing these features from now on. Moreover, <strong>any issues or pull requests are welcome, so please don’t hesitate to send them in!: &lt;</strong><a href="https://github.com/yomaytk/elfconv">https://github.com/yomaytk/elfconv</a><strong>&gt;</strong></p><p>We at <a href="https://www.rd.ntt/e/">NTT</a> are looking for colleagues to engage in research and development of open-source software related to system software, containers, and WebAssembly. Please visit &lt;<a href="https://www.rd.ntt/e/sic/recruit/">https://www.rd.ntt/e/sic/recruit/</a>&gt; to see how to join us.</p><p>私たちNTTは，システムソフトウェアやコンテナ，WebAssemblyに関するOSSの研究開発をする仲間を募集しています．ぜひ採用情報ページをご覧ください: &lt;<a href="https://www.rd.ntt/sic/recruit/">https://www.rd.ntt/sic/recruit/</a>&gt;</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c6b26945cf39" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nttlabs/some-performance-improvements-in-the-binary-translator-that-converts-linux-applications-c6b26945cf39">elfconv: Linux Apps to High-Performance Wasm Binary Translator</a> was originally published in <a href="https://medium.com/nttlabs">nttlabs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[elfconv: an experimental AOT compiler that translates Linux/AArch64 ELF binary to WebAssembly.]]></title>
            <link>https://medium.com/nttlabs/elfconv-an-experimental-aot-compiler-that-translates-linux-aarch64-elf-binary-to-webassembly-0d47b1b2d50b?source=rss-dc386ecee2ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/0d47b1b2d50b</guid>
            <category><![CDATA[webassembly]]></category>
            <category><![CDATA[binary-translation]]></category>
            <category><![CDATA[llvm]]></category>
            <dc:creator><![CDATA[Masashi Yoshimura]]></dc:creator>
            <pubDate>Wed, 10 Jan 2024 08:10:59 GMT</pubDate>
            <atom:updated>2024-01-10T08:10:59.562Z</atom:updated>
            <content:encoded><![CDATA[<h3>Language supports of WebAssembly</h3><p>WebAssembly (WASM) is a binary format having a virtual instruction set and has been created to make up for the performance overhead of Javascript on browsers, WASM has been expected for the usage of sandbox environments and portable distribution of applications. Now, many programming languages support WASM (e.g. C, C++, Rust, Go), and therefore we can easily make WASM applications.</p><p>However, it is difficult for us to make WASM applications in the following case.</p><ol><li>The programming language doesn’t support WASM.</li><li>The source code is not available (e.g. the source code is not public under license).</li><li>It takes time and effort to build the source code for reasons such as the versions of the libraries to build are old.</li></ol><h3>What is elfconv?</h3><p>Considering such facts, we have implemented “<strong>elfconv</strong>”, an experimental AOT compiler that translates Linux/AArch64 ELF binary to WebAssembly. Using this tool, we can easily make a WASM application from only the Linux/AArch64 ELF binary.</p><p><a href="https://github.com/yomaytk/elfconv">https://github.com/yomaytk/elfconv</a></p><p>(Note: “<strong>elfconv is a work in progress</strong>”, so the capabilities are limited. You may fail to compile your ELF binary or execute the WASM application even if it could compile.)</p><h3>How it works?</h3><p>In this project, we convert the Linux ELF binary (currently supports only AArch64) to the LLVM bitcode targeting WASM, and we compile the LLVM bitcode to WASM binary using the existing compiler such as emscripten. In converting to LLVM bitcode, elfconv uses <a href="https://github.com/lifting-bits/remill"><em>remill</em></a>, the library for lifting CPU instruction to LLVM IR instruction. <em>remill</em> supports multiple CPU architectures, AArch64, SPARC32, SPARC64, x86, and amd64 (Please see the <a href="https://github.com/lifting-bits/remill/blob/master/README.md">README.md</a> for more details). Furthermore, the Linux ELF binary possibly has any Linux system calls, so we statically linked the file that emulates Linux system calls now. Fig.1 shows the whole architecture of elfconv.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*vb19evKUAg3n5n3BN_7wDQ.jpeg" /><figcaption>Fig.1 Architecture of elfconv project</figcaption></figure><p>We prepared a simple demonstration that shows how elfconv compiles the Linux/AArch64 ELF binary to WASM and emscripten executes it. The ELF binary used in the demo is a <a href="https://github.com/yomaytk/elfconv/tree/main/examples/eratosthenes_sieve">simple program</a> that calculates 100 prime numbers in ascending order and doesn’t use libc because elfconv takes more than 1–2 minutes to compile it. In this demo, we use elfconv/dev.sh to generate the WASM binary.</p><p><a href="https://github.com/yomaytk/elfconv/tree/main/demo">Demo</a></p><p>You can easily try elfconv using the docker container (Please see <a href="https://github.com/yomaytk/elfconv/blob/main/README.md">README.md</a> for more details).</p><h3>Current limitations and future works</h3><p>elfconv is a work in progress, and the features are limited as follows.</p><ol><li>supports only not stripped ELF binary (Now, elfconv uses a symbol table to specify every function).</li><li>many Linux system calls are not implemented.</li><li>supports partially converting CPU instructions.</li></ol><p>Furthermore, when targeting WASM, there are some challenges following.</p><ol><li>supports dynamic linking</li><li>some Linux system calls that are difficult to implement (e.g. fork, exec).</li><li>takes a lot of time to compile a large ELF binary.</li></ol><p>We continue to develop elfconv and will deal with the above issues while discussing with the WASM community.</p><h3>NTT is hiring!</h3><p>We at <a href="https://www.rd.ntt/e/">NTT</a> are looking for engineers who work in Open Source communities like WebAssembly, containers, and so on. Please visit <a href="https://www.rd.ntt/e/sic/recruit/">https://www.rd.ntt/e/sic/recruit/</a> to see how to join us.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0d47b1b2d50b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/nttlabs/elfconv-an-experimental-aot-compiler-that-translates-linux-aarch64-elf-binary-to-webassembly-0d47b1b2d50b">elfconv: an experimental AOT compiler that translates Linux/AArch64 ELF binary to WebAssembly.</a> was originally published in <a href="https://medium.com/nttlabs">nttlabs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>