From: Josh Poimboeuf <jpoimboe@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
llvm@lists.linux.dev, linux-kernel@vger.kernel.org,
kasan-dev@googlegroups.com
Subject: Re: [PATCH] objtool: Fix symbol creation
Date: Wed, 18 May 2022 10:36:04 -0700 [thread overview]
Message-ID: <20220518173604.7gcrjjum6fo2m2ub@treble> (raw)
In-Reply-To: <20220518074152.GB10117@worktop.programming.kicks-ass.net>
On Wed, May 18, 2022 at 09:41:52AM +0200, Peter Zijlstra wrote:
> +static int elf_update_symbol(struct elf *elf, struct section *symtab,
> + struct section *symtab_shndx, struct symbol *sym)
> {
> - Elf_Data *data, *shndx_data = NULL;
> - Elf32_Word first_non_local;
> - struct symbol *sym;
> - Elf_Scn *s;
> -
> - first_non_local = symtab->sh.sh_info;
> -
> - sym = find_symbol_by_index(elf, first_non_local);
> - if (!sym) {
> - WARN("no non-local symbols !?");
> - return first_non_local;
> - }
> + Elf_Data *symtab_data = NULL, *shndx_data = NULL;
> + Elf64_Xword entsize = symtab->sh.sh_entsize;
> + Elf32_Word shndx = sym->sec->idx;
So if it's a global UNDEF symbol then I think 'sym->sec' can be NULL and
this blows up?
> + for (;;) {
> + /* get next data descriptor for the relevant sections */
> + symtab_data = elf_getdata(s, symtab_data);
> + if (t)
> + shndx_data = elf_getdata(t, shndx_data);
> +
> + /* end-of-list */
> + if (!symtab_data) {
> + /* if @idx == 0, it's the next contiguous entry, create it */
> + if (!idx) {
> + void *buf;
Could just do the "index out of range warning" here to reduce the
indentation level.
> + /* setup extended section index magic and write the symbol */
> + if (shndx >= SHN_UNDEF && shndx < SHN_LORESERVE) {
> + sym->sym.st_shndx = shndx;
> + if (!shndx_data)
> + shndx = 0;
I think this '0' is SHN_UNDEF?
Also shouldn't 'sym->sym.st_shndx' get the same value?
--
Josh
next prev parent reply other threads:[~2022-05-18 17:36 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-16 20:47 objtool "no non-local symbols" error with tip of tree LLVM Nathan Chancellor
2022-05-16 21:40 ` Peter Zijlstra
2022-05-16 22:48 ` Nathan Chancellor
2022-05-17 15:33 ` Peter Zijlstra
2022-05-17 15:42 ` Peter Zijlstra
2022-05-17 18:53 ` Nathan Chancellor
2022-05-18 1:24 ` Josh Poimboeuf
2022-05-18 5:30 ` Peter Zijlstra
2022-05-18 16:17 ` Josh Poimboeuf
2022-05-18 17:14 ` Josh Poimboeuf
2022-05-18 17:25 ` Peter Zijlstra
2022-05-18 18:04 ` Josh Poimboeuf
2022-05-18 7:40 ` Peter Zijlstra
2022-05-18 7:41 ` [PATCH] objtool: Fix symbol creation Peter Zijlstra
2022-05-18 17:36 ` Josh Poimboeuf [this message]
2022-05-18 22:10 ` Peter Zijlstra
2022-05-19 9:00 ` [PATCH v2] " Peter Zijlstra
2022-05-19 15:13 ` Josh Poimboeuf
2022-09-07 0:47 ` [PATCH] " Sami Tolvanen
2022-05-19 21:57 ` [tip: objtool/urgent] " tip-bot2 for Peter Zijlstra
2022-05-20 10:53 ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
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=20220518173604.7gcrjjum6fo2m2ub@treble \
--to=jpoimboe@kernel.org \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--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).