From nobody Mon Dec 13 23:50:44 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D7D3918E52F3; Mon, 13 Dec 2021 23:50:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JCdYc5NJGz4cSS; Mon, 13 Dec 2021 23:50:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 868461DD42; Mon, 13 Dec 2021 23:50:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BDNoiVB040712; Mon, 13 Dec 2021 23:50:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BDNoiMJ040711; Mon, 13 Dec 2021 23:50:44 GMT (envelope-from git) Date: Mon, 13 Dec 2021 23:50:44 GMT Message-Id: <202112132350.1BDNoiMJ040711@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 3aa0bc89c6a1 - main - libdwarf: Add a weak uncompress() symbol List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3aa0bc89c6a1165cb16987493540372af24e760f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639439445; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vyeGhb33PyDVocA7ESjAhSFqwaEMWMtDJkz8q0LiEO8=; b=haqpb1ESPPEzfOtm0TvpBe9kc7rXuQVqr977UIh5m+SJtgUMQAIa6SHQkxhNUjngd02LlX SE4sVyKC0MJl/sun0WZIIgo/QI/EVqGLRZsU5NaCQHL1k6pV/vcf+3dIdCMhS/rdAxUrJr kSOMUSqop6ttCmUPXl3GFWVOGTTJ6k2k0yoawzKWzYO3FXYhGpL9ndX1lU/63RUWizJGWZ QZsn05zPF1B1TgTQjlZZ62jZZMQQii/vHWltDfJ1/ufJCOSAuJotjSn0axWDbcUueo8fpj v3Z0/lLEeLqqyB/jSDNO5hWzR0I9i3a7AQ0iSX98NqlYQYfpXRO4uN2zKJxLJQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639439445; a=rsa-sha256; cv=none; b=FmVd+uRZxze2DO3NybA6O5GHP+XbiFrQPGxcaTi3Wo5tvpTWubFz5KcoqqomG3dreIjNFm uDoAmH5nvEC4ooNtIOLMiOld03cfLkHj3xj50hOCZfk8gJpIVtxQ3BM5HALCWVjBmfUND2 RyhopvwxT+8ei7oPFgdQ6UaNcJLkQR3rbDMkKkSsbQxijBu3JJD7fIH8o80iembnxtmEdq 2N16GONAxeIJi36opgafP53LZv4jaqjctXXv60T1vYhbkkgKFjCT9MZ9N59fnkTw/SCGY8 HXIXurLGdLPQY5zFMRP3cuvzuYMh/kMdJX32FqsbVkjTLAo4Nv1EBkwodTVTVg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=3aa0bc89c6a1165cb16987493540372af24e760f commit 3aa0bc89c6a1165cb16987493540372af24e760f Author: Mark Johnston AuthorDate: 2021-12-13 23:44:13 +0000 Commit: Mark Johnston CommitDate: 2021-12-13 23:47:15 +0000 libdwarf: Add a weak uncompress() symbol This works around brokenness in buildworld's bootstrapping logic: it uses the source tree's metadata to collect dependency info (such as, "libdwarf depends on libz") but links against static host libraries. If these two are out of sync, as is the case if one builds a commit prior to the introduction of the libz dependency, then the build fails when trying to statically link nm(1). Mitigate the problem by defining a weak uncompress() symbol which simply returns an error. This ensures that the build won't fail when statically linking libdwarf without zlib. The downside is that any tools using libdwarf without zlib will now hit a runtime error if they attempt to decode compressed sections, but at least they'll fail deterministically, and compressed debug info is only enabled by default in main. In particular, this fixes building of branches lacking commit dbf05458e3bd, such as releng branches, stable/12 and 13 and old revisions of main. Previously the nm(1) build would fail with: ld: error: undefined symbol: uncompress >>> referenced by libdwarf_elf_init.c:233 >>> (/usr/src/contrib/elftoolchain/libdwarf/libdwarf_elf_init.c:233) >>> libdwarf_elf_init.o:(_dwarf_elf_init) in archive >>> /usr/lib/libdwarf.a Reported by: dim, ler, krion Reviewed by: imp, emaste Fixes: dbf05458e3bd ("libdwarf: Support consumption of compressed ELF sections") MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D33419 --- contrib/elftoolchain/libdwarf/zlib_stub.c | 27 +++++++++++++++++++++++++++ lib/libdwarf/Makefile | 3 ++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/contrib/elftoolchain/libdwarf/zlib_stub.c b/contrib/elftoolchain/libdwarf/zlib_stub.c new file mode 100644 index 000000000000..173c581b31ec --- /dev/null +++ b/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 */ +} diff --git a/lib/libdwarf/Makefile b/lib/libdwarf/Makefile index a3ef95b2572a..994c0bc5c1fa 100644 --- a/lib/libdwarf/Makefile +++ b/lib/libdwarf/Makefile @@ -73,7 +73,8 @@ SRCS= \ libdwarf_reloc.c \ libdwarf_rw.c \ libdwarf_sections.c \ - libdwarf_str.c + libdwarf_str.c \ + zlib_stub.c INCS= dwarf.h libdwarf.h