Fix configure --as-shared-lib

This commit is contained in:
Andrea Fioraldi 2021-09-13 11:41:54 +02:00
parent a63ffba266
commit 0d92da5d7e
3 changed files with 23 additions and 7 deletions

11
configure vendored
View File

@ -835,6 +835,7 @@ if test "$mingw32" = "yes" ; then
fi fi
werror="" werror=""
as_shared_lib="no"
for opt do for opt do
optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)') optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
@ -1582,9 +1583,9 @@ for opt do
--disable-slirp-smbd) slirp_smbd=no --disable-slirp-smbd) slirp_smbd=no
;; ;;
--as-shared-lib) --as-shared-lib)
QEMU_LDFLAGS="$QEMU_LDFLAGS -shared" as_shared_lib="yes"
QEMU_CFLAGS="QEMU_CFLAGS -fPIC -DAS_SHARED_LIB=1" QEMU_CFLAGS="$QEMU_CFLAGS -fPIC -DAS_SHARED_LIB=1"
QEMU_CXXFLAGS="QEMU_CXXFLAGS -fPIC -DAS_SHARED_LIB=1" QEMU_CXXFLAGS="$QEMU_CXXFLAGS -fPIC -DAS_SHARED_LIB=1"
;; ;;
*) *)
echo "ERROR: unknown option $opt" echo "ERROR: unknown option $opt"
@ -4923,6 +4924,10 @@ if test "$secret_keyring" = "yes" ; then
echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
fi fi
if test "$as_shared_lib" = "yes" ; then
echo "AS_SHARED_LIB=y" >> $config_host_mak
fi
echo "ROMS=$roms" >> $config_host_mak echo "ROMS=$roms" >> $config_host_mak
echo "MAKE=$make" >> $config_host_mak echo "MAKE=$make" >> $config_host_mak
echo "PYTHON=$python" >> $config_host_mak echo "PYTHON=$python" >> $config_host_mak

View File

@ -656,7 +656,7 @@ int libafl_qemu_run(void)
#ifdef AS_SHARED_LIB #ifdef AS_SHARED_LIB
int qemu_user_init(int argc, char **argv, char **envp); int qemu_user_init(int argc, char **argv, char **envp);
__attribute__((section(".init_array"))) static void *ctr = &qemu_user_init; __attribute__((section(".init_array"))) void *_qemu_user_init_ctr = &qemu_user_init;
int qemu_user_init(int argc, char **argv, char **envp) int qemu_user_init(int argc, char **argv, char **envp)
#else #else

View File

@ -2656,15 +2656,26 @@ foreach target : target_dirs
exe_name += '-unsigned' exe_name += '-unsigned'
endif endif
emulator = executable(exe_name, exe['sources'], if 'AS_SHARED_LIB' in config_host
emulator = shared_library(exe_name, exe['sources'],
install: true, install: true,
c_args: c_args, c_args: c_args,
dependencies: arch_deps + deps + exe['dependencies'], dependencies: arch_deps + deps + exe['dependencies'],
objects: lib.extract_all_objects(recursive: true), objects: lib.extract_all_objects(recursive: true),
link_language: link_language, link_language: link_language,
link_depends: [block_syms, qemu_syms] + exe.get('link_depends', []), link_depends: [block_syms, qemu_syms] + exe.get('link_depends', []),
link_args: link_args, link_args: link_args)
gui_app: exe['gui']) else
emulator = executable(exe_name, exe['sources'],
install: true,
c_args: c_args,
dependencies: arch_deps + deps + exe['dependencies'],
objects: lib.extract_all_objects(recursive: true),
link_language: link_language,
link_depends: [block_syms, qemu_syms] + exe.get('link_depends', []),
link_args: link_args,
gui_app: exe['gui'])
endif
if targetos == 'darwin' if targetos == 'darwin'
icon = 'pc-bios/qemu.rsrc' icon = 'pc-bios/qemu.rsrc'