Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp960108ybm; Wed, 27 May 2020 12:13:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7Arb1WcBMDCI0RjgTCCgHZi5FOqzUgvmMWXnTiUM9bIkmLVhYrinPI3FSP6q+hboLO9f/ X-Received: by 2002:a17:906:1c10:: with SMTP id k16mr7096309ejg.511.1590606835915; Wed, 27 May 2020 12:13:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590606835; cv=none; d=google.com; s=arc-20160816; b=ti20GDQj8s048+ygpcl4R2hfpei9Gaux/cpmzKEAdzIpz7qTTeLnGeBUhETIw4Np1s I+BqsGrA7lF2Ync0M/1pJ/IVTr6G/kh4zQkzS/ZBS8etg7ng2MCd+77D1puatlCdWBX5 sWSVIMABR7J611/WR6qvU77HgYc04fqcrHxiMuDrpM6HDUfj6vlC0m3TjFUCv/62ihGW QFYRiRxWqiPoE8idfRJS48v8BzEUdE+FDQ1xx66a747HX/C4km1udSpVZcK2qziKNoSP HxKtXX/l/gquYdGXn0mof3VaZjUr2DROEkn3G8Nf7WnOppWZZdBsJp6P32mWch88dgLP vcKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=m4U8/Y7LQJjbCmilv/OaP6EvZmAIwjZhHbgWLuB3CKs=; b=wMQZljQNlFnzjOqvla4O/21n0aJ3lGOXD9EgyR5lJhZhilGT9BDtBx9t1xLMTMiY+J EBk0RYXjOSHNZH2tDlXNvKaeKpThNTCTxZdBowzBf91dTZhNbwU3PhRI+vHZpmVJD187 NgplX0VH4Bo0w/jsLq66qsIiq3rJSaamaxXC1GQSTyt7nWlyyeA/W7bqy6hpsniPldi7 c+V+6vy6Yi50jCpb/Y8UGjRdU5Nj/uWY1vgNq+Xb7k7ooq6WdAsZ6ToUqrFrnrSUOQ3e FOwzl8tAPwZQbqm1HGi3AK8Xfgbp7Ki4mrmdC3o0xsGjRHgdXX5QfqyQueWsd8fJfzo9 CeWw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=vmware.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c34si2113347edd.509.2020.05.27.12.13.33; Wed, 27 May 2020 12:13:55 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=vmware.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391381AbgE0Qmz (ORCPT + 98 others); Wed, 27 May 2020 12:42:55 -0400 Received: from ex13-edg-ou-002.vmware.com ([208.91.0.190]:11383 "EHLO EX13-EDG-OU-002.vmware.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391358AbgE0Qms (ORCPT ); Wed, 27 May 2020 12:42:48 -0400 Received: from sc9-mailhost3.vmware.com (10.113.161.73) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Wed, 27 May 2020 09:42:44 -0700 Received: from sc9-mailhost2.vmware.com (unknown [10.200.192.41]) by sc9-mailhost3.vmware.com (Postfix) with ESMTP id AA5714046A; Wed, 27 May 2020 09:42:46 -0700 (PDT) From: Matt Helsley To: CC: Josh Poimboeuf , Peter Zijlstra , Steven Rostedt , Matt Helsley Subject: [RFC][PATCH 2/3] objtool: Find relocation base section using sh_info Date: Wed, 27 May 2020 09:42:32 -0700 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII Received-SPF: None (EX13-EDG-OU-002.vmware.com: mhelsley@vmware.com does not designate permitted sender hosts) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently objtool uses a naming heuristic to find the "base" section to apply the relocation(s) to. The standard defines the SHF_INFO_LINK flag (SHF => in the section header flags) which indicates when the section header's sh_info field can be used to find the necessary section. Warns when the heuristic is used as a fallback and changes the name heuristic calculation to handle rela (explicit addend) and now rel (implicit addend) relocations. Signed-off-by: Matt Helsley --- tools/objtool/elf.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 6fb9f83f7f66..a162bc383945 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -502,7 +502,13 @@ static int read_relocs(struct elf *elf) if (sec->sh.sh_type != SHT_RELA) continue; - sec->base = find_section_by_name(elf, sec->name + 5); + if (sec->sh.sh_flags & SHF_INFO_LINK) { + sec->base = find_section_by_index(elf, sec->sh.sh_info); + } else if (strncmp(sec->name, ".rel", 4) == 0) { + WARN("Using naming heuristic to find base of reloc section %s", + sec->name); + sec->base = find_section_by_name(elf, sec->name + 5); + } if (!sec->base) { WARN("can't find base section for reloc section %s", sec->name); -- 2.20.1