|
1 | 1 | Obfuscating compiler for ARM using https://github.com/obfuscator-llvm/obfuscator. |
| 2 | + |
| 3 | +This is designed to be integrated with buildroot in order to provide an |
| 4 | +obfuscating compiler for components that need it. |
| 5 | + |
| 6 | +To integrate with with buildroot, a package.mk will look like this (the `*_SOURCE` |
| 7 | +var below is important, you'll need to interact with the GitHub API to find it |
| 8 | +when upgrading to a new release): |
| 9 | + |
| 10 | +```make |
| 11 | +HOST_LLVM_OBFUSCATOR_VERSION = v4 |
| 12 | +HOST_LLVM_OBFUSCATOR_SOURCE = 5086675 |
| 13 | + |
| 14 | +HOST_LLVM_OBFUSCATOR_SITE = https://$(GITHUB_TOKEN):@api.github.com/repos/swift-nav/llvm-obfuscator-arm/releases/assets |
| 15 | +HOST_LLVM_OBFUSCATOR_METHOD = wget |
| 16 | +HOST_LLVM_OBFUSCATOR_DL_OPTS = --auth-no-challenge --header='Accept:application/octet-stream' |
| 17 | + |
| 18 | +HOST_LLVM_OBFUSCATOR_ACTUAL_SOURCE_TARBALL = llvm-obfuscator-arm-$(HOST_LLVM_OBFUSCATOR_VERSION).tar.xz |
| 19 | +HOST_LLVM_OBFUSCATOR_DEPENDENCIES = host-xz |
| 20 | + |
| 21 | +define HOST_LLVM_OBFUSCATOR_PRE_EXTRACT_FIXUP |
| 22 | + if ! [ -e $(DL_DIR)/$(HOST_LLVM_OBFUSCATOR_ACTUAL_SOURCE_TARBALL) ]; then \ |
| 23 | + mv -v $(DL_DIR)/$(HOST_LLVM_OBFUSCATOR_SOURCE) $(DL_DIR)/$(HOST_LLVM_OBFUSCATOR_ACTUAL_SOURCE_TARBALL); fi |
| 24 | + $(eval HOST_LLVM_OBFUSCATOR_SOURCE=$(HOST_LLVM_OBFUSCATOR_ACTUAL_SOURCE_TARBALL)) |
| 25 | +endef |
| 26 | + |
| 27 | +HOST_LLVM_OBFUSCATOR_PRE_EXTRACT_HOOKS += HOST_LLVM_OBFUSCATOR_PRE_EXTRACT_FIXUP |
| 28 | + |
| 29 | +define HOST_LLVM_OBFUSCATOR_INSTALL_CMDS |
| 30 | + mkdir -p $(HOST_DIR)/opt/llvm-obfuscator |
| 31 | + rsync -az $(@D)/opt/llvm-obfuscator/ $(HOST_DIR)/opt/llvm-obfuscator/ |
| 32 | +endef |
| 33 | + |
| 34 | +LLVM_OBF_CC = $(HOST_DIR)/opt/llvm-obfuscator/wrappers/bin/arm-linux-gnueabihf-clang |
| 35 | +LLVM_OBF_CXX = $(HOST_DIR)/opt/llvm-obfuscator/wrappers/bin/arm-linux-gnueabihf-clang++ |
| 36 | + |
| 37 | +$(eval $(host-generic-package)) |
| 38 | +``` |
| 39 | + |
| 40 | +To upgrade to a new release of the compiler, use the GitHub API to find the |
| 41 | +new artifact ID: |
| 42 | + |
| 43 | +```bash |
| 44 | +> export GITHUB_TOKEN=... # your GitHub auth token |
| 45 | +> curl -sSL -H "Authorization: token $GITHUB_TOKEN" -H "Accept: application/vnd.github.v3.raw" https://api.github.com/repos/swift-nav/llvm-obfuscator-arm/releases/latest | jq '.assets[0].id,.assets[0].name,.tag_name' |
| 46 | + |
| 47 | +5086675 |
| 48 | +"llvm-obfuscator-arm.txz" |
| 49 | +"v4" |
| 50 | +``` |
0 commit comments