Most of the exe name functions can take a const char* for the name.
Indeed, on Linux this is a requirement since we also lookup
debuginfod-find using a const char string literal.
The exception to this rule is for scripts. In this case the script
shebang can refer to another script with another shebang. And so on
until eventually an ELF or macho file is encountered. In that case
VG_(args_the_exename) will get freed if necessary and reassigned
to a new string. So VG_(load_script) needs to be able to take a
non-const char* name, unlike VG_(load_ELF) and VG_(load_macho).
VG_(args_the_exename) is now non-const (which fixes a warning
when freeing it), VG_(load_script) takes a non-const name
and there is an ugly cast for the function pointer.
/* The name of the client executable, as specified on the command
line. */
-const HChar* VG_(args_the_exename) = NULL;
+HChar* VG_(args_the_exename) = NULL;
/* The real name of the executable, with resolved
* relative paths and symlinks */
#include "priv_ume.h"
+typedef Int (*load_function)( Int fd, const HChar *name, ExeInfo *info );
typedef struct {
Bool (*match_fn)(const void *hdr, SizeT len);
# else
# error "unknown OS"
# endif
- { VG_(match_script), VG_(load_script) },
+ { VG_(match_script), (load_function)VG_(load_script) },
};
#define EXE_HANDLER_COUNT (sizeof(exe_handlers)/sizeof(exe_handlers[0]))
#endif
extern Bool VG_(match_script) ( const void *hdr, SizeT len );
-extern Int VG_(load_script) ( Int fd, const HChar *name, ExeInfo *info );
+extern Int VG_(load_script) ( Int fd, HChar *name, ExeInfo *info );
#endif // __PRIV_UME_H
/* returns: 0 = success, non-0 is failure */
-Int VG_(load_script)(Int fd, const HChar* name, ExeInfo* info)
+Int VG_(load_script)(Int fd, HChar* name, ExeInfo* info)
{
HChar hdr[4096];
Int len = sizeof hdr;
/* The name of the client executable, as specified on the command
line. */
-extern const HChar* VG_(args_the_exename);
+extern HChar* VG_(args_the_exename);
extern const HChar* VG_(resolved_exename);