From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EB792385C401; Tue, 28 Nov 2023 15:23:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EB792385C401 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1701184982; bh=TZZ2UW+BIMBVhoXHEX/GoC9Fp8La67LD+m3khAbBL2U=; h=From:To:Subject:Date:In-Reply-To:References:From; b=aldOgnooGFcUOAHQ/dU/m+WGEiG25WxxM3haPR3db0tmslVa1dbz9yfxi7AcH8Uc+ N0JSUL1QiRqKsJyNzdVjAEpB50iQCtnkNNbSGTa4TCWrLQENvXchhH+LUsD8RCxhe7 zgLHEgKuq+s5g7jNcQfBeuesKhzTVaeccdzcBgxY= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/109253] libbpf: failed to find BTF info for global/extern symbol '__divdi3' Date: Tue, 28 Nov 2023 15:23:01 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109253 --- Comment #3 from GCC Commits --- The master branch has been updated by Jose E. Marchesi : https://gcc.gnu.org/g:f31a019d1161ec78846473da743aedf49cca8c27 commit r14-5930-gf31a019d1161ec78846473da743aedf49cca8c27 Author: Jose E. Marchesi Date: Fri Nov 24 06:30:28 2023 +0100 Emit funcall external declarations only if actually used. There are many places in GCC where alternative local sequences are tried in order to determine what is the cheapest or best alternative to use in the current target. When any of these sequences involve a libcall, the current implementation of emit_library_call_value_1 introduce a side-effect consisting on emitting an external declaration for the funcall (such as __divdi3) which is thus emitted even if the sequence that does the libcall is not retained. This is problematic in targets such as BPF, because the kernel loader chokes on the spurious symbol __divdi3 and makes the resulting BPF object unloadable. Note that BPF objects are not linked before being loaded. This patch changes asssemble_external_libcall to defer emitting declarations of external libcall symbols, by saving the call tree nodes in a temporary list pending_libcall_symbols and letting process_pending_assembly_externals to emit them only if they have been referenced. Solution suggested and sketched by Richard Sandiford. Regtested in x86_64-linux-gnu. Tested with host x86_64-linux-gnu with target bpf-unknown-none. gcc/ChangeLog PR target/109253 * varasm.cc (pending_libcall_symbols): New variable. (process_pending_assemble_externals): Process pending_libcall_symbols. (assemble_external_libcall): Defer emitting external libcall symbols to process_pending_assemble_externals. gcc/testsuite/ChangeLog PR target/109253 * gcc.target/bpf/divmod-libcall-1.c: New test. * gcc.target/bpf/divmod-libcall-2.c: Likewise. * gcc.c-torture/compile/libcall-2.c: Likewise.=