Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3276514iob; Mon, 16 May 2022 17:54:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXVDojLUQVjszUE03RN6qoi0lNNKLgzZZ1EVYNZiMKnZnpiFp7E7nv7BoLhIEl0+jtac3P X-Received: by 2002:a65:6451:0:b0:3c1:cb83:8e4 with SMTP id s17-20020a656451000000b003c1cb8308e4mr17309880pgv.339.1652748896370; Mon, 16 May 2022 17:54:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652748896; cv=none; d=google.com; s=arc-20160816; b=Oi5DYfjnYjMYCrr/DH6zN0pPJejVps41GBx7tIphOlu5z1tm5KQUyK2WIrUoCoTutD +NkVvV1g7A6plLx7I3HWkPHoYuCiwR+Mi4ukgh/wpV9b1nKKCiYigZuIqIXlYELc5E3S +SR0+uJXVmdnNM88I70w/LsPRPup3Q6hAx1iVgNcQUAFm9xefsTIO6FBQDzF7DLqqO3C QINxS/U4NsUGio2e4Q0kGacFO8KKg2zzzUToh6JBZfhDGGDdF5q+A1Cqjf6n3iByvJDZ j/dp6ZeToVJmNGuwzviomZ+BsbD3yr6lLkSAS0HSuEys5lFLIKiVY7P/VgNwf/weYRMO /xYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=AyJBqgpz73uaiM8oXDPx2MhxDsj8LgRWS3TNA7ATI6M=; b=gJLeHa7UPzz3+dqvV3WNdJ6522oLecNCbQdrRjnqvzMstzxJbSQBPPlwKz8e0QpZ8O 0cwa5ZwxXRtswWxxnXuM//z1+Irn9n/V5fAqhc1YDfxgFs0o2xhzWVe188cyTmUHoLNT OsM4MX700rgh6zvwjMNoaHy9QoFWHRdKzaIemV9CCYR4Mc6gSmc6lurt0NUAhrfcDjgL FQAILXxaM0CC2yJnNCkkdsxZvfa9jgwTMXXW80z/yerMLDqGwmktR3j8nlkeACxpzVqZ KHjTD5KEoM9XbnATD1avr37eCz5UM5X8W3iyzuBSu20URjAWEJfZrDxGtlBriIFe4lpF aHXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=K0O3qejp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lx9-20020a17090b4b0900b001decaeaf1easi1142541pjb.6.2022.05.16.17.54.44; Mon, 16 May 2022 17:54:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=K0O3qejp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236795AbiEPPlu (ORCPT + 99 others); Mon, 16 May 2022 11:41:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232339AbiEPPlr (ORCPT ); Mon, 16 May 2022 11:41:47 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD72127B36 for ; Mon, 16 May 2022 08:41:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=AyJBqgpz73uaiM8oXDPx2MhxDsj8LgRWS3TNA7ATI6M=; b=K0O3qejpmE2QUjNiIa/ko4USJv KGzQxmKT0v8gaONRuBtau+H4FeHVKT9U67qUAXhtBQHhEpDJMcJbyvX8GKSGV/d3bfL6/VPfdOoeP 1WShfjajJbPX1ar/mzAo7Frr3rmQx8uGd5t7q0cCf3aF70mr6AFjB3J4OQAjRCapX/ho3Z32f3q4C IOcYg4GS6p3QvP2MvOfHrym5ygBAjkiy9vOM0TJY45y6BqscPlpupjMvJJBAQKKjxjmXLecHiJJwk v9IT0o5+uMcXj+wKx/xvnQg7uGYz2cRCfi3/zQpg6mP1+n6z6xMHJJ4NvwhWdSnihMwWXIEbfK3Dt 1Gqab9vA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqcqs-000yQs-NB; Mon, 16 May 2022 15:41:43 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (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 noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 705B830023F; Mon, 16 May 2022 17:41:40 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 501B920225E5F; Mon, 16 May 2022 17:41:40 +0200 (CEST) Date: Mon, 16 May 2022 17:41:40 +0200 From: Peter Zijlstra To: Mikulas Patocka Cc: Linus Torvalds , Josh Poimboeuf , linux-kernel@vger.kernel.org Subject: Re: [PATCH] objtool: fix objtool regression on x32 systems Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 16, 2022 at 11:06:36AM -0400, Mikulas Patocka wrote: > The patch 4abff6d48dbc ("objtool: Fix code relocs vs weak symbols") makes > the kernel unbootable. The patch c087c6e7b551 ("objtool: Fix type of > reloc::addend") attempts to fix it by replacing 'int' with 'long'. > > However, we may be running on a system with x32 ABI and 'long' on x32 is > 32-bit, thus the patch c087c6e7b551 doesn't really change anything and we > still end up with miscompiled kernel. This patch replaces 'long' with > 'long long', so that the 64-bit kernel is correctly compiled on a x32 > system. Hurmph.. you're building a 64bit kernel on a x32 hosted machine? And this is the *only* thing that goes sideways? I suspect quite a bit of objtool assumes LP64 and won't quite work right on ILP32 and we've just been lucky so far. > Index: linux-2.6/tools/objtool/elf.c > =================================================================== > --- linux-2.6.orig/tools/objtool/elf.c 2022-05-16 16:20:49.000000000 +0200 > +++ linux-2.6/tools/objtool/elf.c 2022-05-16 16:22:21.000000000 +0200 > @@ -546,7 +546,7 @@ static struct section *elf_create_reloc_ > int reltype); > > int elf_add_reloc(struct elf *elf, struct section *sec, unsigned long offset, > - unsigned int type, struct symbol *sym, long addend) > + unsigned int type, struct symbol *sym, long long addend) > { > struct reloc *reloc; > > Index: linux-2.6/tools/objtool/include/objtool/elf.h > =================================================================== > --- linux-2.6.orig/tools/objtool/include/objtool/elf.h 2022-05-16 16:07:54.000000000 +0200 > +++ linux-2.6/tools/objtool/include/objtool/elf.h 2022-05-16 16:22:45.000000000 +0200 > @@ -73,7 +73,7 @@ struct reloc { > struct symbol *sym; > unsigned long offset; > unsigned int type; > - long addend; > + long long addend; > int idx; > bool jump_table_start; > }; > @@ -135,7 +135,7 @@ struct elf *elf_open_read(const char *na > struct section *elf_create_section(struct elf *elf, const char *name, unsigned int sh_flags, size_t entsize, int nr); > > int elf_add_reloc(struct elf *elf, struct section *sec, unsigned long offset, > - unsigned int type, struct symbol *sym, long addend); > + unsigned int type, struct symbol *sym, long long addend); > int elf_add_reloc_to_insn(struct elf *elf, struct section *sec, > unsigned long offset, unsigned int type, > struct section *insn_sec, unsigned long insn_off); > I think I much prefer s64 there instead of 'long long'. But really I think all of objtool needs a bit of an audit to see what types need be used.