Fix build for libfuzzer_libpng in ubuntu 24 (#2987)
* fix justfile for ubuntu libpng
This commit is contained in:
parent
641db5f19b
commit
a682c36c84
@ -1,117 +1,40 @@
|
||||
import "../../../just/libafl-cc-libpng.just"
|
||||
|
||||
FUZZER_NAME := 'fuzzer_libpng'
|
||||
PROJECT_DIR := absolute_path(".")
|
||||
PROFILE := env("PROFILE", "release")
|
||||
PROFILE_DIR := if PROFILE == "release" { "release" } else if PROFILE == "dev" { "debug" } else { "debug" }
|
||||
CARGO_TARGET_DIR := env("CARGO_TARGET_DIR", "target")
|
||||
FUZZER := PROJECT_DIR / CARGO_TARGET_DIR / PROFILE_DIR / FUZZER_NAME
|
||||
LIBAFL_CC := PROJECT_DIR / CARGO_TARGET_DIR / PROFILE_DIR / "libafl_cc"
|
||||
LIBAFL_CXX := PROJECT_DIR / CARGO_TARGET_DIR / PROFILE_DIR / "libafl_cxx"
|
||||
|
||||
[unix]
|
||||
cc feat:
|
||||
cargo build --profile {{PROFILE}} --features="{{feat}}"
|
||||
|
||||
alias cc := cxx
|
||||
[unix]
|
||||
cxx feat:
|
||||
cargo build --profile {{PROFILE}} --features="{{feat}}"
|
||||
|
||||
[linux]
|
||||
[macos]
|
||||
libpng:
|
||||
#!/bin/bash
|
||||
if [ ! -f v1.6.37.tar.gz ]; then
|
||||
wget https://github.com/glennrp/libpng/archive/refs/tags/v1.6.37.tar.gz
|
||||
fi
|
||||
tar -xvf v1.6.37.tar.gz
|
||||
[unix]
|
||||
lib feat: (libpng feat) (cxx feat)
|
||||
|
||||
[windows]
|
||||
libpng:
|
||||
echo "Unsupported on this platform"
|
||||
# Feat is either nothing or "crash"
|
||||
[unix]
|
||||
fuzzer feat="": (lib feat) (cxx feat)
|
||||
{{LIBAFL_CXX}} {{PROJECT_DIR}}/harness.cc \
|
||||
"{{LIBPNG_BUILD}}/.libs/libpng16.a" \
|
||||
"{{ZLIB_BUILD}}/libz.a" \
|
||||
-I"{{LIBPNG_INCLUDE}}" \
|
||||
-I"{{LIBPNG_BUILD}}" \
|
||||
-I"{{ZLIB_INCLUDE}}" \
|
||||
-L"{{ZLIB_LIB}}" \
|
||||
-o {{FUZZER_NAME}} \
|
||||
-lm -lz
|
||||
|
||||
[linux]
|
||||
[macos]
|
||||
cxx:
|
||||
cargo build --profile {{PROFILE}}
|
||||
|
||||
[windows]
|
||||
cxx:
|
||||
echo "Unsupported on this platform"
|
||||
|
||||
[linux]
|
||||
[macos]
|
||||
crash_cxx:
|
||||
cargo build --profile {{PROFILE}} --features=crash
|
||||
|
||||
[windows]
|
||||
crash_cxx:
|
||||
echo "Unsupported on this platform"
|
||||
|
||||
[linux]
|
||||
[macos]
|
||||
lib: libpng cxx
|
||||
#!/bin/bash
|
||||
cd libpng-1.6.37 && ./configure --enable-shared=no --with-pic=yes --enable-hardware-optimizations=yes
|
||||
cd {{PROJECT_DIR}}
|
||||
make -C libpng-1.6.37 CC="{{LIBAFL_CC}}" CXX="{{LIBAFL_CXX}}"
|
||||
|
||||
[windows]
|
||||
lib:
|
||||
echo "Unsupported on this platform"
|
||||
|
||||
[linux]
|
||||
[macos]
|
||||
crash_lib: libpng crash_cxx
|
||||
#!/bin/bash
|
||||
cd libpng-1.6.37 && ./configure --enable-shared=no --with-pic=yes --enable-hardware-optimizations=yes
|
||||
cd {{PROJECT_DIR}}
|
||||
make -C libpng-1.6.37 CC="{{LIBAFL_CC}}" CXX="{{LIBAFL_CXX}}"
|
||||
|
||||
[windows]
|
||||
crash_lib:
|
||||
echo "Unsupported on this platform"
|
||||
|
||||
[linux]
|
||||
[macos]
|
||||
fuzzer: lib cxx
|
||||
pwd
|
||||
{{LIBAFL_CXX}} {{PROJECT_DIR}}/harness.cc {{PROJECT_DIR}}/libpng-1.6.37/.libs/libpng16.a -I {{PROJECT_DIR}}/libpng-1.6.37/ -o {{FUZZER_NAME}} -lm -lz
|
||||
|
||||
[windows]
|
||||
fuzzer:
|
||||
echo "Unsupported on this platform"
|
||||
|
||||
[linux]
|
||||
[macos]
|
||||
crash_fuzzer: crash_lib crash_cxx
|
||||
{{LIBAFL_CXX}} {{PROJECT_DIR}}/harness.cc {{PROJECT_DIR}}/libpng-1.6.37/.libs/libpng16.a -I {{PROJECT_DIR}}/libpng-1.6.37/ -o {{FUZZER_NAME}} -lm -lz
|
||||
|
||||
[windows]
|
||||
crash_fuzzer:
|
||||
echo "Unsupported on this platform"
|
||||
|
||||
|
||||
[linux]
|
||||
[macos]
|
||||
run: fuzzer
|
||||
# Feat is either nothing or "crash"
|
||||
[unix]
|
||||
run feat="": (fuzzer feat)
|
||||
#!/bin/bash
|
||||
./{{FUZZER_NAME}} &
|
||||
sleep 0.2
|
||||
./{{FUZZER_NAME}} 2>/dev/null
|
||||
|
||||
[windows]
|
||||
run: fuzzer
|
||||
echo "Unsupported on this platform"
|
||||
|
||||
[linux]
|
||||
[macos]
|
||||
crash: crash_fuzzer
|
||||
#!/bin/bash
|
||||
./{{FUZZER_NAME}} &
|
||||
sleep 0.2
|
||||
./{{FUZZER_NAME}} 2>/dev/null
|
||||
|
||||
[windows]
|
||||
crash: fuzzer
|
||||
echo "Unsupported on this platform"
|
||||
|
||||
|
||||
[linux]
|
||||
[macos]
|
||||
[unix]
|
||||
test: fuzzer
|
||||
#!/bin/bash
|
||||
rm -rf libafl_unix_shmem_server || true
|
||||
@ -125,12 +48,7 @@ test: fuzzer
|
||||
exit 1
|
||||
fi
|
||||
|
||||
[windows]
|
||||
test: fuzzer
|
||||
echo "Unsupported on this platform"
|
||||
|
||||
clean:
|
||||
rm -rf {{FUZZER_NAME}}
|
||||
make -C libpng-1.6.37 clean || true
|
||||
cargo clean
|
||||
|
||||
|
60
just/libafl-cc-libpng.just
Normal file
60
just/libafl-cc-libpng.just
Normal file
@ -0,0 +1,60 @@
|
||||
import "libafl-cc.just"
|
||||
|
||||
OPTIMIZATIONS := env("OPTIMIZATIONS", "yes")
|
||||
|
||||
LIBPNG_ROOT := DEPS_DIR / "libpng-1.6.37"
|
||||
LIBPNG_BUILD := TARGET_DIR / "build-png"
|
||||
LIBPNG_INCLUDE := LIBPNG_ROOT
|
||||
|
||||
ZLIB_ROOT := DEPS_DIR / "zlib-1.2.13"
|
||||
ZLIB_BUILD := TARGET_DIR / "build-zlib"
|
||||
ZLIB_INCLUDE := ZLIB_BUILD / "zlib" / "include"
|
||||
ZLIB_LIB := ZLIB_BUILD / "zlib" / "lib"
|
||||
|
||||
DEPS_DIR := TARGET_DIR / "deps"
|
||||
|
||||
[unix]
|
||||
target_dir:
|
||||
mkdir -p {{ TARGET_DIR }}
|
||||
|
||||
[unix]
|
||||
deps_dir:
|
||||
mkdir -p {{ DEPS_DIR }}
|
||||
|
||||
[unix]
|
||||
zlib_wget: deps_dir
|
||||
wget -O "{{ DEPS_DIR }}/zlib-1.2.13.tar.gz" https://zlib.net/fossils/zlib-1.2.13.tar.gz
|
||||
|
||||
tar zxvf {{ DEPS_DIR }}/zlib-1.2.13.tar.gz -C {{ DEPS_DIR }}
|
||||
|
||||
[unix]
|
||||
zlib feat: zlib_wget (cc feat)
|
||||
rm -rf {{ ZLIB_BUILD }}
|
||||
mkdir {{ ZLIB_BUILD }}
|
||||
|
||||
cd {{ ZLIB_BUILD }} && CC={{ LIBAFL_CC }} {{ ZLIB_ROOT }}/configure --prefix=./zlib
|
||||
|
||||
make -j -C {{ ZLIB_BUILD }} install
|
||||
|
||||
[unix]
|
||||
libpng_wget: deps_dir
|
||||
wget -O "{{ DEPS_DIR }}/v1.6.37.tar.gz" https://github.com/glennrp/libpng/archive/refs/tags/v1.6.37.tar.gz
|
||||
|
||||
tar -xvf "{{ DEPS_DIR }}/v1.6.37.tar.gz" -C {{ DEPS_DIR }}
|
||||
|
||||
rm -rf {{ LIBPNG_BUILD }}
|
||||
mkdir {{ LIBPNG_BUILD }}
|
||||
|
||||
[unix]
|
||||
libpng feat: (zlib feat) libpng_wget (cc feat)
|
||||
cd {{ LIBPNG_BUILD }}/ && \
|
||||
CC="{{LIBAFL_CC}}" \
|
||||
CFLAGS="-I{{ ZLIB_INCLUDE }}" \
|
||||
CPPFLAGS="-I{{ ZLIB_INCLUDE }}" \
|
||||
LDFLAGS="-L{{ ZLIB_LIB }}" \
|
||||
{{ DEPS_DIR }}/libpng-1.6.37/configure \
|
||||
--enable-shared=no \
|
||||
--with-pic=yes \
|
||||
--enable-hardware-optimizations={{ OPTIMIZATIONS }}
|
||||
|
||||
make -j -C {{ LIBPNG_BUILD }}
|
4
just/libafl-cc.just
Normal file
4
just/libafl-cc.just
Normal file
@ -0,0 +1,4 @@
|
||||
import "libafl.just"
|
||||
|
||||
LIBAFL_CC := BUILD_DIR / "libafl_cc"
|
||||
LIBAFL_CXX := BUILD_DIR / "libafl_cxx"
|
@ -79,6 +79,6 @@ libpng: arch_dir zlib libpng_wget
|
||||
--enable-shared=no \
|
||||
--with-pic=yes \
|
||||
--enable-hardware-optimizations={{ OPTIMIZATIONS }} \
|
||||
--host={{ ARCH }} \
|
||||
--host={{ ARCH }}
|
||||
|
||||
make -j -C {{ TARGET_DIR }}/build-png/
|
@ -12,11 +12,13 @@
|
||||
# - `FUZZER`: Executable path.
|
||||
|
||||
PROFILE := env("PROFILE", "release")
|
||||
FUZZER_EXTENSION := if os_family() == "windows" { ".exe" } else { "" }
|
||||
FUZZER := BUILD_DIR / FUZZER_NAME + FUZZER_EXTENSION
|
||||
|
||||
PROJECT_DIR := absolute_path(".")
|
||||
PROFILE_DIR := if PROFILE == "dev" { "debug" } else { "release" }
|
||||
TARGET_DIR := absolute_path(env("TARGET_DIR", "target"))
|
||||
BUILD_DIR := TARGET_DIR / PROFILE_DIR
|
||||
FUZZER_EXTENSION := if os_family() == "windows" { ".exe" } else { "" }
|
||||
FUZZER := BUILD_DIR / FUZZER_NAME + FUZZER_EXTENSION
|
||||
|
||||
JUSTHASHES := ".justhashes"
|
||||
|
||||
|
@ -272,8 +272,7 @@ void __afl_start_forkserver(void) {
|
||||
uint32_t len = (__token_stop - __token_start), offset = 0;
|
||||
|
||||
if (write(FORKSRV_FD + 1, &len, 4) != 4) {
|
||||
write(2, "Error: could not send autotokens len\n",
|
||||
strlen("Error: could not send autotokens len\n"));
|
||||
fprintf(stderr, "Error: could not send autotokens len\n");
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user