From c43ceb8a3434db8021f2f265cc55c94610e1d01a Mon Sep 17 00:00:00 2001 From: junkzours Date: Fri, 21 Feb 2025 03:53:24 -0500 Subject: [PATCH] Change the definition of shemu_printf so that unused parameters are removed from the compiled binary (#111) * Change the definition of shemu_printf so that unused parameters (strings etc.) are removed from the compiled binary * Syntax fix * Fix the implementation of shemu_internal_printf * Replace NULL by ND_NULL in the invocation of shemu_internal_printf --- bdshemu/bdshemu.c | 6 +++--- bdshemu/include/bdshemu_common.h | 8 +++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/bdshemu/bdshemu.c b/bdshemu/bdshemu.c index a26852f..346ff9a 100644 --- a/bdshemu/bdshemu.c +++ b/bdshemu/bdshemu.c @@ -12,11 +12,11 @@ // -// shemu_printf - simple version +// shemu_internal_printf - simple version // #ifndef BDDISASM_NO_FORMAT void -shemu_printf( +shemu_internal_printf( SHEMU_CONTEXT *Context, char *formatstring, ... @@ -41,7 +41,7 @@ shemu_printf( } #else void -shemu_printf( +shemu_internal_printf( SHEMU_CONTEXT *Context, char *formatstring, ... diff --git a/bdshemu/include/bdshemu_common.h b/bdshemu/include/bdshemu_common.h index 15564bd..ad48a57 100644 --- a/bdshemu/include/bdshemu_common.h +++ b/bdshemu/include/bdshemu_common.h @@ -12,6 +12,12 @@ #endif +#ifndef BDDISASM_NO_FORMAT +#define shemu_printf(Context, formatstring, ...) shemu_internal_printf(Context, formatstring, __VA_ARGS__) +#else +#define shemu_printf(Context, formatstring, ...) do { (void)formatstring; shemu_internal_printf(Context, ND_NULL, __VA_ARGS__); } while (0) +#endif + // The SHELLBMP and STACKBMP are two bitmaps which hold the state of each shellcode byte and each stack byte. // Inside SHELLBMP, we store whether a shellcode byte has been fetched for execution or not, and whether it was // modified or not. @@ -65,7 +71,7 @@ void -shemu_printf( +shemu_internal_printf( SHEMU_CONTEXT *Context, char *formatstring, ...