Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Commits on Source (3)
src/build
*.so.*
*.osAI
*.osNAI
*.so
.sconsign.dblite
1
libzafl is the runtime components needed to use an AFL-compatible fuzzer with a zafl-transformed binary.
PREREQS
-------
SCons
GCC
dpkg
BUILDING
-------
% scons
INSTALLING
----------
The builder should create a .deb file, which can be installed like so:
% sudo dpkg -i libzafl_1-2019.01.18_amd64.deb
This should install /usr/lib/libzafl.so and /usr/libautozafl.so.
......@@ -16,10 +16,9 @@ else:
env.Append(CXXFLAGS=" -O3 ")
env.Append(LINKFLAGS=" -O3 ")
if int(env['autozafl']) == 1:
print "Build lib for autozafl"
env.Append(CXXFLAGS = " -DZAFL_AUTO_INIT_FORK_SERVER ")
lib=SConscript("src/SConscript")
deb=SConscript("deb/SConscript")
all=deb+lib
Return('lib')
Return('all')
import os, shutil, sys, subprocess, datetime
Import('env') # exported by parent SConstruct
# I wanted to base the debian version number partly on the
# revision checked out from our SVN repository.
# Skip this if it's not relevant to you.
minor_version = datetime.datetime.today().strftime('%Y.%m.%d')
# Here's the core info for the package
DEBNAME = "libzafl"
p=subprocess.Popen(["cat", "../MAJOR_VERSION"], stdout=subprocess.PIPE)
DEBVERSION = p.stdout.read().rstrip()
p.wait()
print 'DEBVERSION=' + DEBVERSION
DEBMAINT = "jdh8d@gmail.com"
p=subprocess.Popen('/usr/bin/dpkg-architecture --list|grep DEB_HOST_ARCH=|sed \"s/.*=//\"', shell=True, stdout=subprocess.PIPE)
DEBARCH = p.stdout.read().rstrip()
p.wait()
print 'DEBARCH=' + DEBARCH
DEBDEPENDS = "libc6 "
DEBDESC = "A really cool utility"
DEBFILES = [
# Now we specify the files to be included in the .deb
# Where they should go, and where they should be copied from.
# If you have a lot of files, you may wish to generate this
# list in some other way.
("usr/lib/libzafl.so", "#lib/libzafl.so"),
("usr/lib/libautozafl.so", "#lib/libautozafl.so"),
]
# This is the debian package we're going to create
debpkg = '#%s_%s-%s_%s.deb' % (DEBNAME, DEBVERSION, minor_version, DEBARCH)
# and we want it to be built when we build 'debian'
env.Alias("debian", debpkg)
DEBCONTROLFILE = os.path.join(DEBNAME, "DEBIAN/control")
# This copies the necessary files into place into place.
# Fortunately, SCons creates the necessary directories for us.
for f in DEBFILES:
# We put things in a directory named after the package
dest = os.path.join(DEBNAME, f[0])
# The .deb package will depend on this file
env.Depends(debpkg, dest)
# Copy from the the source tree.
env.Command(dest, f[1], Copy('$TARGET','$SOURCE'))
# The control file also depends on each source because we'd like
# to know the total installed size of the package
env.Depends(DEBCONTROLFILE, dest)
# Now to create the control file:
CONTROL_TEMPLATE = """
Package: %s
Priority: extra
Section: misc
Installed-Size: %s
Maintainer: %s
Architecture: %s
Version: %s-%s
Depends: %s
Description: %s
"""
env.Depends(debpkg,DEBCONTROLFILE )
# The control file should be updated when the minor_version changes
env.Depends(DEBCONTROLFILE, env.Value(minor_version))
# This function creates the control file from the template and info
# specified above, and works out the final size of the package.
def make_control(target=None, source=None, env=None):
installed_size = 0
for i in DEBFILES:
print 'in make_control with i='+str(i)
print 'in make_control with env.File(i[1])='+str(env.File(i[1]))
installed_size += os.stat(str(env.File(i[1])))[6]
control_info = CONTROL_TEMPLATE % (
DEBNAME, installed_size, DEBMAINT, DEBARCH, DEBVERSION,
minor_version, DEBDEPENDS, DEBDESC)
f = open(str(target[0]), 'w')
f.write(control_info)
f.close()
# We can generate the control file by calling make_control
env.Command(DEBCONTROLFILE, None, make_control)
# And we can generate the .deb file by calling dpkg-deb
deb=env.Command(debpkg, DEBCONTROLFILE,
"fakeroot dpkg-deb -b %s %s" % ("deb/%s" % DEBNAME, "$TARGET"))
Default(deb)
Return('deb')
......@@ -12,14 +12,18 @@ cpath='''
../include/
'''
myenv=myenv.Clone(CPPPATH=Split(cpath))
if int(env['autozafl']) == 1:
lib=myenv.SharedLibrary("autozafl", Split(files))
else:
lib=myenv.SharedLibrary("zafl", Split(files))
autozaflenv=myenv.Clone()
autozaflenv.Append(CFLAGS=" -DZAFL_AUTO_INIT_FORK_SERVER ")
autozaflenv.Replace(SHOBJSUFFIX=".osAI")
lib1=autozaflenv.SharedLibrary("autozafl", Split(files))
install1=autozaflenv.Install("../lib/", lib1)
install=myenv.Install("$ZEST_RUNTIME/lib64/", lib)
myenv.Replace(SHOBJSUFFIX=".osNAI")
lib2=myenv.SharedLibrary("zafl", Split(files))
install2=myenv.Install("../lib/", lib2)
install=install1+install2
Default(install)
......