diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 242546cf4b73559697cf29631960da43c8b604af..6f7692503e9b3b0cca39f81881113bc1f0331086 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -89,6 +89,7 @@ test-bins-arm64: script: - ./cicd_testing/do-clean.sh - ./cicd_testing/do-build.sh + - ./cicd_testing/libc_test.sh - ./cicd_testing/eh-tests.sh - ./cicd_testing/builtin-xforms.sh - ./cicd_testing/elfdep.sh diff --git a/SMPStaticAnalyzer b/SMPStaticAnalyzer index 0bd405d71fb242fd6d98e7d95ea18487094c5a19..b52cf944c29a13159de32fd470b1cd3eb9b47ab9 160000 --- a/SMPStaticAnalyzer +++ b/SMPStaticAnalyzer @@ -1 +1 @@ -Subproject commit 0bd405d71fb242fd6d98e7d95ea18487094c5a19 +Subproject commit b52cf944c29a13159de32fd470b1cd3eb9b47ab9 diff --git a/builtin_xforms/add_lib/SConstruct b/builtin_xforms/add_lib/SConstruct deleted file mode 100644 index 7fe41a3bcc605387c2eaafceaa7e944ab0d252fb..0000000000000000000000000000000000000000 --- a/builtin_xforms/add_lib/SConstruct +++ /dev/null @@ -1,15 +0,0 @@ -import os - - -env=Environment() -Export('env') -lib=SConscript("SConscript") - - -pedi = Command( target = "./testoutput", - source = "./SConscript", - action = "cd "+os.environ['SECURITY_TRANSFORMS_HOME']+" ; " + os.environ['PEDI_HOME']+"/pedi -m manifest.txt ; cd - " ) - -Depends(pedi,lib); -Default(pedi) - diff --git a/builtin_xforms/resolve_callbacks/SConstruct b/builtin_xforms/resolve_callbacks/SConstruct deleted file mode 100644 index c96332f0422ad5df0853931209219d9a2e20bc17..0000000000000000000000000000000000000000 --- a/builtin_xforms/resolve_callbacks/SConstruct +++ /dev/null @@ -1,6 +0,0 @@ - - - -env=Environment() -Export('env') -lib=SConscript("SConscript") diff --git a/cicd_testing/builtin-xforms.sh b/cicd_testing/builtin-xforms.sh index 190b22c908f66dd7c2c9b3e98f6ed42030298c1a..937214c149008ccc886b9c9ae1931d040108497c 100755 --- a/cicd_testing/builtin-xforms.sh +++ b/cicd_testing/builtin-xforms.sh @@ -10,7 +10,7 @@ cd $PEASOUP_HOME/tests make clean; if [[ $(uname -m) == 'armv7l' ]] || [[ $(uname -m) == 'aarch64' ]]; then - ./test_cmds.sh -c "rida" -l -a "bzip2 ls" + ./test_cmds.sh -c "rida" -l -a "du ls" else ./test_cmds.sh -c "rida fix_calls_rida fix_calls_ida" -l -a "bzip2 tcpdump" if lsb_release -d | grep 'Ubuntu 20.04.4 LTS' ; then diff --git a/cicd_testing/do-prot-bins.sh b/cicd_testing/do-prot-bins.sh index 8ac08919b4b89bb81d5e2e228447661f57538657..1bc20bd86a940ec2376cc2a77c23e6b3ee0eee5b 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/cicd_testing/libc_test.sh b/cicd_testing/libc_test.sh new file mode 100755 index 0000000000000000000000000000000000000000..14f5fe3e0d0b91f7b3507992168ff154bd8d2cf1 --- /dev/null +++ b/cicd_testing/libc_test.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -e +set -x + +cd /tmp/peasoup_test +export IDAROOT=$CICD_MODULE_WORK_DIR/idapro71 +export IDASDK=$CICD_MODULE_WORK_DIR/idapro71_sdk +source set_env_vars + +cd $PEASOUP_HOME/tests/libc/ +./test_libc.sh diff --git a/irdb-libs/SConscript b/irdb-libs/SConscript index 596cc70348a09e99b7222866553611f04895a1d1..8f9047c46572fd31ff5b7a2ad9da24df126ebf7a 100644 --- a/irdb-libs/SConscript +++ b/irdb-libs/SConscript @@ -54,7 +54,7 @@ Export('env') if not env.GetOption('clean'): # get the libcapstone.so.[version] file regardless of the version extension - libcapstone_path = Glob(os.environ['SECURITY_TRANSFORMS_HOME']+'/third_party/capstone/libcapstone.so.*') + libcapstone_path = Glob(os.environ['SECURITY_TRANSFORMS_HOME']+'/third_party/capstone/libcapstone.so.*') assert len(libcapstone_path) <= 1, "More than one candidate for libcapstone.so.[version]?!" assert len(libcapstone_path) != 0, "No candidates for libcapstone.so.[version]?!" @@ -64,7 +64,7 @@ if not env.GetOption('clean'): libcapstone=os.environ['SECURITY_TRANSFORMS_HOME']+"/lib/libcapstone.so" # get the libkeystone.so.[version] file regardless of the version extension - libkeystone_path = Glob(os.environ['SECURITY_TRANSFORMS_HOME']+'/lib/usr/local/lib*/libkeystone.so.*') + libkeystone_path = Glob(os.environ['SECURITY_TRANSFORMS_HOME']+'/lib/usr/local/lib*/libkeystone.so.*') + Glob(os.environ['SECURITY_TRANSFORMS_HOME']+'/lib/usr/local/lib*/*/libkeystone.so.*') assert len(libkeystone_path) <= 1, "More than one candidate for libkeystone.so.[version]?!" assert len(libkeystone_path) != 0, "No candidates for libkeystone.so.[version]?!" diff --git a/irdb-libs/SConstruct b/irdb-libs/SConstruct deleted file mode 100644 index 0abcc3f52b44dd9e3ec1b5680b262758015b4231..0000000000000000000000000000000000000000 --- a/irdb-libs/SConstruct +++ /dev/null @@ -1,77 +0,0 @@ -import os -import sys - - - -(sysname, nodename, release, version, machine)=os.uname() - -env=Environment() - - -# default build options -env.Replace(CFLAGS="-fPIC -fmax-errors=2 -Wall -Werror -fmax-errors=2") -env.Replace(CXXFLAGS="-fPIC -fmax-errors=2 -Wall -Werror -fmax-errors=2 ") -env.Replace(LINKFLAGS="-fPIC -fmax-errors=2 -Wall -Werror -fmax-errors=2 ") - -# parse arguments into env and set default values. -env.Replace(SECURITY_TRANSFORMS_HOME=os.environ['SECURITY_TRANSFORMS_HOME']) -env.Replace(IRDB_SDK=os.environ['IRDB_SDK']) -env.Replace(SMPSA_HOME=os.environ['SMPSA_HOME']) -env.Replace(do_64bit_build=ARGUMENTS.get("do_64bit_build",None)) -env.Replace(debug=ARGUMENTS.get("debug",0)) -env.Replace(build_deep=ARGUMENTS.get("build_deep", 0)) -env.Replace(build_tools=ARGUMENTS.get("build_tools", 1)) -env.Replace(build_stars=ARGUMENTS.get("build_stars", 1)) -env.Replace(build_cgc=ARGUMENTS.get("build_cgc", 0)) - -if 'PEDI_HOME' in os.environ: - env.Replace(PEDI_HOME=os.environ['PEDI_HOME']) - -env.Append(LINKFLAGS=" -Wl,-unresolved-symbols=ignore-in-shared-libs ") - -if int(env['debug']) == 1: - print "Setting debug mode" - env.Append(CFLAGS=" -g ") - env.Append(CXXFLAGS=" -g ") - env.Append(LINKFLAGS=" -g ") - env.Append(SHLINKFLAGS=" -g ") -else: - print "Setting release mode" - env.Append(CFLAGS=" -O3 ") - env.Append(CXXFLAGS=" -O3 ") - env.Append(LINKFLAGS=" -O3 ") - env.Append(SHLINKFLAGS=" -O3 ") - -# set 32/64 bit build properly -print "env[64bit]="+str(env['do_64bit_build']) -if env['do_64bit_build'] is None: - print 'Defaulting to default compilation size.' -elif int(env['do_64bit_build']) == 1: - print 'Using 64-bit compilation size.' - env.Append(CFLAGS=" -m64 ") - env.Append(CXXFLAGS=" -m64 ") - env.Append(LINKFLAGS=" -m64 ") - env.Append(SHLINKFLAGS=" -m64 ") -else: - print 'Using 32-bit compilation size.' - env.Append(CFLAGS=" -m32 ") - env.Append(CXXFLAGS=" -m32 ") - env.Append(LINKFLAGS=" -m32 ") - env.Append(SHLINKFLAGS=" -m32 ") - - - -# add extra flag for solaris. -if sysname == "SunOS": - env.Append(LINKFLAGS=" -L/opt/csw/lib -DSOLARIS ") - env.Append(SHLINKFLAGS=" -L/opt/csw/lib -DSOLARIS ") - env.Append(CFLAGS=" -I/opt/csw/include -DSOLARIS ") - env.Append(CXXFLAGS=" -I/opt/csw/include -DSOLARIS ") - - -Export('env') -if int(env['build_deep']) == 1: - SConscript("SConscript.deep") -else: - SConscript("SConscript") - diff --git a/irdb-libs/dump_insns/SConstruct b/irdb-libs/dump_insns/SConstruct deleted file mode 100644 index 17f632b8c29cd420163897b1eb044ca3486df362..0000000000000000000000000000000000000000 --- a/irdb-libs/dump_insns/SConstruct +++ /dev/null @@ -1,7 +0,0 @@ - - - -env=Environment() -Export('env') -install=SConscript("SConscript") -Return('install') diff --git a/irdb-libs/dump_map/SConstruct b/irdb-libs/dump_map/SConstruct deleted file mode 100644 index ac50a84a9c7d79b2716693b51594bdfbde4110e2..0000000000000000000000000000000000000000 --- a/irdb-libs/dump_map/SConstruct +++ /dev/null @@ -1,9 +0,0 @@ - - - -env=Environment() -env.Append(LINKFLAGS=" -Wl,-unresolved-symbols=ignore-in-shared-libs -L../lib") -Export('env') -install=SConscript("SConscript") - -Return('install') diff --git a/irdb-libs/ir_builders/SConstruct b/irdb-libs/ir_builders/SConstruct deleted file mode 100644 index b5b7b78c5f88640c7e8877a9df76dc9191af7498..0000000000000000000000000000000000000000 --- a/irdb-libs/ir_builders/SConstruct +++ /dev/null @@ -1,8 +0,0 @@ - - - -env=Environment() -Export('env') -lib=SConscript("SConscript") - -Return('lib') diff --git a/irdb-libs/ir_builders/fill_in_indtargs.cpp b/irdb-libs/ir_builders/fill_in_indtargs.cpp index 5c449ef6356e81f81bcec66b853ba9bb81da5ca5..d653b4025d2bc01558e4f3b2d27ff8674694ad83 100644 --- a/irdb-libs/ir_builders/fill_in_indtargs.cpp +++ b/irdb-libs/ir_builders/fill_in_indtargs.cpp @@ -3915,10 +3915,10 @@ V2: const auto scoop_contents = scoop->getContents().c_str(); const auto symsize = ptrsize == 8 ? sizeof(Elf64_Sym) : ptrsize == 4 ? sizeof(Elf32_Sym) - : throw domain_error("Cannot detect ptr size -> ELF symbol mapping"); + : throw domain_error("Cannot detect ptr size -> ELF symbol mapping"); auto table_entry_no = 0U; - for (auto i = 0U; i + symsize < scoop->getSize(); i += symsize, table_entry_no++) + for (auto i = 0U; i + symsize <= scoop->getSize(); i += symsize, table_entry_no++) { int addr_offset = 0; VirtualOffset_t vo = 0; diff --git a/irdb-libs/libEXEIO/SConstruct b/irdb-libs/libEXEIO/SConstruct deleted file mode 100644 index b5b7b78c5f88640c7e8877a9df76dc9191af7498..0000000000000000000000000000000000000000 --- a/irdb-libs/libEXEIO/SConstruct +++ /dev/null @@ -1,8 +0,0 @@ - - - -env=Environment() -Export('env') -lib=SConscript("SConscript") - -Return('lib') diff --git a/irdb-libs/libEXEIO/src/SConstruct b/irdb-libs/libEXEIO/src/SConstruct deleted file mode 100644 index b5b7b78c5f88640c7e8877a9df76dc9191af7498..0000000000000000000000000000000000000000 --- a/irdb-libs/libEXEIO/src/SConstruct +++ /dev/null @@ -1,8 +0,0 @@ - - - -env=Environment() -Export('env') -lib=SConscript("SConscript") - -Return('lib') diff --git a/irdb-libs/libIRDB-cfg/src/SConstruct b/irdb-libs/libIRDB-cfg/src/SConstruct deleted file mode 100644 index b3bd01322f2b78089fd86e0e9b0ae01897c9c8a5..0000000000000000000000000000000000000000 --- a/irdb-libs/libIRDB-cfg/src/SConstruct +++ /dev/null @@ -1,7 +0,0 @@ - - - -env=Environment() -Export('env') -lib=SConscript("SConscript") -Return('lib') diff --git a/irdb-libs/libIRDB-core/src/SConstruct b/irdb-libs/libIRDB-core/src/SConstruct deleted file mode 100644 index b2e8e0ca9b3cfeb2a49f186cdc49b783f79c5adb..0000000000000000000000000000000000000000 --- a/irdb-libs/libIRDB-core/src/SConstruct +++ /dev/null @@ -1,9 +0,0 @@ - - - -env=Environment() -Export('env') -lib=SConscript("SConscript") - -Return('lib') - diff --git a/irdb-libs/libIRDB-core/src/operand_csarm64.cpp b/irdb-libs/libIRDB-core/src/operand_csarm64.cpp index 9ebeee78e96e22066d5551473e84f42fef5d307f..cd80bd3884bec5c29afe2419df412dd7ffe8dea2 100644 --- a/irdb-libs/libIRDB-core/src/operand_csarm64.cpp +++ b/irdb-libs/libIRDB-core/src/operand_csarm64.cpp @@ -51,12 +51,23 @@ string DecodedOperandCapstoneARM64_t::getString() const { case ARM64_OP_REG: return string(cs_reg_name(handle, op.reg)); - case ARM64_OP_REG_MRS: - case ARM64_OP_REG_MSR: - case ARM64_OP_FP: - return string("fpcr"); case ARM64_OP_IMM: + case ARM64_OP_CIMM: return to_string(op.imm); + case ARM64_OP_FP: + return to_string(op.fp); + case ARM64_OP_REG_MRS: + return "MRS"s + to_string(op.reg); + case ARM64_OP_REG_MSR: + return "MSR"s + to_string(op.reg); + case ARM64_OP_PSTATE: + return "STATE"s + to_string(op.pstate); + case ARM64_OP_SYS: + return "SYS"s + to_string(op.sys); + case ARM64_OP_PREFETCH: + return "PREFETCH"s + to_string(op.prefetch); + case ARM64_OP_BARRIER: + return "BARRIER"s + to_string(op.barrier); case ARM64_OP_MEM: { string ret_val; @@ -74,6 +85,7 @@ string DecodedOperandCapstoneARM64_t::getString() const return ret_val; } + default: assert(0); } diff --git a/irdb-libs/libIRDB-elfdep/SConstruct b/irdb-libs/libIRDB-elfdep/SConstruct deleted file mode 100644 index 4d6381b5999d3e6d4e4687fc95f444ea2c4c5747..0000000000000000000000000000000000000000 --- a/irdb-libs/libIRDB-elfdep/SConstruct +++ /dev/null @@ -1,8 +0,0 @@ - - - -env=Environment() -Export('env') -lib=SConscript("SConscript") - -Return(lib) diff --git a/irdb-libs/libIRDB-elfdep/src/SConstruct b/irdb-libs/libIRDB-elfdep/src/SConstruct deleted file mode 100644 index 6c6fd8ea22a97d734ad3e4f3e5a937340c63375d..0000000000000000000000000000000000000000 --- a/irdb-libs/libIRDB-elfdep/src/SConstruct +++ /dev/null @@ -1,30 +0,0 @@ -import os -import utils - - -env=Environment() -Export('env') - -env.Replace(debug=ARGUMENTS.get("debug",0)) - - -if int(env['debug']) == 1: - print "Setting debug mode" - env.Append(CFLAGS=" -g ") - env.Append(CXXFLAGS=" -g ") - env.Append(LINKFLAGS=" -g ") -else: - print "Setting release mode" - env.Append(CFLAGS=" -O3 ") - env.Append(CXXFLAGS=" -O3 ") - env.Append(LINKFLAGS=" -O3 ") - -lib=SConscript("SConscript") - -pedi = Command( target = "./testoutput", - source = "./SConscript", - action = "cd "+os.environ['SECURITY_TRANSFORMS_HOME']+" ; " + os.environ['PEDI_HOME']+"/pedi -m manifest.txt " ) - -Depends(pedi,lib); -Default(pedi) - diff --git a/irdb-libs/libIRDB-syscall/src/SConstruct b/irdb-libs/libIRDB-syscall/src/SConstruct deleted file mode 100644 index 17f632b8c29cd420163897b1eb044ca3486df362..0000000000000000000000000000000000000000 --- a/irdb-libs/libIRDB-syscall/src/SConstruct +++ /dev/null @@ -1,7 +0,0 @@ - - - -env=Environment() -Export('env') -install=SConscript("SConscript") -Return('install') diff --git a/irdb-libs/libIRDB-transform/SConstruct b/irdb-libs/libIRDB-transform/SConstruct deleted file mode 100644 index 4d6381b5999d3e6d4e4687fc95f444ea2c4c5747..0000000000000000000000000000000000000000 --- a/irdb-libs/libIRDB-transform/SConstruct +++ /dev/null @@ -1,8 +0,0 @@ - - - -env=Environment() -Export('env') -lib=SConscript("SConscript") - -Return(lib) diff --git a/irdb-libs/libIRDB-transform/src/SConstruct b/irdb-libs/libIRDB-transform/src/SConstruct deleted file mode 100644 index c96332f0422ad5df0853931209219d9a2e20bc17..0000000000000000000000000000000000000000 --- a/irdb-libs/libIRDB-transform/src/SConstruct +++ /dev/null @@ -1,6 +0,0 @@ - - - -env=Environment() -Export('env') -lib=SConscript("SConscript") diff --git a/irdb-libs/libIRDB-util/src/SConstruct b/irdb-libs/libIRDB-util/src/SConstruct deleted file mode 100644 index 17f632b8c29cd420163897b1eb044ca3486df362..0000000000000000000000000000000000000000 --- a/irdb-libs/libIRDB-util/src/SConstruct +++ /dev/null @@ -1,7 +0,0 @@ - - - -env=Environment() -Export('env') -install=SConscript("SConscript") -Return('install') diff --git a/irdb-libs/libMEDSannotation/SConstruct b/irdb-libs/libMEDSannotation/SConstruct deleted file mode 100644 index b3bd01322f2b78089fd86e0e9b0ae01897c9c8a5..0000000000000000000000000000000000000000 --- a/irdb-libs/libMEDSannotation/SConstruct +++ /dev/null @@ -1,7 +0,0 @@ - - - -env=Environment() -Export('env') -lib=SConscript("SConscript") -Return('lib') diff --git a/irdb-libs/libStructDiv/SConstruct b/irdb-libs/libStructDiv/SConstruct deleted file mode 100644 index 4d6381b5999d3e6d4e4687fc95f444ea2c4c5747..0000000000000000000000000000000000000000 --- a/irdb-libs/libStructDiv/SConstruct +++ /dev/null @@ -1,8 +0,0 @@ - - - -env=Environment() -Export('env') -lib=SConscript("SConscript") - -Return(lib) diff --git a/irdb-libs/libStructDiv/src/SConstruct b/irdb-libs/libStructDiv/src/SConstruct deleted file mode 100644 index c96332f0422ad5df0853931209219d9a2e20bc17..0000000000000000000000000000000000000000 --- a/irdb-libs/libStructDiv/src/SConstruct +++ /dev/null @@ -1,6 +0,0 @@ - - - -env=Environment() -Export('env') -lib=SConscript("SConscript") diff --git a/irdb-libs/meds2pdb/SConstruct b/irdb-libs/meds2pdb/SConstruct deleted file mode 100644 index 17f632b8c29cd420163897b1eb044ca3486df362..0000000000000000000000000000000000000000 --- a/irdb-libs/meds2pdb/SConstruct +++ /dev/null @@ -1,7 +0,0 @@ - - - -env=Environment() -Export('env') -install=SConscript("SConscript") -Return('install') diff --git a/irdb-libs/rida/SConstruct b/irdb-libs/rida/SConstruct deleted file mode 100644 index 39bd7cd0aa70be5adffc2dbe2c7b704a7274fab1..0000000000000000000000000000000000000000 --- a/irdb-libs/rida/SConstruct +++ /dev/null @@ -1,12 +0,0 @@ - - - -env=Environment() - -env.Append(CFLAGS=" -g -Wall -Werror -std=c++14 -fmax-errors=2") -env.Append(CXXFLAGS=" -g -Wall -Werror -std=c++14 -fmax-errors=2") -env.Append(LINKFLAGS=" -g -Wall -Werror -std=c++14 -fmax-errors=2") - -Export('env') -install=SConscript("SConscript") -Return('install') diff --git a/irdb-libs/thanos/SConstruct b/irdb-libs/thanos/SConstruct deleted file mode 100644 index 44d3bd9e81dfb9812806072103183b71c0810436..0000000000000000000000000000000000000000 --- a/irdb-libs/thanos/SConstruct +++ /dev/null @@ -1,7 +0,0 @@ - - - -env=Environment() -Export('env') -ret=SConscript("SConscript") -Return('ret') diff --git a/irdb-libs/third_party/capstone b/irdb-libs/third_party/capstone index 1d230532840a37ac032c6ab80128238fc930c6c1..d5141c04785678535c7792eddc21f146186e639f 160000 --- a/irdb-libs/third_party/capstone +++ b/irdb-libs/third_party/capstone @@ -1 +1 @@ -Subproject commit 1d230532840a37ac032c6ab80128238fc930c6c1 +Subproject commit d5141c04785678535c7792eddc21f146186e639f diff --git a/set_command_envs b/set_command_envs index ee97496fb68e26dd201c903ed8189a8395ab4d08..2c3491faf46e3e6f9ed2edcf6875e09242206d93 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/tests/libc/hello.c b/tests/libc/hello.c new file mode 100644 index 0000000000000000000000000000000000000000..469c20bec1a312b3faf70c79b9e8d0a755204af0 --- /dev/null +++ b/tests/libc/hello.c @@ -0,0 +1,5 @@ +#include <stdio.h> +int main() { + printf("Hello world\n"); + return 0; +} diff --git a/tests/libc/test_libc.sh b/tests/libc/test_libc.sh new file mode 100755 index 0000000000000000000000000000000000000000..e27d32039d0651a0abe3ef86e24dbba891d180f2 --- /dev/null +++ b/tests/libc/test_libc.sh @@ -0,0 +1,35 @@ +#!/bin/bash + + +main() +{ + set -e + set -x + + # make sure no prior libcs are hanging out. + rm -rf libc.* || true + + # calc some names + local libc=$(ldd $(which ls)|grep 'libc\.'|cut -d'>' -f2|cut -d'(' -f1) + local libc_short=$(basename $libc) + local libc_zipr=$(basename $libc).zipr + + # run zipr + $PSZ $(realpath $libc) $libc_zipr + + # move the zir'd libc to the right name. All subsequent commands + # now run with the zipr'd libc + mv $libc_zipr $libc_short + + # invoke gcc + gcc hello.c || exit 1 + ./a.out || exit 1 + + # invoke zipr on ls -- using zipr'd libc. + $PSZ $(which ls) ls.zipr || exit 1 + ./ls.zipr -lhrSR || exit 1 + ldd ./ls.zipr +} + +main "$@" + diff --git a/tools/eh_frame_tools/eh_to_bin.sh b/tools/eh_frame_tools/eh_to_bin.sh index 86056d29b34ea68b72a27e76e64d80cee6670f00..7f10b67263ed06ac607685f4d3e219dcd44eea46 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 diff --git a/zipr/SConstruct b/zipr/SConstruct deleted file mode 100644 index 78796d1f77efe432c8d89540cd7835eccf183397..0000000000000000000000000000000000000000 --- a/zipr/SConstruct +++ /dev/null @@ -1,60 +0,0 @@ -import os -import sys - -(sysname, nodename, release, version, machine)=os.uname() - - -env=Environment() - -# default build options -env.Replace(CFLAGS=" -fPIC ") -env.Replace(CXXFLAGS=" -std=c++14 -fPIC ") -env.Replace(LINKFLAGS=" -fPIC ") - -# parse arguments -env.Replace(SECURITY_TRANSFORMS_HOME=os.environ['SECURITY_TRANSFORMS_HOME']) -env.Replace(ZIPR_HOME=os.environ['ZIPR_HOME']) -env.Replace(ZIPR_INSTALL=os.environ['ZIPR_INSTALL']) -env.Replace(ZIPR_SDK=os.environ['ZIPR_SDK']) -env.Replace(profile=ARGUMENTS.get("profile",0)) -env.Replace(debug=ARGUMENTS.get("debug",0)) -env.Replace(do_cgc=ARGUMENTS.get("do_cgc",0)) -env.Replace(do_64bit_build=ARGUMENTS.get("do_64bit_build",0)) - -env.Append(LINKFLAGS=" -Wl,-unresolved-symbols=ignore-in-shared-libs ") - -if int(env['profile']) == 1: - print "Setting profile and debug mode" - env.Append(CFLAGS=" -pg") - env.Append(CXXFLAGS=" -pg") - env.Append(LINKFLAGS=" -pg") - env['debug'] = 1 -if int(env['debug']) == 1: - print "Setting debug mode" - env.Append(CFLAGS=" -g") - env.Append(CXXFLAGS=" -g") - env.Append(LINKFLAGS=" -g") -else: - print "Setting release mode" - env.Append(CFLAGS=" -O3") - env.Append(CXXFLAGS=" -O3") - env.Append(LINKFLAGS=" -O3") - -env['build_appfw']=0 -env['build_tools']=0 - -# add extra flag for solaris. -if sysname == "SunOS": - env.Append(LINKFLAGS=" -L/opt/csw/lib -DSOLARIS ") - env.Append(CFLAGS=" -I/opt/csw/include -DSOLARIS ") - env.Append(CXXFLAGS=" -I/opt/csw/include -DSOLARIS ") -else: - env.Append(CFLAGS=" -fPIE ") - env.Append(CXXFLAGS=" -fPIE ") - env.Append(LINKFLAGS=" -fPIE ") - - - -Export('env') -SConscript("SConscript") - diff --git a/zipr/src/SConstruct b/zipr/src/SConstruct deleted file mode 100644 index c0dd68a00d406b0148a93709cf916ad6d05f282c..0000000000000000000000000000000000000000 --- a/zipr/src/SConstruct +++ /dev/null @@ -1,6 +0,0 @@ - - - -env=Environment() -Export('env') -SConscript("SConscript") diff --git a/zipr/src/zipr.cpp b/zipr/src/zipr.cpp index 0363678f3b80b617b8be8fded8b0bfb3ff201050..c4862f24bf05790613d9f5082f291d5e4ea9d733 100644 --- a/zipr/src/zipr.cpp +++ b/zipr/src/zipr.cpp @@ -360,7 +360,7 @@ void ZiprImpl_t::CreateExecutableScoops(const std::map<RangeAddress_t, int> &ord // setup a scoop for this section. // zero init is OK, after zipring we'll update with the right bytes. - const auto text_name = count == 1 ? string(".text") : string(".zipr_text_")+to_string(count++); + const auto text_name = count++ == 0u ? string(".text") : string(".zipr_text_")+to_string(count); const auto text_contents = string(text_end->getVirtualOffset() - text_start->getVirtualOffset()+1, '\x00'); const auto text_scoop = m_firp->addNewDataScoop(text_name, text_start, text_end, nullptr, 5 /*R-X*/, false, text_contents); diff --git a/zipr_push64_reloc_plugin/SConstruct b/zipr_push64_reloc_plugin/SConstruct deleted file mode 100644 index 6b5cd6b97e922cc5aa24482950db5749869a4818..0000000000000000000000000000000000000000 --- a/zipr_push64_reloc_plugin/SConstruct +++ /dev/null @@ -1,47 +0,0 @@ -import os -import sys - -(sysname, nodename, release, version, machine)=os.uname() - - - - -env=Environment() - -# default build options -env.Replace(CFLAGS="-fPIC -w ") -env.Replace(CXXFLAGS="-fPIC -w ") -env.Replace(LINKFLAGS="-fPIC ") - -# parse arguments -env.Replace(SECURITY_TRANSFORMS_HOME=os.environ['SECURITY_TRANSFORMS_HOME']) -env.Replace(ZIPR_HOME=os.environ['ZIPR_HOME']) -env.Replace(ZIPR_INSTALL=os.environ['ZIPR_INSTALL']) -env.Replace(ZIPR_SDK=os.environ['ZIPR_SDK']) -env.Replace(debug=ARGUMENTS.get("debug",0)) -env.Replace(do_64bit_build=ARGUMENTS.get("do_64bit_build",0)) - - -if int(env['debug']) == 1: - print "Setting debug mode" - env.Append(CFLAGS=" -g") - env.Append(CXXFLAGS=" -g") - env.Append(LINKFLAGS=" -g") -else: - print "Setting release mode" - env.Append(CFLAGS=" -O3") - env.Append(CXXFLAGS=" -O3") - env.Append(LINKFLAGS=" -O3") - -if sysname == "SunOS": - env.Append(LINKFLAGS=" -L/opt/csw/lib -DSOLARIS ") - env.Append(CFLAGS=" -I/opt/csw/include -DSOLARIS ") - env.Append(CXXFLAGS=" -I/opt/csw/include -DSOLARIS ") - - -env['build_appfw']=0 -env['build_tools']=0 - -Export('env') -SConscript("SConscript", variant_dir='build') - diff --git a/zipr_unpin_plugin/SConstruct b/zipr_unpin_plugin/SConstruct deleted file mode 100644 index 6b5cd6b97e922cc5aa24482950db5749869a4818..0000000000000000000000000000000000000000 --- a/zipr_unpin_plugin/SConstruct +++ /dev/null @@ -1,47 +0,0 @@ -import os -import sys - -(sysname, nodename, release, version, machine)=os.uname() - - - - -env=Environment() - -# default build options -env.Replace(CFLAGS="-fPIC -w ") -env.Replace(CXXFLAGS="-fPIC -w ") -env.Replace(LINKFLAGS="-fPIC ") - -# parse arguments -env.Replace(SECURITY_TRANSFORMS_HOME=os.environ['SECURITY_TRANSFORMS_HOME']) -env.Replace(ZIPR_HOME=os.environ['ZIPR_HOME']) -env.Replace(ZIPR_INSTALL=os.environ['ZIPR_INSTALL']) -env.Replace(ZIPR_SDK=os.environ['ZIPR_SDK']) -env.Replace(debug=ARGUMENTS.get("debug",0)) -env.Replace(do_64bit_build=ARGUMENTS.get("do_64bit_build",0)) - - -if int(env['debug']) == 1: - print "Setting debug mode" - env.Append(CFLAGS=" -g") - env.Append(CXXFLAGS=" -g") - env.Append(LINKFLAGS=" -g") -else: - print "Setting release mode" - env.Append(CFLAGS=" -O3") - env.Append(CXXFLAGS=" -O3") - env.Append(LINKFLAGS=" -O3") - -if sysname == "SunOS": - env.Append(LINKFLAGS=" -L/opt/csw/lib -DSOLARIS ") - env.Append(CFLAGS=" -I/opt/csw/include -DSOLARIS ") - env.Append(CXXFLAGS=" -I/opt/csw/include -DSOLARIS ") - - -env['build_appfw']=0 -env['build_tools']=0 - -Export('env') -SConscript("SConscript", variant_dir='build') -