lkml.org 
[lkml]   [2022]   [May]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] objtool: Fix symbol creation
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

\
 
 \ /
  Last update: 2022-05-18 19:38    [W:0.084 / U:0.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site