@@ -0,0 +1,76 @@
|
||||
From ebb6050a70852a1afdedbe45e6fca7ffd4b15350 Mon Sep 17 00:00:00 2001
|
||||
From: Robert Swiecki <robert@swiecki.net>
|
||||
Date: Mon, 6 Jun 2022 18:01:41 +0200
|
||||
Subject: [PATCH] linux/bfd: use DIAGNOSTIC_ERROR_SWITCH define to figure out
|
||||
if init_disassemble_info takes 3 or 4 arguments
|
||||
|
||||
(cherry picked from commit 90fdf81006614664ef05e5e3c6f94d91610f11b2)
|
||||
---
|
||||
linux/bfd.c | 29 +++++++++++++++++++++++++++--
|
||||
1 file changed, 27 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/linux/bfd.c b/linux/bfd.c
|
||||
index 69f4da59..3494a7e6 100644
|
||||
--- a/linux/bfd.c
|
||||
+++ b/linux/bfd.c
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "linux/bfd.h"
|
||||
|
||||
#include <bfd.h>
|
||||
+#include <diagnostics.h>
|
||||
#include <dis-asm.h>
|
||||
#include <inttypes.h>
|
||||
#include <pthread.h>
|
||||
@@ -61,7 +62,15 @@ typedef struct {
|
||||
*/
|
||||
#if defined(FOR_EACH_DISASSEMBLER_OPTION)
|
||||
#define _HF_BFD_GE_2_29
|
||||
-#endif
|
||||
+#endif /* defined(FOR_EACH_DISASSEMBLER_OPTION) */
|
||||
+/*
|
||||
+ * binutils/libopcode has an unstable public interface. At some point in time the function
|
||||
+ * init_disassemble_info() started taking 4 arguments instead of 3. Try to differentiate on the
|
||||
+ * basis of some defines which apeared around the same time.
|
||||
+ */
|
||||
+#if defined(DIAGNOSTIC_ERROR_SWITCH)
|
||||
+#define _HF_DISASM_4_ARGS
|
||||
+#endif /* defined(DIAGNOSTIC_ERROR_SWITCH) */
|
||||
|
||||
static pthread_mutex_t arch_bfd_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
@@ -197,6 +206,18 @@ static int arch_bfdFPrintF(void* buf, const char* fmt, ...) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
+#if defined(_HF_DISASM_4_ARGS)
|
||||
+static int arch_bfdFPrintFStyled(
|
||||
+ void* buf, enum disassembler_style style HF_ATTR_UNUSED, const char* fmt, ...) {
|
||||
+ va_list args;
|
||||
+ va_start(args, fmt);
|
||||
+ int ret = util_vssnprintf(buf, _HF_INSTR_SZ, fmt, args);
|
||||
+ va_end(args);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+#endif /* defined(_HF_DISASM_4_ARGS) */
|
||||
+
|
||||
void arch_bfdDisasm(pid_t pid, uint8_t* mem, size_t size, char* instr) {
|
||||
MX_SCOPED_LOCK(&arch_bfd_mutex);
|
||||
|
||||
@@ -227,8 +248,12 @@ void arch_bfdDisasm(pid_t pid, uint8_t* mem, size_t size, char* instr) {
|
||||
return;
|
||||
}
|
||||
|
||||
- struct disassemble_info info;
|
||||
+ struct disassemble_info info = {};
|
||||
+#if defined(_HF_DISASM_4_ARGS)
|
||||
+ init_disassemble_info(&info, instr, arch_bfdFPrintF, arch_bfdFPrintFStyled);
|
||||
+#else /* defined(_HF_DISASM_4_ARGS) */
|
||||
init_disassemble_info(&info, instr, arch_bfdFPrintF);
|
||||
+#endif /* defined(_HF_DISASM_4_ARGS) */
|
||||
info.arch = bfd_get_arch(bfdh);
|
||||
info.mach = bfd_get_mach(bfdh);
|
||||
info.buffer = mem;
|
||||
--
|
||||
2.37.3
|
||||
|
||||
9
hello.c
Normal file
9
hello.c
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
printf ("hello, world\n");
|
||||
return 0;
|
||||
}
|
||||
116
honggfuzz.spec
Normal file
116
honggfuzz.spec
Normal file
@@ -0,0 +1,116 @@
|
||||
# SPDX-FileCopyrightText: (C) 2026 Institute of Software, Chinese Academy of Sciences (ISCAS)
|
||||
# SPDX-FileCopyrightText: (C) 2026 openRuyi Project Contributors
|
||||
# SPDX-FileContributor: Jvle <keke.oerv@isrc.iscas.ac.cn>
|
||||
#
|
||||
# SPDX-License-Identifier: MulanPSL-2.0
|
||||
|
||||
%global srcname honggfuzz
|
||||
|
||||
Name: %{srcname}
|
||||
Version: 2.5
|
||||
Release: %autorelease
|
||||
Summary: General-purpose, easy-to-use fuzzer
|
||||
License: ASL 2.0
|
||||
URL: https://honggfuzz.dev/
|
||||
VCS: git:https://github.com/google/honggfuzz
|
||||
#!RemoteAsset: sha256:0bac9de876f1ea60903672c944d82bcd5ce4bc25769a2e1ecee5159561b9ec03
|
||||
Source0: https://github.com/google/honggfuzz/archive/refs/tags/%{version}.tar.gz
|
||||
# Used for sanity-check in %%check section.
|
||||
Source1: hello.c
|
||||
|
||||
Patch0: 0001-linux-bfd-use-DIAGNOSTIC_ERROR_SWITCH-define-to-figu.patch
|
||||
|
||||
BuildRequires: gcc
|
||||
BuildRequires: gcc-c++
|
||||
BuildRequires: binutils-devel
|
||||
BuildRequires: libunwind-devel
|
||||
# This package currently links with lzma but does not require it.
|
||||
# However we have to keep this BR at the moment until upstream remove
|
||||
# the link (or edit Makefile). See also:
|
||||
# https://github.com/google/honggfuzz/issues/332
|
||||
BuildRequires: xz-devel
|
||||
BuildRequires: make
|
||||
BuildRequires: zlib-devel
|
||||
|
||||
Requires: gcc
|
||||
Requires: gcc-c++
|
||||
# Unfortunately it fails unless exactly the same version of clang &
|
||||
# compiler-rt are installed, but that's a bug in clang not in this
|
||||
# package.
|
||||
Requires: clang
|
||||
Requires: compiler-rt
|
||||
|
||||
%description
|
||||
Honggfuzz is a general-purpose fuzzing tool. Given an input corpus
|
||||
files, honggfuzz modifies input to a test program and utilize the
|
||||
ptrace() API/POSIX signal interface to detect and log crashes. It
|
||||
can also use software or hardware-based code coverage techniques
|
||||
to produce more and more interesting inputs.
|
||||
|
||||
%package devel
|
||||
Summary: Development files for %{srcname}
|
||||
Requires: %{srcname}%{?_isa} = %{version}-%{release}
|
||||
|
||||
%description devel
|
||||
Development files for %{srcname}.
|
||||
|
||||
%prep
|
||||
# Disable LTO since it breaks linking.
|
||||
%define _lto_cflags %{nil}
|
||||
%autosetup -p1
|
||||
# The source contains proprietary binary blobs. We remove the entire
|
||||
# third_party/ subdirectory when repackaging this:
|
||||
# reference: https://koji.fedoraproject.org/koji/buildinfo?buildID=2494915
|
||||
rm -rf third_party
|
||||
|
||||
%build
|
||||
# Upstream removes -D_FORTIFY_SOURCE claiming that "fortify-source
|
||||
# intercepts some functions", so we also remove it here.
|
||||
%undefine _fortify_level
|
||||
%make_build
|
||||
|
||||
%install
|
||||
mkdir -p $RPM_BUILD_ROOT/%{_bindir}
|
||||
mkdir -p $RPM_BUILD_ROOT/%{_includedir}
|
||||
make install PREFIX=%{_prefix} DESTDIR=$RPM_BUILD_ROOT
|
||||
|
||||
# The rule above doesn't preserve links in the installed binaries.
|
||||
# Recreate them here.
|
||||
pushd $RPM_BUILD_ROOT%{_bindir}
|
||||
for f in hfuzz-clang hfuzz-clang++ hfuzz-g++ hfuzz-gcc; do
|
||||
rm $f
|
||||
ln hfuzz-cc $f
|
||||
done
|
||||
popd
|
||||
|
||||
# Make sure the include files aren't chmod +x.
|
||||
find $RPM_BUILD_ROOT%{_includedir} -type f -exec chmod -x {} \;
|
||||
|
||||
%check
|
||||
# This checks that a simple program can be compiled using the GCC
|
||||
# wrappers.
|
||||
ln -s %{SOURCE1} hello.c
|
||||
ln -s %{SOURCE1} hello.cpp
|
||||
hfuzz_cc/hfuzz-gcc hello.c -o hello
|
||||
./hello
|
||||
hfuzz_cc/hfuzz-g++ hello.cpp -o hello
|
||||
./hello
|
||||
|
||||
%files
|
||||
%license COPYING
|
||||
%{_bindir}/honggfuzz
|
||||
%{_bindir}/hfuzz-cc
|
||||
%{_bindir}/hfuzz-clang
|
||||
%{_bindir}/hfuzz-clang++
|
||||
%{_bindir}/hfuzz-g++
|
||||
%{_bindir}/hfuzz-gcc
|
||||
|
||||
%files devel
|
||||
%license COPYING
|
||||
%doc CHANGELOG README.md CONTRIBUTING.md docs/
|
||||
%{_includedir}/libhfcommon
|
||||
%{_includedir}/libhfuzz
|
||||
%{_includedir}/libhnetdriver
|
||||
|
||||
%changelog
|
||||
%{?autochangelog}
|
||||
Reference in New Issue
Block a user