]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix linking problem for #1612
authorMatthijs Mekking <matthijs@isc.org>
Wed, 1 Jul 2020 07:32:08 +0000 (09:32 +0200)
committerMatthijs Mekking <matthijs@isc.org>
Wed, 1 Jul 2020 08:55:30 +0000 (10:55 +0200)
When a library is examined, an object file within it can be left out
of the link if it does not provide symbols that the symbol table
needs.  Introducing `isc_stdtime_tostring` caused a build failure for
`update_test` because it now requires `libisc.a(stdtime.o)` and that
also exports the `isc_stdtime_get` symbol, meaning we have a
multiple definition error.

Add a local version of `isc_stdtime_tostring`, so that the linker
will not search for it in available object files.

lib/dns/tests/update_test.c

index da4b065816d156ed532a4e3d359372851d00b308..6ed64d385c235ff48db976e041ac28b4c1b290e8 100644 (file)
@@ -75,11 +75,34 @@ set_mystdtime(int year, int month, int day) {
        mystdtime = timegm(&tm);
 }
 
+/*
+ * Override isc_stdtime_get() from lib/isc/[unix/win32]/stdtime.c
+ * with our own for testing purposes.
+ */
 void
 isc_stdtime_get(isc_stdtime_t *now) {
        *now = mystdtime;
 }
 
+/*
+ * Because update_test.o requires dns_update_*() symbols, the linker is able
+ * to resolve them using libdns.a(update.o).  That object has other symbol
+ * dependencies (dst_key_*()), so it pulls libdns.a(dst_api.o).
+ * That object file requires the isc_stdtime_tostring() symbol.
+ *
+ * Define a local version here so that we don't have to depend on
+ * libisc.a(stdtime.o).  If isc_stdtime_tostring() would be left undefined,
+ * the linker has to get the required object file, and that will result in a
+ * multiple definition error because the isc_stdtime_get() symbol exported
+ * there is already in the exported list.
+ */
+void
+isc_stdtime_tostring(isc_stdtime_t t, char *out, size_t outlen) {
+       UNUSED(t);
+       UNUSED(out);
+       UNUSED(outlen);
+}
+
 /* simple increment by 1 */
 static void
 increment_test(void **state) {