-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from yomaytk/release
Add the release directory.
- Loading branch information
Showing
4 changed files
with
123 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# How to use release packages | ||
This shows how to use the release packages (e.g. elfconv-v0.1.0-linux-arm64.tar.gz). | ||
## Quick Start | ||
You can translate the ELF binary to the WASM binary by the following command. `TARGET` should be `wasm-host` for WASI runtimes or `wasm-browser` for browser. | ||
```bash | ||
$ cd <unzipped directory> | ||
$ TARGET=wasm-host ./elfconv.sh /path/to/ELF ./bitcode | ||
``` | ||
## Contents | ||
The unzipped directory includes 3 shell scripts (`prepare.sh`, `elfconv.sh`, `clean.sh`) and 3 directories (`bin`, `bitcode`, `lib`). | ||
|
||
`elfconv.sh`: for translating the ELF binary to WASM binary. | ||
|
||
`prepare.sh`: for prepareing the files and directorie to make the release packages. | ||
|
||
`clean.sh`: for removing the generated resources by the `prepare.sh` | ||
|
||
`bin/`: includes `elflift` that is statically linked executable file to translate the ELF binary to the LLVM bitcode. | ||
|
||
`bitcode/`: includes several LLVM bitcode files that provides the all virtual instruction sets for the translated LLVM IR sets of the original ELF binary. | ||
|
||
`lib/`: includes the two archives of *elfconv-runtime*. `libelfconvbrowser.a` is for browser and `libelfconvwasi.a` is for WASI runtimes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
rm -rf bin bitcode lib *.o *.bc *.wasm *.html *.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#!/usr/bin/env bash | ||
|
||
setting() { | ||
|
||
RELEASE_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | ||
ELFCONV_DIR=${RELEASE_DIR}/../ | ||
ELFCONV_ARCH_DIR=${ELFCONV_DIR}/backend/remill/lib/Arch | ||
RUNTIME_DIR=${ELFCONV_DIR}/runtime | ||
UTILS_DIR=${ELFCONV_DIR}/utils | ||
BUILD_DIR=${ELFCONV_DIR}/build | ||
|
||
# shared compiler options | ||
OPTFLAGS="-O3" | ||
|
||
# emscripten | ||
EMCXX=emcc | ||
EMAR=emar | ||
EMCCFLAGS="${OPTFLAGS} -I${ELFCONV_DIR}/backend/remill/include -I${ELFCONV_DIR}" | ||
EMCC_ELFCONV_MACROS="-DELFCONV_BROWSER_ENV=1" | ||
|
||
# wasi-sdk | ||
WASISDKCXX=${WASI_SDK_PATH}/bin/clang++ | ||
WASISDKAR=${WASI_SDK_PATH}/bin/ar | ||
WASISDKFLAGS="${OPTFLAGS} --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot -I${ELFCONV_DIR}/backend/remill/include -I${ELFCONV_DIR} -fno-exceptions" | ||
WASI_ELFCONV_MACROS="-DELFC_WASI_ENV=1" | ||
|
||
} | ||
|
||
main() { | ||
|
||
setting | ||
|
||
# clear cache | ||
rm -rf bin bitcode lib | ||
|
||
# set elflift | ||
mkdir -p bin | ||
cd "${BUILD_DIR}" && ninja | ||
if file "./lifter/elflift" | grep -q "dynamically linked"; then | ||
echo -e "[\033[33mWARNING\033[0m] elflift is dynamically linked file." | ||
fi | ||
cd "${RELEASE_DIR}" | ||
if cp ${BUILD_DIR}/lifter/elflift bin; then | ||
echo -e "[\033[32mINFO\033[0m] Set elflift." | ||
else | ||
echo -e "[\033[31mERROR\033[0m] Faild to set elflift." | ||
exit 1 | ||
fi | ||
|
||
# set semantics *.bc file | ||
mkdir -p bitcode | ||
if cp -r ${ELFCONV_ARCH_DIR}/AArch64/Runtime/ bitcode; then | ||
echo -e "[\033[32mINFO\033[0m] Set semantics *.bc." | ||
else | ||
echo -e "[\033[31mERROR\033[0m] Failed to set semantics *.bc." | ||
exit 1 | ||
fi | ||
|
||
# set elfconv-runtime archive (libelfconvbrowser.a) | ||
mkdir -p lib | ||
cd "${RUNTIME_DIR}" || { echo "cd Failure"; exit 1; } | ||
# shellcheck disable=SC2086 | ||
$EMCXX $EMCCFLAGS $EMCC_ELFCONV_MACROS -o Entry.o -c Entry.cpp && \ | ||
$EMCXX $EMCCFLAGS $EMCC_ELFCONV_MACROS -o Memory.o -c Memory.cpp && \ | ||
$EMCXX $EMCCFLAGS $EMCC_ELFCONV_MACROS -o Syscall.o -c Syscall.cpp && \ | ||
$EMCXX $EMCCFLAGS $EMCC_ELFCONV_MACROS -o VmIntrinsics.o -c VmIntrinsics.cpp && \ | ||
$EMCXX $EMCCFLAGS $EMCC_ELFCONV_MACROS -o Util.o -c "${UTILS_DIR}"/Util.cpp && \ | ||
$EMCXX $EMCCFLAGS $EMCC_ELFCONV_MACROS -o elfconv.o -c "${UTILS_DIR}"/elfconv.cpp && \ | ||
$EMAR rcs libelfconvbrowser.a Entry.o Memory.o Syscall.o VmIntrinsics.o Util.o elfconv.o | ||
if mv libelfconvbrowser.a ${RELEASE_DIR}/lib; then | ||
echo -e "[\033[32mINFO\033[0m] Set libelfconvbrowser.a." | ||
else | ||
echo -e "[\033[31mERROR\033[0m] Failed to set libelfconvbrowser.a." | ||
exit 1 | ||
fi | ||
rm *.o | ||
|
||
# set elfconv-runtime archive (libelfconvwasi.a) | ||
cd "${RUNTIME_DIR}" || { echo "cd Failure"; exit 1; } | ||
# shellcheck disable=SC2086 | ||
$WASISDKCXX $WASISDKFLAGS $WASI_ELFCONV_MACROS -o Entry.o -c Entry.cpp && \ | ||
$WASISDKCXX $WASISDKFLAGS $WASI_ELFCONV_MACROS -o Memory.o -c Memory.cpp && \ | ||
$WASISDKCXX $WASISDKFLAGS $WASI_ELFCONV_MACROS -o Syscall.o -c Syscall.cpp && \ | ||
$WASISDKCXX $WASISDKFLAGS $WASI_ELFCONV_MACROS -o VmIntrinsics.o -c VmIntrinsics.cpp && \ | ||
$WASISDKCXX $WASISDKFLAGS $WASI_ELFCONV_MACROS -o Util.o -c "${UTILS_DIR}"/Util.cpp && \ | ||
$WASISDKCXX $WASISDKFLAGS $WASI_ELFCONV_MACROS -o elfconv.o -c "${UTILS_DIR}"/elfconv.cpp && \ | ||
$WASISDKAR rcs libelfconvwasi.a Entry.o Memory.o Syscall.o VmIntrinsics.o Util.o elfconv.o | ||
if mv libelfconvwasi.a ${RELEASE_DIR}/lib; then | ||
echo -e "[\033[32mINFO\033[0m] Set libelfconvwasi.a." | ||
else | ||
echo -e "[\033[31mERROR\033[0m] Failed to set libelfconvwasi.a." | ||
exit 1 | ||
fi | ||
rm *.o | ||
|
||
} | ||
|
||
main |