Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1073586ybv; Thu, 13 Feb 2020 15:17:31 -0800 (PST) X-Google-Smtp-Source: APXvYqzvEOTNClmm52OZI+LjE5yuEElBuDbh/QcXExQjL0YTP322rnRtkNmWa06k7MHO/ZPHvwKE X-Received: by 2002:a54:4396:: with SMTP id u22mr6615oiv.128.1581635851555; Thu, 13 Feb 2020 15:17:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581635851; cv=none; d=google.com; s=arc-20160816; b=fxJ/RenHidsB3TH6UhtFjeK8HVno+GrIsrWMmjPNgZEMrFfU65A8cP46Arvzo+UGwN 1k3ZGcaq1LlXlsm76vH2DmtHE5c0+8lw7xGT2nA0KNSrgIl8X1Oy6deYN4C8p3DNik/r C468W+79vz7NFmVp1eiNUBwkJSUeblWl1eYz22fzGnjZZV2bDAjnS7P0BhhrESP5IC9T 8ip+sqykZzOtiBAWlLd9cmAanriuz4WI5LpvwbKBZEdWWKEwFdBLnW48FMwFbID+MKHS Txl6VmIV72MRmklzFA8GwHFtCfQAIgEYk4edzYIrQuZbIozBl1qLnt3JyQG9spVaayZU w6IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=JPKc4Qj1zLgWNNEAg/3I0kSh8srrtB1FZBnX9z98lqM=; b=LDRPn3MLVH9lIYZJCCdIWH5VUEjIHaGyaJ+YLDU8+sIJ56dL/dqgMoosT+tg05Gkyv JRk4ORS4bdrumpYNrJ3Kcyn0IVVn/bbUtjPZQ56K5PC3VOL7rQ0EE3BaQ2frpmZPaRlB UN63XHFzbcz/rp/ey4hqsF9CUlq4j5SX6oh32V86m91QUYsVcCJSQ1T8tNQJ/B7WAVf9 FFhp6/9HRa0F/fEKXQtr/ii1OEoKGxf7d7tc4oDoCCd1ypuXB+R6IP7/vIt82ZrmuP9F nmGA+ecOckQS84aIYBpzOObFVvx9BpaYF6NmjYaG826/J23pKYPvouxCHmpZmGQsYFkn pERQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dOrMTpvr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v18si1853494otn.174.2020.02.13.15.17.18; Thu, 13 Feb 2020 15:17:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dOrMTpvr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727845AbgBMXRG (ORCPT + 99 others); Thu, 13 Feb 2020 18:17:06 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:58151 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726780AbgBMXRF (ORCPT ); Thu, 13 Feb 2020 18:17:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581635824; 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: in-reply-to:in-reply-to:references:references; bh=JPKc4Qj1zLgWNNEAg/3I0kSh8srrtB1FZBnX9z98lqM=; b=dOrMTpvrMFx9VTLoEzw2hfCceaO0qY80E3b42oRcxiBfsdPUuEmYt4LivEGyR7i0lN3bkB /hKG2/9vccSHCMzBiOMxMRJ4qzaI3fUT3YdVk44JwAWNKWeiop1YjteAUYXk1wX+womNNI kUOAJJhnKlJstWKwSj4UVy8qKSDssq8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-284-mCoTIPOIMBSGaD5vJl8xiA-1; Thu, 13 Feb 2020 18:16:56 -0500 X-MC-Unique: mCoTIPOIMBSGaD5vJl8xiA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DFB271851FC2; Thu, 13 Feb 2020 23:16:54 +0000 (UTC) Received: from treble (ovpn-121-12.rdu2.redhat.com [10.10.121.12]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 155091FD3B; Thu, 13 Feb 2020 23:16:53 +0000 (UTC) Date: Thu, 13 Feb 2020 17:16:51 -0600 From: Josh Poimboeuf To: Fangrui Song Cc: Nick Desaulniers , peterz@infradead.org, clang-built-linux@googlegroups.com, Nathan Chancellor , linux-kernel@vger.kernel.org Subject: Re: [PATCH] objtool: ignore .L prefixed local symbols Message-ID: <20200213231651.alogip6tupegsbvq@treble> References: <20200213184708.205083-1-ndesaulniers@google.com> <20200213221758.i6pchz4gsiy2lsyc@treble> <20200213223734.3zjrvhshjyr5ca7p@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200213223734.3zjrvhshjyr5ca7p@google.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 13, 2020 at 02:37:34PM -0800, Fangrui Song wrote: > I still consider such a check (tools/objtool/check.c:679) unneeded. > > st_type doesn't have to be STT_FUNC. Either STT_NOTYPE or STT_FUNC is > ok. If STT_GNU_IFUNC is used, it can be ok as well. > (My clang patch skips STT_GNU_IFUNC just because rtld typically doesn't > cache R_*_IRELATIVE results. Having two STT_GNU_IFUNC symbols with same st_shndx and > st_value can create two R_*_IRELATIVE, which need to be resolved twice > at runtime.) > > } else if (rela->sym->type == STT_SECTION) { > insn->call_dest = find_symbol_by_offset(rela->sym->sec, > rela->addend+4); > if (!insn->call_dest || > insn->call_dest->type != STT_FUNC) { > WARN_FUNC("can't find call dest symbol at %s+0x%x", > insn->sec, insn->offset, > rela->sym->sec->name, > rela->addend + 4); > return -1; > } > > > .section .init.text,"ax",@progbits > call printk > call .Lprintk$local > .text > .globl printk > .type printk,@function > printk: > .Lprintk$local: > ret Objtool isn't a general ELF validator, it's more of a kernel sanity validator. In the kernel we currently have a constraint that you can only call STT_FUNC. At the very least it helps keep our asm code clean. If that constraint ever becomes a problem then we could always reconsider it. > % llvm-mc -filetype=obj -triple=riscv64 a.s -mattr=+relax -o a.o > % readelf -Wr a.o > > Relocation section '.rela.init.text' at offset 0xa0 contains 4 entries: > Offset Info Type Symbol's Value Symbol's Name + Addend > 0000000000000000 0000000200000012 R_RISCV_CALL 0000000000000000 printk + 0 > 0000000000000000 0000000000000033 R_RISCV_RELAX 0 > 0000000000000008 0000000100000012 R_RISCV_CALL 0000000000000000 .Lprintk$local + 0 > 0000000000000008 0000000000000033 R_RISCV_RELAX 0 > > > On RISC-V, when relaxation is enabled, .L cannot be resolved at assembly > time because sections can shrink. > > https://sourceware.org/binutils/docs/as/Symbol-Names.html > > > Local symbols are defined and used within the assembler, but they are *normally* not saved in object files. > > I consider the GNU as issue a missed optimization, instead of a bug. > There is no rigid rule that .L symbols cannot be saved in object files. I know nothing about RISC-V, but if I understand correctly, .Lprintk$local is the function's local entry point, similar to ppc64 localentry. Would it not always be a constant offset from the printk address, such that the relocation could be "printk + 8" or so? Regardless, it doesn't really matter for now, objtool is x86-only. -- Josh