From b3bb18ec2c51264eff3240ae8c47a6a7a6c238a4 Mon Sep 17 00:00:00 2001 From: Jason Hiser <jdhiser@gmail.com> Date: Mon, 3 Apr 2023 08:43:04 -0400 Subject: [PATCH] Adjust to use aarch64 tools while xforming aarch64 programs on x86 --- cicd_testing/do-prot-bins.sh | 4 +++- set_command_envs | 1 + tools/eh_frame_tools/eh_to_bin.sh | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cicd_testing/do-prot-bins.sh b/cicd_testing/do-prot-bins.sh index 8ac08919b..1bc20bd86 100755 --- a/cicd_testing/do-prot-bins.sh +++ b/cicd_testing/do-prot-bins.sh @@ -12,7 +12,7 @@ popd install_deps() { - sudo apt-get install -y binutils-aarch64-linux-gnu + sudo apt-get install -y binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu } main() @@ -20,6 +20,8 @@ main() install_deps export PS_OBJDUMP=$(which aarch64-linux-gnu-objdump) export PS_READELF=$(which aarch64-linux-gnu-readelf) + export PS_GCC=$(which aarch64-linux-gnu-gcc) + export PS_OBJCOPY=$(which aarch64-linux-gnu-objcopy) mkdir -p artifacts/protected_binaries diff --git a/set_command_envs b/set_command_envs index ee97496fb..2c3491faf 100755 --- a/set_command_envs +++ b/set_command_envs @@ -8,4 +8,5 @@ if [[ -z $PS_TAR ]] ; then export PS_TAR=tar; fi if [[ -z $PS_MD5SUM ]] ; then export PS_MD5SUM=md5sum; fi if [[ -z $PS_TIMEOUT ]] ; then export PS_TIMEOUT=timeout; fi if [[ -z $PS_GREP ]] ; then export PS_GREP=grep; fi +if [[ -z $PS_GCC ]] ; then export PS_GCC=gcc; fi diff --git a/tools/eh_frame_tools/eh_to_bin.sh b/tools/eh_frame_tools/eh_to_bin.sh index 86056d29b..7f10b6726 100755 --- a/tools/eh_frame_tools/eh_to_bin.sh +++ b/tools/eh_frame_tools/eh_to_bin.sh @@ -8,10 +8,10 @@ outfile=$3 # so then try normal gcc # and if both fail, then we exit with an error code -gcc $infile -nostdlib -Wl,--section-start -Wl,eh_frame_hdr=$addr -Wl,-e -Wl,0x1000 -Wl,--build-id=none -Wl,-T -Wl,${PEASOUP_HOME}/tools/eh_frame_tools/eh_frame.ls -o $outfile -Wl,-Map,$outfile.map -static -no-pie -fno-PIC || \ -gcc $infile -nostdlib -Wl,--section-start -Wl,eh_frame_hdr=$addr -Wl,-e -Wl,0x1000 -Wl,--build-id=none -Wl,-T -Wl,${PEASOUP_HOME}/tools/eh_frame_tools/eh_frame.ls -o $outfile -Wl,-Map,$outfile.map -static || \ +$PS_GCC $infile -nostdlib -Wl,--section-start -Wl,eh_frame_hdr=$addr -Wl,-e -Wl,0x1000 -Wl,--build-id=none -Wl,-T -Wl,${PEASOUP_HOME}/tools/eh_frame_tools/eh_frame.ls -o $outfile -Wl,-Map,$outfile.map -static -no-pie -fno-PIC || \ +$PS_GCC $infile -nostdlib -Wl,--section-start -Wl,eh_frame_hdr=$addr -Wl,-e -Wl,0x1000 -Wl,--build-id=none -Wl,-T -Wl,${PEASOUP_HOME}/tools/eh_frame_tools/eh_frame.ls -o $outfile -Wl,-Map,$outfile.map -static || \ exit 1 #eu-readelf -S ./a.out -objcopy --rename-section eh_frame_hdr=.eh_frame_hdr --rename-section eh_frame=.eh_frame --rename-section gcc_except_table=.gcc_except_table $outfile +$PS_OBJCOPY --rename-section eh_frame_hdr=.eh_frame_hdr --rename-section eh_frame=.eh_frame --rename-section gcc_except_table=.gcc_except_table $outfile #eu-readelf -S -w ./b.out -- GitLab