[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC 48/48] plugin: add a couple of very simple example
From: |
Roman Bolshakov |
Subject: |
Re: [Qemu-devel] [RFC 48/48] plugin: add a couple of very simple examples |
Date: |
Thu, 29 Nov 2018 23:45:18 +0300 |
User-agent: |
NeoMutt/20180716 |
On Thu, Oct 25, 2018 at 01:20:57PM -0400, Emilio G. Cota wrote:
> +
> +lib%.so: %.o
> + $(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDLIBS)
The rule should be a bit different for macOS:
%.bundle: %.o
$(CC) -bundle -Wl,-bundle_loader,PATH_TO_QEMU_EXE -o $@ $^ $(LDLIBS)
"-bundle" flag is needed because macOS has two kinds of Mach-O
dynamically loaded executables:
- dylib (MH_DYLIB) - it's like an ELF shared object used for dynamic
linking. Can be loaded, preloaded for sake of function interposing
but cannot be explicitly unloaded.
- bundle (MH_BUNDLE) - similar to an ELF shared object used in plugin
dlopen/dlclose scenario.
We can pick any (enabled in configure) qemu-system executable as
bundle_loader. We specify it to check if all symbols in a bundle,
including the ones coming from the executable are defined. FWIW, here's
the reference for bundle_loader flag:
-bundle_loader executable
This specifies the executable that will be loading the bundle
output file being linked. Undefined symbols from the bundle are
checked against the specified executable like it was one of the
dynamic libraries the bundle was linked with
The ".bundle" extension is not required but IMO it feels more native to
the system than ".so".
I've checked both plugins can be loaded and print a line when QEMU exits.
Best regards,
Roman