Index: contrib/elftoolchain/libdwarf/zlib_stub.c =================================================================== --- /dev/null +++ contrib/elftoolchain/libdwarf/zlib_stub.c @@ -0,0 +1,27 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 The FreeBSD Foundation + * + * This software was developed by Mark Johnston under sponsorship from + * the FreeBSD Foundation. + */ + +#include + +/* + * A hack to allow libdwarf.a to be statically linked without zlib. This is + * unfortunately required for FreeBSD <= 13.0 to bootstrap build tools + * such as nm(1), as they use metadata from the source tree to generate the + * dependency list but then link with the build host's libraries. + */ + +extern int uncompress(void *, unsigned long *, const void *, + unsigned long); + +int __weak_symbol +uncompress(void *dst __unused, unsigned long *dstsz __unused, + const void *src __unused, unsigned long srcsz __unused) +{ + return (-6); /* Z_VERSION_ERROR */ +} Index: lib/libdwarf/Makefile =================================================================== --- lib/libdwarf/Makefile +++ lib/libdwarf/Makefile @@ -73,7 +73,8 @@ libdwarf_reloc.c \ libdwarf_rw.c \ libdwarf_sections.c \ - libdwarf_str.c + libdwarf_str.c \ + zlib_stub.c INCS= dwarf.h libdwarf.h