Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2384526rdb; Thu, 21 Sep 2023 18:03:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGn4Q3F05NwTjznbtp+RIuP6utjm2iHC2CMfLML8o2kn1qUUODPcAskMCP8uqI+ouzKBevM X-Received: by 2002:a17:90a:b113:b0:26c:e606:f455 with SMTP id z19-20020a17090ab11300b0026ce606f455mr7040299pjq.36.1695344590428; Thu, 21 Sep 2023 18:03:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695344590; cv=none; d=google.com; s=arc-20160816; b=G3qmYbRfvDqdgkTFheAygHpqYuu1r+ttrEcYRafx75+IyvnC3JpBfWKj4FjKUUmt8/ Y+3G+mTclKHugWGfrhB7E8+tegpc9PRYN2YvP2u8fae9E0Y4o6a3kanTKSDW+LAeIXvg BUSyIvCHtyF4J79EhattIyeKlCkLeEj4SVEVCg/ABu6wj/7SM0FSzv4FjM/Y4KHrFRKm kOxvdDD18e9BA6EYoQlp16ckm9DN4fx97Sbmtj4DhcAFKx9prsTJXRhgpmYBW5YlcBMC ++TZb2q+z3TWjZJT8jYNDUvKhrQ9+/+o10hOkUfIs9YsGnNa76RMrYaISKglqcOECBho CxZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Kr0HDINOfnSGJvR8CBUjdsC1w8o7oheg4iDN7h3/HXE=; fh=FhmsxNZKN2NY1ofs2e4wzr2QnhLz9jg8/P8RnHBDvJk=; b=bNEripmsovjs+PPmANe1cX4zkDnS3KAkAGJXdesAm8VXx/EpXu6tpd8MMN8RBO8xCP dp+52lX1ky4urncYp3pb/cAVs0zi9PhQ3G0MqvfXSHvifmsLmg6jW+VtKAtZFfi78bau pedDaqNjASAs9liKi1zKeCvfjS64bL+y8EfByVQ9mbmyeOOui2D28ob7UJx49FT+HBnR kTIXxe5w+BUj4BYO92nXt0zj8LxerZPXmgqSyC9HlEg6y/EP2y61WKIsNcdpaUMEIM/j HhOfIbqhT6I6D/47H9yDOln5Uh2+TXq/DNEhvGUVR1sZyX+Tz1j+4TUQtM1/eAWm2/Xw sRAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=wDXn9xPM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id f8-20020a170902684800b001c5e1816251si1182523pln.497.2023.09.21.18.03.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 18:03:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=wDXn9xPM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id D98A782F4C98; Thu, 21 Sep 2023 13:27:36 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231977AbjIUU1U (ORCPT + 99 others); Thu, 21 Sep 2023 16:27:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231851AbjIUU0r (ORCPT ); Thu, 21 Sep 2023 16:26:47 -0400 Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 546A9102 for ; Thu, 21 Sep 2023 13:07:21 -0700 (PDT) Received: by mail-qt1-x82e.google.com with SMTP id d75a77b69052e-415155b2796so10441cf.1 for ; Thu, 21 Sep 2023 13:07:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695326840; x=1695931640; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Kr0HDINOfnSGJvR8CBUjdsC1w8o7oheg4iDN7h3/HXE=; b=wDXn9xPMveNFhs697QYomVuMlz2fhaoARhXF7lm7PRp+dKjZPmEG8R6NxT8E4jE7cY cWiw34zP1tMw1DpJrqTXzX463AjcAPhgW5s2vFijkRQQt2LwmkIe+2cgFE2eF1VITqNf 9GHs1DOTsF78UibfB9VuA4bajbzVFEZpuqHvpIECdzd+WBVr4tilLP2GvRjWmtEz3lhq QGZNfD/VN+sJLyued1T4aGyJ72E3bnyKoPq+mFRwwHua2AAb99xtpCe6EhxL/KcsEml0 LP5Mjlqd1Pb3ekVMpXvOrUKvstGpVTp3T00DUoqw0jLaVaU2Do58zkDAKyV1wk88EPuZ 8afw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695326840; x=1695931640; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Kr0HDINOfnSGJvR8CBUjdsC1w8o7oheg4iDN7h3/HXE=; b=a9kFAfvoxQemxFUuVZU+E3fhTX6EJPsbFsNRT1pq9bGtmXmSicGcy4Xp75tVcwvL/R loY1GOsRBdarscJK4nwouNLv5EcC2KPMqJbtGqpW6p9Uqyzq9/VuYGt3cjxS/YJeWK+V +AM0HQZ3G8GeKoZhtwAG2cukmDdJDC8owtAFfWVb0jOXRqifFQxRhxLnp7oy+hbttBUv 41Mapn50LrJBtztkhGw6ApH7210rWuBpz4s2IszWnuiZZ+PK13C9G41kEBKs1OULReAv U/YdQICb094jS5g8t3P+sNFZ2KSsYxihcuHMIBiyYNAlqMScD17/dW2u5b1DujmG9gPA Lugg== X-Gm-Message-State: AOJu0YzFQcDI1HdLEEGvuxsFKdmnQBp7zHj/IIh6GNoqLG/LTn3TK4rz 7E93R+cGqNIriroT2KqEgBMRxXL72Nbxya4ReP0bWw== X-Received: by 2002:a05:622a:1aa9:b0:40f:d1f4:aa58 with SMTP id s41-20020a05622a1aa900b0040fd1f4aa58mr14332qtc.8.1695326840269; Thu, 21 Sep 2023 13:07:20 -0700 (PDT) MIME-Version: 1.0 References: <20230920001728.1439947-1-maskray@google.com> <20230921072655.GA14803@noisy.programming.kicks-ass.net> <20230921153537.GG14803@noisy.programming.kicks-ass.net> <20230921171900.GB29413@noisy.programming.kicks-ass.net> <20230921192253.GA39480@noisy.programming.kicks-ass.net> In-Reply-To: <20230921192253.GA39480@noisy.programming.kicks-ass.net> From: Fangrui Song Date: Thu, 21 Sep 2023 13:07:09 -0700 Message-ID: Subject: Re: [PATCH] x86/speculation, objtool: Use absolute relocations for annotations To: Peter Zijlstra Cc: x86@kernel.org, Josh Poimboeuf , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Nick Desaulniers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 21 Sep 2023 13:27:37 -0700 (PDT) On Thu, Sep 21, 2023 at 12:22=E2=80=AFPM Peter Zijlstra wrote: > > On Thu, Sep 21, 2023 at 10:36:27AM -0700, Fangrui Song wrote: > > > Well, only if the clever assembler doesn't support 32-bit absolute > > relocation for a 64-bit architecture. > > I don't know such an architecture. In addition, as long as the > > architecture intends to support DWARF32, it has to support 32-bit > > absolute relocations for a 64-bit architecture. > > Ooh... my bad. For some reason I thought that absolute meant native word > size. But you already mentioned R_X86_64_32 (and I failed to check) and > that is indeed an absolute (S+A) relocation of 32bit (dword) size. > > And apparently we also have R_X64_64_16 and R_X86_64_8, which would even > allow something like: > > #define OBJTOOL_ANNOTATE(type) \ > "999:\n\t" \ > ".pushsection .discard.objtool_annotate\n\t" \ > ".byte 999b\n\t" \ > ".byte " __stringify(type) "\n\t" \ > ".popsection\n\t" > > And since we only read the relocation and don't care for the actual > result that would actually work just fine. > > Anyway, thanks for bearing with me. > > Acked-by: Peter Zijlstra (Intel) Thanks! I assume that the patch can be picked up without me doing anything= :) Yes, x86 also supports 1-byte and 2-byte absolute relocation types, which are missing from some other architectures. If we want to optimize for RELA, we can use R_*_NONE by utilizing `.reloc ., BFD_RELOC_NONE, .text.foo` (as mentioned in the commit message). (binutils 2.26 https://sourceware.org/git/?p=3Dbinutils-gdb.git;a=3Dcommit;= h=3D740bdc67c057ee8012327420848eb134e1db4211; I added the support to most LLVM targets in 2021). However, this is just 4 byte per entry difference compared with the large sizeof(Elf{32,64}_Rel), so not worth the trouble:) --=20 =E5=AE=8B=E6=96=B9=E7=9D=BF