Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp877021ybt; Wed, 24 Jun 2020 13:33:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznaU+icM9S3WInt+5Uspc8f/wBUBSTN+F588xT3A3lFk1vbkW4uQYzBBn908imOcL0SQlE X-Received: by 2002:a50:e881:: with SMTP id f1mr27521897edn.98.1593030820831; Wed, 24 Jun 2020 13:33:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593030820; cv=none; d=google.com; s=arc-20160816; b=kW6DN8PTXsIXV0j7qjxUuB2QoECDrynn+BxELvLOW5Z1GbLuKxDJHUJVZpxFRvmyL5 XR9OD0DdwiPXBhhE2l9cJJ0huBn8mBtu40hbTwOL6VcAUOzLGV+wmIZUwJWlsJi8Xxnq 1yeKTe8ATpz0t466qqpBvAFnDDK8APdwYRjQ7jwvmCrc2pafyhaAyLVVSw2cLO2LVx/K JtM/EeqFJMzZR6m4I2v1WgDUsU93IltinJImJAZgXQM7y093/YugGBmG9sOY24MKiY+i PJ36PdwW+gaV497cbuB2TSMbMMJ/3UlKvbU7qHwpA+opBt/ayLiqnK9t2uOSoo+1OsQd ESfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=xQdUf2OUslJj5DjDkMf3WWk6yA/Z9kKXMPQTw/J6IlI=; b=DV4qmAaQa0BHzqR4pZXoj35vg19xzNNAh/iLdViXGeQmRv39uBFIWtjLwtOt2KbYhg FKIVBDBmYcdILs5WHnHBP2MOubR1k9G4AbqeddHL5eEB9o2TRowtWhSr5xNHxs8OGaEQ VbqPtjYze7SvNJvEpgEhkApHItLGTj9k81cQmtN7abtGKf/DUPnR/eAsD9n/pIPJNFrv e3wQcWHGeoTF0tiD+qH9HIy9+DoioNkDGqB9Y6p5Rn3h+WonaZ5qEjecTEgu7Mvo251Q A6TA6NuzlOjISblNiQvaI2gfDt71cd1FBH61HHbLiZkqSxbANLyhGEUjg6nqvxXuQPWG Ck3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Xm0pw21C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p18si13128632edm.288.2020.06.24.13.33.17; Wed, 24 Jun 2020 13:33:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Xm0pw21C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391458AbgFXUc4 (ORCPT + 99 others); Wed, 24 Jun 2020 16:32:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391451AbgFXUcx (ORCPT ); Wed, 24 Jun 2020 16:32:53 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A754FC061796 for ; Wed, 24 Jun 2020 13:32:53 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id c3so3488653ybi.3 for ; Wed, 24 Jun 2020 13:32:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=xQdUf2OUslJj5DjDkMf3WWk6yA/Z9kKXMPQTw/J6IlI=; b=Xm0pw21CFWwXKUCWT9uv8sjRFTZSZ2FxFwksg6PZZFhaViOtrXe11fAV4rmUtsA/iD yw79dp1HbVFKYB9IyYfau+MusfZUyo7hsiV4z3U+B+VERxLsAmDLIOjA6ZbmwYQrk90b ude2AkBLX9/aWcsdUn0At059rWaNafFELeyyTNpWfaIPQWe975NuzYbO2Y2+sB6z99TZ DkeatZZ3I3Kg3WrJcfsykfzzNiGAFFIiaZ9KHBKGVzxxZKDwbNS3dVYdRS4I3s6IiWF7 F9FQwIOY90ZeHvihhQegbpcF6vQYY7VW45ZJstmN7BQcaqrs2XDnMXsRYKvPnePBoQiK Uk5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=xQdUf2OUslJj5DjDkMf3WWk6yA/Z9kKXMPQTw/J6IlI=; b=LSnK56oywgWg1t1z9cTJs1Zr6Ls2ya51bBGsi7zMLvlrNDCruirabo+jmQppOwO0w/ ccPJhkMstGx2XICd1mWA8pzwMxVbXgsgyw/EsyQSe0DaVWqhw8GgBjIjfkHJBa8TsXEl VNYeMnjU7sN+WC+GC4A5QKL5yI/vMoMJY6/WkaZHdmrz/amnU8d/0o+yebJHM559rXEw cazvQNkz1K4ErjENl2c4wVyPT029O4ZQVo1he+/TNQlLyuSf5uysYf/dIHCTKMoyrfu0 Ei5/9JP8Om/KPq9v6NiqrXDSLOB2ftLM/HqBGcXdGHtrHKdPf0HdE2cHw9Fkv9LC5vlh yQpw== X-Gm-Message-State: AOAM530sb8aVLTyzM910UU2KwP85aqIZYpC3ld68u2dEHI2FZl5XIrNU /JnehC2B0ctwGaIYsdVb1+7tEMkZv8yARPB+RIM= X-Received: by 2002:a25:4cca:: with SMTP id z193mr43175648yba.510.1593030771779; Wed, 24 Jun 2020 13:32:51 -0700 (PDT) Date: Wed, 24 Jun 2020 13:31:39 -0700 In-Reply-To: <20200624203200.78870-1-samitolvanen@google.com> Message-Id: <20200624203200.78870-2-samitolvanen@google.com> Mime-Version: 1.0 References: <20200624203200.78870-1-samitolvanen@google.com> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog Subject: [PATCH 01/22] objtool: use sh_info to find the base for .rela sections From: Sami Tolvanen To: Masahiro Yamada , Will Deacon Cc: Greg Kroah-Hartman , "Paul E. McKenney" , Kees Cook , Nick Desaulniers , clang-built-linux@googlegroups.com, kernel-hardening@lists.openwall.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, x86@kernel.org, Sami Tolvanen , Josh Poimboeuf Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ELF doesn't require .rela section names to match the base section. Use the section index in sh_info to find the section instead of looking it up by name. LLD, for example, generates a .rela section that doesn't match the base section name when we merge sections in a linker script for a binary compiled with -ffunction-sections. Signed-off-by: Sami Tolvanen Signed-off-by: Josh Poimboeuf Reviewed-by: Kees Cook --- tools/objtool/elf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 84225679f96d..c1ba92abaa03 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -502,7 +502,7 @@ static int read_relas(struct elf *elf) if (sec->sh.sh_type != SHT_RELA) continue; - sec->base = find_section_by_name(elf, sec->name + 5); + sec->base = find_section_by_index(elf, sec->sh.sh_info); if (!sec->base) { WARN("can't find base section for rela section %s", sec->name); -- 2.27.0.212.ge8ba1cc988-goog