diff options
author | Alexander Bulekov <alxndr@bu.edu> | 2020-10-23 11:07:34 -0400 |
---|---|---|
committer | Thomas Huth <thuth@redhat.com> | 2020-10-26 09:53:53 +0100 |
commit | e7d3222e2e07e2a1a0aac979ef1fa5e8ef59f02c (patch) | |
tree | 6a7bcc1a5835fd09fec53a5de1b14c4638e54eb7 /softmmu | |
parent | 20f5a3029386363357e6fa0c2e82b35ac4914d6a (diff) |
fuzz: Declare DMA Read callback function
This patch declares the fuzz_dma_read_cb function and uses the
preprocessor and linker(weak symbols) to handle these cases:
When we build softmmu/all with --enable-fuzzing, there should be no
strong symbol defined for fuzz_dma_read_cb, and we link against a weak
stub function.
When we build softmmu/fuzz with --enable-fuzzing, we link against the
strong symbol in generic_fuzz.c
When we build softmmu/all without --enable-fuzzing, fuzz_dma_read_cb is
an empty, inlined function. As long as we don't call any other functions
when building the arguments, there should be no overhead.
Signed-off-by: Alexander Bulekov <alxndr@bu.edu>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Message-Id: <20201023150746.107063-6-alxndr@bu.edu>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'softmmu')
-rw-r--r-- | softmmu/memory.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/softmmu/memory.c b/softmmu/memory.c index a5d1641820..cec0e0f743 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -3246,6 +3246,19 @@ void memory_region_init_rom_device(MemoryRegion *mr, vmstate_register_ram(mr, owner_dev); } +/* + * Support softmmu builds with CONFIG_FUZZ using a weak symbol and a stub for + * the fuzz_dma_read_cb callback + */ +#ifdef CONFIG_FUZZ +void __attribute__((weak)) fuzz_dma_read_cb(size_t addr, + size_t len, + MemoryRegion *mr, + bool is_write) +{ +} +#endif + static const TypeInfo memory_region_info = { .parent = TYPE_OBJECT, .name = TYPE_MEMORY_REGION, |