objtool fixes
Linus,
Please pull the latest objtool/urgent git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git objtool-urgent-2021-06-12
# HEAD: 2d49b721dc18c113d5221f4cf5a6104eb66cb7f2 objtool: Only rewrite unconditional retpoline thunk calls
Two objtool fixes:
- fix a bug that corrupts the code by mistakenly rewriting conditional jumps,
- and fix another bug generating an incorrect ELF symbol table during retpoline rewriting.
Thanks,
Ingo
------------------>
Peter Zijlstra (2):
objtool: Fix .symtab_shndx handling for elf_create_undef_symbol()
objtool: Only rewrite unconditional retpoline thunk calls
tools/objtool/arch/x86/decode.c | 4 ++++ tools/objtool/elf.c | 25 ++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-)
tools/objtool/arch/x86/decode.c +4 -0
@@ -747,6 +747,10 @@ int arch_rewrite_retpolines(struct objtool_file *file)list_for_each_entry (insn, &file->retpoline_call_list, call_node) { +if (insn->type !=INSN_JUMP_DYNAMIC && + insn->type !=INSN_CALL_DYNAMIC ) +continue ; +if (!strcmp (insn->sec->name,".text.__x86.indirect_thunk" ))continue ;
tools/objtool/elf.c +24 -1
@@ -717,7 +717,7 @@ static int elf_add_string(struct elf *elf, struct section *strtab, char *str)struct symbol *elf_create_undef_symbol (struct elf *elf,const char *name) { -struct section *symtab; +struct section *symtab, *symtab_shndx;struct symbol *sym;Elf_Data *data;Elf_Scn *s;
@@ -769,6 +769,29 @@ struct symbol *elf_create_undef_symbol(struct elf *elf, const char *name) symtab->len += data->d_size; symtab->changed = true; + symtab_shndx =find_section_by_name (elf,".symtab_shndx" ); +if (symtab_shndx) { + s =elf_getscn (elf->elf, symtab_shndx->idx); +if (!s) { +WARN_ELF ("elf_getscn" ); +return NULL ; + } + + data =elf_newdata (s); +if (!data) { +WARN_ELF ("elf_newdata" ); +return NULL ; + } + + data->d_buf = &sym->sym.st_size;/* conveniently 0 */ + data->d_size =sizeof (Elf32_Word); + data->d_align =4 ; + data->d_type =ELF_T_WORD ; + + symtab_shndx->len +=4 ; + symtab_shndx->changed = true; + } + sym->sec =find_section_by_index (elf,0 );elf_add_symbol (elf, sym);
The pull request you sent on Sat, 12 Jun 2021 14:37:46 +0200:
The pull request you sent on Sat, 12 Jun 2021 14:37:46 +0200:
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gitobjtool-urgent-2021-06-12
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/768895fb774d7af32d17cf3a455b0bd6df272f14
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/prtracker.html