unikraft / static-pie-apps

Built Linux applications (static-pie) for Unikraft binary compatibility mode
7 stars 40 forks source link

Add Node.js static PIE build #85

Closed i-Pear closed 1 year ago

i-Pear commented 1 year ago

Added Node.js static PIE build. A sample server is also provided, which displays "Hello World from unikraft!" on the returned web page.

i-Pear commented 1 year ago

However, even if Node.js is built with -static-pie and -fPIC, it still cannot be launched normally through run-elfloader.

This is similar to unikraft #611: binary-compat: php: Cannot handle multiple user space heaps

Logs

$ ./run_elfloader -n -d ../static-pie-apps/node/node
SeaBIOS (version Arch Linux 1.16.1-1-1)

iPXE (http://ipxe.org) 00:03.0 C000 PCI2.10 PnP PMM+7EFD3240+7EF33240 C000

Booting from ROM..1: Set IPv4 address 172.44.0.2 mask 255.255.255.0 gw 172.44.0.1
en1: Added
en1: Interface is up
Powered by
o.   .o       _ _               __ _
Oo   Oo  ___ (_) | __ __  __ _ ' _) :_
oO   oO ' _ `| | |/ /  _)' _` | |_|  _)
oOo oOO| | | | |   (| | | (_) |  _) :_
 OoOoO ._, ._:_:_,\_._,  .__,_:_, \___)
            Mimas 0.7.0~1e17a9c8-custom
[    0.249366] CRIT: [appelfloader] <brk.c @   27> Cannot handle multiple user space heaps: Not implemented!
[    0.249725] CRIT: [appelfloader] <brk.c @   44> Failed to increase heap: Not implemented!
Fatal glibc error: malloc.c:2593 (sysmalloc): assertion failed: (old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) )
i-Pear commented 1 year ago

A build using musl is also provided. No brk errors this time, but it will hang after qemu starts, the same behavior as lang/go/helloworld.

$ ./run_elfloader ../static-pie-apps/node/node-musl ../static-pie-apps/node/helloworld.js
SeaBIOS (version Arch Linux 1.16.1-1-1)
Booting from ROM..Powered by
o.   .o       _ _               __ _
Oo   Oo  ___ (_) | __ __  __ _ ' _) :_
oO   oO ' _ `| | |/ /  _)' _` | |_|  _)
oOo oOO| | | | |   (| | | (_) |  _) :_
 OoOoO ._, ._:_:_,\_._,  .__,_:_, \___)
            Mimas 0.7.0~1e17a9c8-custom