Skip to content
Snippets Groups Projects
Commit b268b6b3 authored by Anh Nguyen-Tuong's avatar Anh Nguyen-Tuong
Browse files

Merge branch...

Merge branch '30-elfdependencies-library-does-not-assign-file-id-when-appending-a-plt-entry' into 'master'

Resolve "ElfDependencies library does not assign file id when appending a plt entry"

Closes #30

See merge request allnp/security_transforms!21

Former-commit-id: f97e45fed48b81799ec5784bb86b1114e5a399cf
parents 374a20ea 8270c407
No related branches found
No related tags found
No related merge requests found
......@@ -145,3 +145,34 @@ xform-cat-centos75:
variables:
OS: 'centos75'
#
# elfdep test
#
# template
.elfdep: &elfdep
stage: test
script:
- ./cicd_tests/elfdep.sh
elfdep-ubuntu18:
<<: *elfdep
tags:
- ubuntu18
variables:
OS: 'ubuntu18'
elfdep-ubuntu16:
<<: *elfdep
tags:
- ubuntu16
variables:
OS: 'ubuntu16'
elfdep-centos75:
<<: *elfdep
tags:
- centos75
variables:
OS: 'centos75'
#!/bin/bash
set -e
set -x
cd $CICD_MODULE_WORK_DIR/peasoup_umbrella
source set_env_vars
cd $SECURITY_TRANSFORMS_HOME/libElfDep/test/
./test-elfdep.sh
......@@ -206,6 +206,7 @@ Instruction_t* ElfDependencies_t::ElfDependenciesImpl_t<T_Elf_Sym,T_Elf_Rela,T_E
newinsn->GetRelocations().insert(newreloc);
getFileIR()->GetRelocations().insert(newreloc);
newinsn->GetAddress()->SetFileID(getFileIR()->GetFile()->GetBaseID());
return newinsn;
}
......
......@@ -32,7 +32,7 @@ files=Glob( Dir('.').srcnode().abspath+"/edt*.cpp")
pgm="edt.exe"
LIBPATH="$SECURITY_TRANSFORMS_HOME/lib"
LIBS=Split("stars "+ myenv.subst('$BASE_IRDB_LIBS')+ " IRDB-core pqxx BeaEngine_s_d transform MEDSannotation EXEIO pebliss ElfDep")
LIBS=Split("stars "+ myenv.subst('$BASE_IRDB_LIBS')+ " IRDB-core libIRDB-cfg libIRDB-util.so pqxx capstone transform MEDSannotation EXEIO pebliss ElfDep")
myenv=myenv.Clone(CPPPATH=Split(cpppath))
pgm=myenv.Program(pgm, files, LIBPATH=LIBPATH, LIBS=LIBS)
install=myenv.Install("$SECURITY_TRANSFORMS_HOME/plugins_install/", pgm)
......
......@@ -41,23 +41,23 @@ int ElfDep_Tester_t::execute()
// insert the instrumentation
auto tmp=insert_loc;
(void)insertAssemblyBefore(getFileIR(),tmp," push rdi") ;
tmp= insertAssemblyAfter(getFileIR(), tmp," push rsi ") ;
tmp= insertAssemblyAfter(getFileIR(), tmp," push rdx") ;
tmp= insertAssemblyAfter(getFileIR(), tmp," push rcx ") ;
tmp= insertAssemblyAfter(getFileIR(), tmp," push r8 ") ;
tmp= insertAssemblyAfter(getFileIR(), tmp," push r9 ") ;
tmp= insertAssemblyAfter(getFileIR(), tmp," call 0 ", edpcb) ;
tmp= insertAssemblyAfter(getFileIR(), tmp," L1: mov rcx, [rel L1]");
(void)insertAssemblyBefore(tmp," push rdi") ;
tmp= insertAssemblyAfter(tmp," push rsi ") ;
tmp= insertAssemblyAfter(tmp," push rdx") ;
tmp= insertAssemblyAfter(tmp," push rcx ") ;
tmp= insertAssemblyAfter(tmp," push r8 ") ;
tmp= insertAssemblyAfter(tmp," push r9 ") ;
tmp= insertAssemblyAfter(tmp," call 0 ", edpcb) ;
tmp= insertAssemblyAfter(tmp," L1: mov rcx, [rel L1]");
auto got_insn=tmp;
tmp= insertAssemblyAfter(getFileIR(), tmp," inc dword [rcx]");
tmp= insertAssemblyAfter(getFileIR(), tmp," call 0", edpcb);
tmp= insertAssemblyAfter(getFileIR(), tmp," pop r9");
tmp= insertAssemblyAfter(getFileIR(), tmp," pop r8");
tmp= insertAssemblyAfter(getFileIR(), tmp," pop rcx");
tmp= insertAssemblyAfter(getFileIR(), tmp," pop rdx");
tmp= insertAssemblyAfter(getFileIR(), tmp," pop rsi");
tmp= insertAssemblyAfter(getFileIR(), tmp," pop rdi");
tmp= insertAssemblyAfter(tmp," inc dword [rcx]");
tmp= insertAssemblyAfter(tmp," call 0", edpcb);
tmp= insertAssemblyAfter(tmp," pop r9");
tmp= insertAssemblyAfter(tmp," pop r8");
tmp= insertAssemblyAfter(tmp," pop rcx");
tmp= insertAssemblyAfter(tmp," pop rdx");
tmp= insertAssemblyAfter(tmp," pop rsi");
tmp= insertAssemblyAfter(tmp," pop rdi");
// map the load to point at the GOT entry.
......
#!/bin/bash
TMP_ORIG=/tmp/testelfdep.ls.orig.$$
TMP_ORIG2=/tmp/testelfdep.ls.orig.2.$$
TMP_ELFDEP=/tmp/testelfdep.ls.elfdep.$$
cleanup_files()
{
rm /tmp/testelfdep.ls* >/dev/null 2>&1
}
cleanup()
{
echo "************"
echo "test failed."
echo "************"
cleanup_files
exit 1
}
......@@ -14,8 +25,19 @@ scons || cleanup
$PSZ /bin/ls ./xxx -c move_globals=on -o move_globals:--elftables -c edt=on || cleanup
/bin/ls /tmp || cleanup
./xxx /tmp || cleanup
/bin/ls /tmp > $TMP_ORIG || cleanup
./xxx /tmp > $TMP_ELFDEP || cleanup
echo "Verify external vars was overwritten"
grep "var = 0" $TMP_ELFDEP || cleanup
grep "var = 1" $TMP_ELFDEP || cleanup
echo "Verify same output"
grep -v "var =" $TMP_ELFDEP > $TMP_ORIG2
diff $TMP_ORIG2 $TMP_ELFDEP
cleanup_files
echo
echo "test passed."
......
Subproject commit a6b87b7bc31499b9ec538701b438f7a60e9dda38
Subproject commit 9408c0de4f3a4b2a3cc1cac3f22219301c561400
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment