binutils: align fuzzers with upstream (#7527)

* binutils: align fuzzers with upstream

Upstream changed init_disassemble_info

Ref:
60a3da00bd

* provide actual styled print function
This commit is contained in:
DavidKorczynski 2022-04-07 14:49:18 +01:00 committed by GitHub
parent 781b777e4b
commit 9349178c2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 2 deletions

View File

@ -34,6 +34,15 @@ typedef struct
size_t pos;
} SFILE;
static int
fuzz_disasm_null_styled_printf (void *stream,
enum disassembler_style style,
const char *format, ...)
{
return 0;
}
static int objdump_sprintf (void *vf, const char *format, ...)
{
SFILE *f = (SFILE *) vf;
@ -65,7 +74,7 @@ disassemble_architecture(int arch, const uint8_t *Data, size_t Size, int big) {
struct disassemble_info disasm_info;
SFILE s;
init_disassemble_info (&disasm_info, stdout, (fprintf_ftype) fprintf);
init_disassemble_info (&disasm_info, stdout, (fprintf_ftype) fprintf, fuzz_disasm_null_styled_printf);
disasm_info.fprintf_func = objdump_sprintf;
disasm_info.print_address_func = generic_print_address;
disasm_info.display_endian = disasm_info.endian = BFD_ENDIAN_LITTLE;
@ -74,6 +83,7 @@ disassemble_architecture(int arch, const uint8_t *Data, size_t Size, int big) {
disasm_info.buffer_length = Size-10;
disasm_info.insn_info_valid = 0;
disasm_info.disassembler_options = options;
disasm_info.created_styled_output = false;
if (arch == bfd_arch_arm) {
disasm_info.private_data = private_data;

View File

@ -28,6 +28,14 @@ typedef struct
size_t pos;
} SFILE;
static int
fuzz_disasm_null_styled_printf (void *stream,
enum disassembler_style style,
const char *format, ...)
{
return 0;
}
static int objdump_sprintf (void *vf, const char *format, ...)
{
SFILE *f = (SFILE *) vf;
@ -60,7 +68,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
return 0;
}
init_disassemble_info (&disasm_info, stdout, (fprintf_ftype) fprintf);
init_disassemble_info (&disasm_info, stdout, (fprintf_ftype) fprintf, fuzz_disasm_null_styled_printf);
disasm_info.fprintf_func = objdump_sprintf;
disasm_info.print_address_func = generic_print_address;
disasm_info.display_endian = disasm_info.endian = BFD_ENDIAN_LITTLE;
@ -68,6 +76,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
disasm_info.buffer_vma = 0x1000;
disasm_info.buffer_length = Size-10;
disasm_info.insn_info_valid = 0;
disasm_info.created_styled_output = false;
s.buffer = AssemblyText;
s.pos = 0;
disasm_info.stream = &s;