Under normal situation, the linker throws out all symbols from
compilation unit when no symbols are used in the final binary, which is
the case for lib/isc/lib.c. This commit adds empty function to lib.c
that's being called from different CU (mem.c in this case) and that
makes the linker to include all the symbols including the normally
unreferenced isc__initialize() and isc__shutdown() in the final binary.
* information regarding copyright ownership.
*/
-#ifndef ISC_LIB_H
-#define ISC_LIB_H 1
+#pragma once
/*! \file isc/lib.h */
* function very early in main().
*/
-ISC_LANG_ENDDECLS
+extern void
+isc_enable_constructors(void);
+/*!<
+ * \bried Enable constructor linkage in non-libtool static builds
+ */
-#endif /* ISC_LIB_H */
+ISC_LANG_ENDDECLS
isc__tls_shutdown();
isc__mem_shutdown();
}
+
+/*
+ * This is a workaround for situation when libisc is statically linked. Under
+ * normal situation, the linker throws out all symbols from compilation unit
+ * when no symbols are used in the final binary. This empty function must be
+ * called at least once from different compilation unit (mem.c in this case).
+ */
+void
+isc_enable_constructors() {
+ /* do nothing */
+}
#include <isc/bind9.h>
#include <isc/hash.h>
+#include <isc/lib.h>
#include <isc/magic.h>
#include <isc/mem.h>
#include <isc/mutex.h>
isc__mem_t *ctx;
+ isc_enable_constructors();
+
STATIC_ASSERT((ALIGNMENT_SIZE & (ALIGNMENT_SIZE - 1)) == 0,
"wrong alignment size");
isc_dir_open
isc_dir_read
isc_dir_reset
+isc_enable_constructors
isc_entropy_get
isc_errno_toresult
isc_error_fatal