diff options
author | Michael Brown <mcb30@ipxe.org> | 2021-03-11 15:08:57 +0000 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2021-03-11 15:25:33 +0000 |
commit | 7c8fc2cae8769fff7d9fe8af3cef046995a3fd3e (patch) | |
tree | 5055737598f38d1d56ce1b8e49a4a269e257f3ea | |
parent | 65bd5c05db2a050a4c0f26ccc0b1e9828b00abbf (diff) | |
download | ipxe-7c8fc2cae8769fff7d9fe8af3cef046995a3fd3e.tar.gz |
[linux] Fail at link time if building slirp.linux without libslirp
The iPXE build system is constructed for a standalone codebase with no
external dependencies, and does not have any equivalent of the
standard userspace ./configure script. We currently check for the
ability to include slirp/libslirp.h and conditionalise portions of
linux_api.c on its presence. The actual slirp driver code is built
unconditionally, as with all iPXE drivers.
This currently leads to a silent runtime failure if attempting to use
slirp.linux built on a system that was missing slirp/libslirp.h.
Convert this to a link-time failure by deliberately omitting the
relevant symbols from linux_api.c when slirp/libslirp.h is not
present. This allows other builds (e.g. tap.linux or tests.linux) to
succeed: the link-time failure will occur only if the slirp driver is
included within the build target.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r-- | src/interface/linux/linux_api.c | 32 |
1 files changed, 3 insertions, 29 deletions
diff --git a/src/interface/linux/linux_api.c b/src/interface/linux/linux_api.c index d1f969aa7..21024ede1 100644 --- a/src/interface/linux/linux_api.c +++ b/src/interface/linux/linux_api.c @@ -486,35 +486,6 @@ linux_slirp_pollfds_poll ( struct Slirp *slirp, int select_error, slirp_pollfds_poll ( slirp, select_error, get_revents, opaque ); } -#else /* HAVE_LIBSLIRP */ - -struct Slirp * __asmcall -linux_slirp_new ( const struct slirp_config *config, - const struct slirp_callbacks *callbacks, void *opaque ) { - return NULL; -} - -void __asmcall linux_slirp_cleanup ( struct Slirp *slirp ) { -} - -void __asmcall linux_slirp_input ( struct Slirp *slirp, const uint8_t *pkt, - int pkt_len ) { -} - -void __asmcall -linux_slirp_pollfds_fill ( struct Slirp *slirp, uint32_t *timeout, - int ( __asmcall * add_poll ) ( int fd, int events, - void *opaque ), - void *opaque ) { -} - -void __asmcall -linux_slirp_pollfds_poll ( struct Slirp *slirp, int select_error, - int ( __asmcall * get_revents ) ( int idx, - void *opaque ), - void *opaque ) { -} - #endif /* HAVE_LIBSLIRP */ /****************************************************************************** @@ -544,8 +515,11 @@ PROVIDE_IPXE_SYM ( linux_socket ); PROVIDE_IPXE_SYM ( linux_bind ); PROVIDE_IPXE_SYM ( linux_sendto ); PROVIDE_IPXE_SYM ( linux_strerror ); + +#ifdef HAVE_LIBSLIRP PROVIDE_IPXE_SYM ( linux_slirp_new ); PROVIDE_IPXE_SYM ( linux_slirp_cleanup ); PROVIDE_IPXE_SYM ( linux_slirp_input ); PROVIDE_IPXE_SYM ( linux_slirp_pollfds_fill ); PROVIDE_IPXE_SYM ( linux_slirp_pollfds_poll ); +#endif /* HAVE_LIBSLIRP */ |