Skip to content
Snippets Groups Projects
Commit 7141a2b9 authored by jdh8d's avatar jdh8d
Browse files

First, working version of the EH-iR. enable with --step-option fill_in_indtargs:--split-eh-frame.

Former-commit-id: 79b921df8fc4f4b32196bcbfbbf7637267cf8c62
parent a4a81a29
No related branches found
No related tags found
No related merge requests found
...@@ -110,6 +110,7 @@ CREATE TABLE #EHPGM# ...@@ -110,6 +110,7 @@ CREATE TABLE #EHPGM#
eh_pgm_id integer, -- id of this object. eh_pgm_id integer, -- id of this object.
caf integer, -- code alignment factor. caf integer, -- code alignment factor.
daf integer, -- data alignment factor daf integer, -- data alignment factor
return_register integer, -- dwarf return register.
ptrsize integer, -- size of a pointer, 4 or 8. ptrsize integer, -- size of a pointer, 4 or 8.
cie_program text, -- for the cie, the bytes that make up a cie program, encoded as hex with commas separating instructions. cie_program text, -- for the cie, the bytes that make up a cie program, encoded as hex with commas separating instructions.
fde_program text -- for the fde, bytes as above fde_program text -- for the fde, bytes as above
......
#!/bin/bash #!/bin/bash
gcc sample.eh.s -nostdlib -Wl,--section-start -Wl,eh_frame_hdr=0x602000 -Wl,-e -Wl,0x1000 -Wl,--build-id=none -Wl,-T -Wl,./eh_frame.ls || exit infile=$1
eu-readelf -S ./a.out addr=$2
objcopy --rename-section eh_frame_hdr=.eh_frame_hdr --rename-section eh_frame=.eh_frame --rename-section gcc_except_table=.gcc_except_table a.out b.out outfile=$3
eu-readelf -S -w ./b.out
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 || exit
#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
#eu-readelf -S -w ./b.out
...@@ -23,14 +23,17 @@ ...@@ -23,14 +23,17 @@
eh_frame_hdr_start: eh_frame_hdr_start:
.byte 1 # version .byte 1 # version
.byte 0x10 | 0x0B # encoding for pointer to eh-frame -- DH_EH_PE_pcrel (0x10) | DH_EH_PE_sdata4 (0x0B) .byte 0x10 | 0x0B # encoding for pointer to eh-frame -- DH_EH_PE_pcrel (0x10) | DH_EH_PE_sdata4 (0x0B)
.byte 0x03 # encoding for ; of entries in eh-frame-hdr -- BDH_EH_PE_udata4 (0x03) .byte 0x03 # encoding for ; of entries in eh-frame-hdr -- DH_EH_PE_udata4 (0x03)
.byte 0x10 | 0x0B # encoding for pointers (to fdes) held in the eh-frame-hdr header -- DH_EH_PE_pcrel | DH_EH_PE_sdata4 .byte 0x30 | 0x0B # encoding for pointers (to fdes) held in the eh-frame-hdr header -- DH_EH_PE_datarel (0x30) | DH_EH_PE_sdata4 (0x0b)
.int Lfde_table - . # pointer to fde_table, encoded as an sdata4, pcrel .int Lfde_table - . # pointer to fde_table, encoded as an sdata4, pcrel
.byte (eh_frame_table_end-eh_frame_table)/4 # number of FDEs in the header. .int (eh_frame_table_end-eh_frame_table)/8 # number of FDEs in the header.
.align 4 .align 4
eh_frame_table: eh_frame_table:
.int Lfde1 - . # fde pointers # an entry in the table is {offset to fde start , offset fde itself }, encoded as datarel|sdata4
.int Lfde2 - . .int fde1_start_addr - eh_frame_hdr_start
.int Lfde1 - eh_frame_hdr_start
.int fde1_start_addr - eh_frame_hdr_start
.int Lfde2 - eh_frame_hdr_start
eh_frame_table_end: eh_frame_table_end:
...@@ -48,9 +51,9 @@ Lcie1: ...@@ -48,9 +51,9 @@ Lcie1:
.sleb128 -8 # data alignment factor .sleb128 -8 # data alignment factor
.uleb128 16 # return address reg. .uleb128 16 # return address reg.
Lcie1_aug_data_start:
# encode the Z (length) # encode the Z (length)
.sleb128 Lcie1_aug_data_end-Lcie1_aug_data_start # Z -- handle length field .sleb128 Lcie1_aug_data_end-Lcie1_aug_data_start # Z -- handle length field
Lcie1_aug_data_start:
#encode the P (personality encoding + personality routine) #encode the P (personality encoding + personality routine)
.byte 0x80 | 0x10 | 0x0B # personality pointer encoding DH_EH_PE_indirect (0x80) | pcrel | sdata4 .byte 0x80 | 0x10 | 0x0B # personality pointer encoding DH_EH_PE_indirect (0x80) | pcrel | sdata4
......
...@@ -247,7 +247,7 @@ check_options() ...@@ -247,7 +247,7 @@ check_options()
if [ "X$2" = "Xzipr" ]; then if [ "X$2" = "Xzipr" ]; then
echo "Using Zipr backend." echo "Using Zipr backend."
export backend="zipr" export backend="zipr"
phases_spec=" $phases_spec stratafy_with_pc_confine=off generate_spri=off spasm=off fast_annot=off zipr=on preLoaded_ILR1=off preLoaded_ILR2=off fast_spri=off " phases_spec=" $phases_spec stratafy_with_pc_confine=off generate_spri=off spasm=off fast_annot=off zipr=on preLoaded_ILR1=off preLoaded_ILR2=off fast_spri=off create_binary_script=off is_so=off"
phases_spec=${phases_spec/preLoaded_ILR1=on/} phases_spec=${phases_spec/preLoaded_ILR1=on/}
phases_spec=${phases_spec/preLoaded_ILR2=on/} phases_spec=${phases_spec/preLoaded_ILR2=on/}
step_options_gather_libraries="$step_options_gather_libraries --main_exe_only" step_options_gather_libraries="$step_options_gather_libraries --main_exe_only"
...@@ -938,45 +938,6 @@ check_for_bad_funcs $newname.ncexe ...@@ -938,45 +938,6 @@ check_for_bad_funcs $newname.ncexe
mkdir logs mkdir logs
# copy in some shared libraries if requested.
#perform_step diehard none cp $CFAR_HOME/DieHard/src/libdiehard.so libheaprand.so
#perform_step diehard none $PEASOUP_HOME/tools/update_env_var.sh DO_DIEHARD 1
#perform_step libtwitcher none cp $GT_COLLAB_HOME/downloads/libtwitcher.so libheaprand.so
#perform_step noh none cp $CFAR_HOME/non_overlapping_heap/noh.so noh.so
#perform_step nol none cp $CFAR_HOME/non_overlapping_libraries/ld-linux-x86-64.so.2 ld-linux-x86-64.so.2.nol
#
# create a stratafied binary that does pc confinement.
#
#perform_step stratafy_with_pc_confine none sh $STRATA_HOME/tools/pc_confinement/stratafy_with_pc_confine.sh $newname.ncexe $newname.stratafied
#cp a.ncexe a.ncexe.orig
#perform_step add_confinement_section none $STRATA_HOME/tools/pc_confinement/add_confinement_section.sh a.ncexe.orig a.ncexe
#
# CGC CRCX elide
#
#perform_step cgc_optimize_start none $DAFFY_HOME/dead_code_ident/optimize_start.sh a.ncexe
#
# Let's output the modified binary
# This binary will really be a shell script that calls the newly stratafied binary
#
#perform_step create_binary_script mandatory $PEASOUP_HOME/tools/do_makepeasoupbinary2.sh $name
#perform_step heaprand pc_confine,double_free $PEASOUP_HOME/tools/update_env_var.sh STRATA_HEAPRAND 1
#perform_step controlled_exit none $PEASOUP_HOME/tools/update_env_var.sh STRATA_CONTROLLED_EXIT 1
#perform_step detect_server pc_confine $PEASOUP_HOME/tools/update_env_var.sh STRATA_DETECT_SERVERS 1
#perform_step rekey none $PEASOUP_HOME/tools/update_env_var.sh STRATA_REKEY_AFTER 5000
#perform_step double_free heaprand $PEASOUP_HOME/tools/update_env_var.sh STRATA_DOUBLE_FREE 1
#perform_step pc_confine none $PEASOUP_HOME/tools/update_env_var.sh STRATA_PC_CONFINE 1
#perform_step isr pc_confine $PEASOUP_HOME/tools/update_env_var.sh STRATA_PC_CONFINE_XOR 1
#perform_step watchdog signconv_func_monitor $PEASOUP_HOME/tools/update_env_var.sh STRATA_WATCHDOG $watchdog_val
#perform_step is_so mandatory $PEASOUP_HOME/tools/update_env_var.sh STRATA_IS_SO $($PEASOUP_HOME/tools/is_so.sh a.ncexe)
#perform_step ibtl ilr $PEASOUP_HOME/tools/update_env_var.sh STRATA_IBTL 1
# turn on sign conversion function monitoring
#perform_step signconv_func_monitor heaprand $PEASOUP_HOME/tools/update_env_var.sh STRATA_NUM_HANDLE 1
# #
# turn off runtime protections for BED. turn off runtime prrotections for BED. turn off runtime prrotections for BED. # turn off runtime protections for BED. turn off runtime prrotections for BED. turn off runtime prrotections for BED.
# #
...@@ -1048,7 +1009,7 @@ fi ...@@ -1048,7 +1009,7 @@ fi
# build basic IR # build basic IR
perform_step fill_in_cfg mandatory $SECURITY_TRANSFORMS_HOME/bin/fill_in_cfg.exe $varid perform_step fill_in_cfg mandatory $SECURITY_TRANSFORMS_HOME/bin/fill_in_cfg.exe $varid
perform_step fill_in_safefr mandatory $SECURITY_TRANSFORMS_HOME/bin/fill_in_safefr.exe $varid perform_step fill_in_safefr mandatory $SECURITY_TRANSFORMS_HOME/bin/fill_in_safefr.exe $varid
perform_step fill_in_indtargs mandatory $SECURITY_TRANSFORMS_HOME/bin/fill_in_indtargs.exe $varid perform_step fill_in_indtargs mandatory $SECURITY_TRANSFORMS_HOME/bin/fill_in_indtargs.exe $varid $step_options_fill_in_indtargs
# finally create a clone so we can do some transforms # finally create a clone so we can do some transforms
perform_step clone mandatory $SECURITY_TRANSFORMS_HOME/bin/clone.exe $varid clone.id perform_step clone mandatory $SECURITY_TRANSFORMS_HOME/bin/clone.exe $varid clone.id
......
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