From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD50AC433EF for ; Sat, 16 Apr 2022 11:26:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231488AbiDPL2e (ORCPT ); Sat, 16 Apr 2022 07:28:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231191AbiDPL2e (ORCPT ); Sat, 16 Apr 2022 07:28:34 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82F032E6BB for ; Sat, 16 Apr 2022 04:26:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=1yz7hq+5VGn1ld/P3Ju6K0vWVwgIZMsTkoV1kFgzx8s=; b=mX4rhZdGvTweiW5QIY6WJ/l/mZ lyXZcxlAyXtMmHqL1Lp1yk2MSDV9t2Q2Te8NKcF0slK8zJdszE6fGvMzmZnP+ipLRzE6yG2i0a5d1 Nob8130JtM+plpdElIwRR2IAR5eRevPRQhtXNujeyfb5H+WXVuAMFriuzh9NG/joA7slxzgisWsED R8EBtRZaiwl7inDMDM+lWEeVPFgXzwgyNZEMj9DMiDe9/hTi5fV23UQjfdB6EdtLK51FFGodXyFPK vzSJuZrtkTH0ysjAlLBGEtryzpHn3lFvmtBO2UdFhd0WsLyj12IVbKKLLZruUdsVtZBgRjZFw+iKW CD0ehxlA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nfgYm-00HRS3-BM; Sat, 16 Apr 2022 11:25:48 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 9AA879861A3; Sat, 16 Apr 2022 13:25:46 +0200 (CEST) Date: Sat, 16 Apr 2022 13:25:46 +0200 From: Peter Zijlstra To: "H.J. Lu" Cc: the arch/x86 maintainers , Josh Poimboeuf , Nick Desaulniers , Miroslav Benes , rostedt@goodmis.org, linux-toolchains@vger.kernel.org Subject: Re: The trouble with __weak and objtool got worse Message-ID: <20220416112546.GG2731@worktop.programming.kicks-ass.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-toolchains@vger.kernel.org On Fri, Apr 15, 2022 at 02:04:32PM -0700, H.J. Lu wrote: > On Fri, Apr 15, 2022 at 4:19 AM Peter Zijlstra wrote: > > *HOWEVER*, sometimes it generates things like this (using new enough > > binutils): > > > > foo-weak.o: > > > > Relocation section '.rela.static_call_sites' at offset 0x2c8 contains 1 entry: > > Offset Info Type Symbol's Value Symbol's Name + Addend > > 0000000000000000 0000000200000002 R_X86_64_PC32 0000000000000000 foo + 0 > > 0000000000000004 0000000d00000002 R_X86_64_PC32 0000000000000000 __SCT__foo + 1 > > > > foo.o: > > > > Relocation section '.rela.static_call_sites' at offset 0x310 contains 2 entries: > > Offset Info Type Symbol's Value Symbol's Name + Addend > > 0000000000000000 0000000200000002 R_X86_64_PC32 0000000000000000 foo + d > > 0000000000000004 0000000d00000002 R_X86_64_PC32 0000000000000000 __SCT__foo + 1 > > > > foos.o: > > > > Relocation section '.rela.static_call_sites' at offset 0x430 contains 4 entries: > > Offset Info Type Symbol's Value Symbol's Name + Addend > > 0000000000000000 0000000100000002 R_X86_64_PC32 0000000000000000 foo + 0 > > 0000000000000004 0000000d00000002 R_X86_64_PC32 0000000000000000 __SCT__foo + 1 > > 0000000000000008 0000000100000002 R_X86_64_PC32 0000000000000000 foo + d > > 000000000000000c 0000000d00000002 R_X86_64_PC32 0000000000000000 __SCT__foo + 1 > > > > And now we can see how that foos.o .static_call_sites goes side-ways, we > > now have _two_ patch sites in foo. One for the weak symbol at foo+0 > > (which is no longer a static_call site!) and one at foo+d which is in > > fact the right location. > > This can't be right. "foo" must point to the non-weak function. > Please file a linker bug report. It does point to the non-weak symbol; they both do, even the relocs that started out as pointing to the weak symbol. Are you saying the linker *should* have removed the relocs that were based on the weak symbol?