Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CFI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open Source Software
CFI
Commits
e5b70e3c
Commit
e5b70e3c
authored
8 years ago
by
an7s
Browse files
Options
Downloads
Patches
Plain Diff
test inter-module cfi
parent
904f0263
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
tests/dude.c
+14
-0
14 additions, 0 deletions
tests/dude.c
tests/libdude.c
+8
-0
8 additions, 0 deletions
tests/libdude.c
tests/test_dude.sh
+95
-0
95 additions, 0 deletions
tests/test_dude.sh
tests/test_pow.sh
+1
-1
1 addition, 1 deletion
tests/test_pow.sh
with
118 additions
and
1 deletion
tests/dude.c
0 → 100644
+
14
−
0
View file @
e5b70e3c
#include
<stdlib.h>
#include
<stdio.h>
extern
int
dude
();
int
main
()
{
dude
();
}
void
foo2
()
{
printf
(
"In foo2()
\n
"
);
}
This diff is collapsed.
Click to expand it.
tests/libdude.c
0 → 100644
+
8
−
0
View file @
e5b70e3c
#include
<stdio.h>
void
dude
()
{
printf
(
"in dude
\n
"
);
foo
();
}
This diff is collapsed.
Click to expand it.
tests/test_dude.sh
0 → 100755
+
95
−
0
View file @
e5b70e3c
#!/bin/bash -x
do_cfi
()
{
$PS
$1
$2
--backend
zipr
--step
selective_cfi
=
on
--step-option
selective_cfi:--multimodule
--step
move_globals
=
on
--step-option
move_globals:--cfi
--step-option
fix_calls:--fix-all
--step-option
zipr:
"--add-sections false"
}
do_coloring_cfi
()
{
$PS
$1
$2
--backend
zipr
--step
selective_cfi
=
on
--step-option
selective_cfi:--multimodule
--step
move_globals
=
on
--step-option
move_globals:--cfi
--step-option
fix_calls:--fix-all
--step-option
selective_cfi:--color
--step-option
zipr:
"--add-sections false"
}
get_correct
()
{
cp
libfoo.so.orig libfoo.so
cp
libdude.so.orig libdude.so
./dude.exe
>
correct
}
test
()
{
cp
$2
libfoo.so
cp
$3
libdude.so
./
$1
>
out
cmp out correct
if
[
$?
=
1
]
;
then
fails
=
$(
expr
$fails
+ 1
)
echo test
failed
$1
$2
$3
echo
"=== out ==="
cat
out
echo
"======"
else
passes
=
$(
expr
$passes
+ 1
)
echo test
passed.
fi
}
build
()
{
gcc
-o
libfoo.so libfoo.c
-w
-shared
-fPIC
gcc
-o
libdude.so libdude.c
-w
-shared
-fPIC
gcc
-o
dude.exe dude.c
-w
-L
.
-ldude
-lfoo
mv
libfoo.so libfoo.so.orig
mv
libdude.so libdude.so.orig
}
protect
()
{
do_coloring_cfi ./dude.exe ./dude.exe.cfi
do_cfi ./libfoo.so.orig ./libfoo.so.cfi
do_cfi ./libdude.so.orig ./libdude.so.cfi
}
clean
()
{
rm
out
rm
correct
rm
-Rf
dude.exe peasoup_exe
*
libfoo.so libfoo.so.orig libfoo.so.cfi libdude.so.
*
foo.cfi dude.exe.cfi
}
report
()
{
total
=
$(
expr
$passes
+
$fails
)
echo
"Passes:
$passes
/
$total
"
echo
"Fails :
$fails
/
$total
"
}
main
()
{
build
protect
get_correct
# test dude.exe libfoo.so.orig libdude.so.orig # unprotected - should pass!
# test dude.exe libfoo.so.cfi libdude.so.orig
# test dude.exe libfoo.so.orig libdude.so.cfi
# test dude.exe.cfi libfoo.so.orig libdude.so.orig
# test dude.exe.cfi libfoo.so.cfi libdude.so.orig
# test dude.exe.cfi libfoo.so.orig libdude.so.cfi
test
dude.exe libfoo.so.cfi libdude.so.cfi
# test dude.exe.cfi libfoo.so.cfi libdude.so.cfi
report
# clean
}
passes
=
0
fails
=
0
main
$*
This diff is collapsed.
Click to expand it.
tests/test_pow.sh
+
1
−
1
View file @
e5b70e3c
...
...
@@ -86,7 +86,7 @@ main()
test
pow.exe libm.so.6.cfi 5 8
# shared lib only
test
pow.exe.cfi libm.so.6.cfi 5 8
# both protected
report
clean
#
clean
}
passes
=
0
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment