Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3289651iob; Mon, 16 May 2022 18:16:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyd6+LJChUIK0ptQexQR5NpJdH6Oms3+wjYxncTYTnvYYHwjqg61WFklcsvR9/Lan8A69AR X-Received: by 2002:a05:6402:2788:b0:42a:c7b2:3fb3 with SMTP id b8-20020a056402278800b0042ac7b23fb3mr492881ede.58.1652750218352; Mon, 16 May 2022 18:16:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652750218; cv=none; d=google.com; s=arc-20160816; b=QQkD4VJ2Ik9yk25UvQqByE/zcvL8hYUnhqXWlkoBLYc5MUUCWDHHfmc4JKc4ZCNjjC 5rDl748KL2ovCubHlKHeK5BWN8sDXxeZXyeVvquOeiNw975xzZJqRSGZgO7WazAhGLuU yTH02CChLnpISQuhi6k3VmawQzSqocSk1d+/2zgbGW0uzUOOpYhdpdxjQwLYKx3aPIZE 3BGJ/9LE6xhZ3YGnDl9xGvtX0EM8BOfQm0WqL5FPQ6rWUsOg3PO5wG21y5np23EjfTOS smeQqOmxLhUzatEMACCUgEAAUqYrcyo7qxcTGxp5Ua1yiUvkvA1CLBeHNuaWY34t2Pda XMLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:subject:cc:to :from:date:dkim-signature; bh=MK6D+bJiFWt3b7kQJCbuCST0iXmLyf1vvMx1vsAtPqA=; b=baBbzH750VMiKRB3DkbvaJ3Db3yHCFqbi49xYRlizp7rDYOM9YtuNHFXA6QipppiCM JmlM98yORak7faj3bvNMGmHLkT272zG/LYKvECr6qhzL6nO9k5bhqThP8oVhrDkhAynL ox9PfqSm93C3R0uWC2kvjjc2t5FT3qrI8ad42aTr4f0iQfdMC58k2EqVJJnM0V6slXP1 fLvDCtBCjr1qr65FWgQlr0FNijNxtXCjz7/iumPY6ple2v3ICscv7CbHBZ5WHqqNJgc0 53637VCGY9XardJehCKte6IdSqgrRLY95u8vS57DZ7usBJ2HDyAMVIOLPvKs9+flciT5 Dtqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ONQSwI9j; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z10-20020a05640235ca00b00425d8c497cfsi13581525edc.149.2022.05.16.18.16.32; Mon, 16 May 2022 18:16:58 -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=@redhat.com header.s=mimecast20190719 header.b=ONQSwI9j; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244969AbiEPPGu (ORCPT + 99 others); Mon, 16 May 2022 11:06:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244989AbiEPPGl (ORCPT ); Mon, 16 May 2022 11:06:41 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B448A3BA58 for ; Mon, 16 May 2022 08:06:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652713598; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=MK6D+bJiFWt3b7kQJCbuCST0iXmLyf1vvMx1vsAtPqA=; b=ONQSwI9jqHNXUCNyX40z/LOGMz+WwKm3Vi3n671g/GAGojbJFKyMyYV2vNEvTLyaYDi1sv lc0gZWuKFoSFB2J1JZMlwAbwINZ9ov7Kzd8hkzSBIPqCRoL2sDqZVFvdJOv7cSE1Yq8DOp iTAUY19xs8en9+kQiTXNIICmNtnPHKU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-594-HLt0MPhlNrenRqNaybuwYA-1; Mon, 16 May 2022 11:06:37 -0400 X-MC-Unique: HLt0MPhlNrenRqNaybuwYA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 42013858293; Mon, 16 May 2022 15:06:37 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3C11E2166B25; Mon, 16 May 2022 15:06:37 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id 24GF6bog021668; Mon, 16 May 2022 11:06:37 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id 24GF6aNO021664; Mon, 16 May 2022 11:06:36 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Mon, 16 May 2022 11:06:36 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Linus Torvalds , Peter Zijlstra , Josh Poimboeuf cc: linux-kernel@vger.kernel.org Subject: [PATCH] objtool: fix objtool regression on x32 systems Message-ID: User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, 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 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. Signed-off-by: Mikulas Patocka Fixes: 4abff6d48dbc ("objtool: Fix code relocs vs weak symbols") Fixes: c087c6e7b551 ("objtool: Fix type of reloc::addend") --- tools/objtool/check.c | 8 ++++---- tools/objtool/elf.c | 2 +- tools/objtool/include/objtool/elf.h | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) Index: linux-2.6/tools/objtool/check.c =================================================================== --- linux-2.6.orig/tools/objtool/check.c 2022-05-16 16:20:49.000000000 +0200 +++ linux-2.6/tools/objtool/check.c 2022-05-16 16:22:11.000000000 +0200 @@ -560,12 +560,12 @@ static int add_dead_ends(struct objtool_ else if (reloc->addend == reloc->sym->sec->sh.sh_size) { insn = find_last_insn(file, reloc->sym->sec); if (!insn) { - WARN("can't find unreachable insn at %s+0x%lx", + WARN("can't find unreachable insn at %s+0x%llx", reloc->sym->sec->name, reloc->addend); return -1; } } else { - WARN("can't find unreachable insn at %s+0x%lx", + WARN("can't find unreachable insn at %s+0x%llx", reloc->sym->sec->name, reloc->addend); return -1; } @@ -595,12 +595,12 @@ reachable: else if (reloc->addend == reloc->sym->sec->sh.sh_size) { insn = find_last_insn(file, reloc->sym->sec); if (!insn) { - WARN("can't find reachable insn at %s+0x%lx", + WARN("can't find reachable insn at %s+0x%llx", reloc->sym->sec->name, reloc->addend); return -1; } } else { - WARN("can't find reachable insn at %s+0x%lx", + WARN("can't find reachable insn at %s+0x%llx", reloc->sym->sec->name, reloc->addend); return -1; } 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);