From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Fangrui Song <maskray@google.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>,
peterz@infradead.org, clang-built-linux@googlegroups.com,
Nathan Chancellor <natechancellor@gmail.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] objtool: ignore .L prefixed local symbols
Date: Thu, 13 Feb 2020 17:16:51 -0600 [thread overview]
Message-ID: <20200213231651.alogip6tupegsbvq@treble> (raw)
In-Reply-To: <20200213223734.3zjrvhshjyr5ca7p@google.com>
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
next prev parent reply other threads:[~2020-02-13 23:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-13 18:47 [PATCH] objtool: ignore .L prefixed local symbols Nick Desaulniers
2020-02-13 19:20 ` Fangrui Song
2020-02-14 6:16 ` Arvind Sankar
2020-02-14 18:05 ` Fangrui Song
2020-02-14 20:42 ` Arvind Sankar
2020-02-14 22:20 ` Fangrui Song
2020-02-15 0:05 ` Arvind Sankar
2020-02-15 0:34 ` Arvind Sankar
2020-02-13 22:17 ` Josh Poimboeuf
2020-02-13 22:37 ` Fangrui Song
2020-02-13 23:16 ` Josh Poimboeuf [this message]
2020-02-13 22:55 ` Nick Desaulniers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200213231651.alogip6tupegsbvq@treble \
--to=jpoimboe@redhat.com \
--cc=clang-built-linux@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maskray@google.com \
--cc=natechancellor@gmail.com \
--cc=ndesaulniers@google.com \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).