Loading arch/x86/Kconfig +1 −1 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ config X86 select ARCH_HAS_FILTER_PGPROT select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_KCOV if X86_64 select ARCH_HAS_KCOV if X86_64 && STACK_VALIDATION select ARCH_HAS_MEM_ENCRYPT select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE Loading tools/objtool/arch.h +2 −0 Original line number Diff line number Diff line Loading @@ -84,4 +84,6 @@ unsigned long arch_jump_destination(struct instruction *insn); unsigned long arch_dest_reloc_offset(int addend); const char *arch_nop_insn(int len); #endif /* _ARCH_H */ tools/objtool/arch/x86/decode.c +18 −0 Original line number Diff line number Diff line Loading @@ -565,3 +565,21 @@ void arch_initial_func_cfi_state(struct cfi_init_state *state) state->regs[16].base = CFI_CFA; state->regs[16].offset = -8; } const char *arch_nop_insn(int len) { static const char nops[5][5] = { /* 1 */ { 0x90 }, /* 2 */ { 0x66, 0x90 }, /* 3 */ { 0x0f, 0x1f, 0x00 }, /* 4 */ { 0x0f, 0x1f, 0x40, 0x00 }, /* 5 */ { 0x0f, 0x1f, 0x44, 0x00, 0x00 }, }; if (len < 1 || len > 5) { WARN("invalid NOP size: %d\n", len); return NULL; } return nops[len-1]; } tools/objtool/arch/x86/include/arch_elf.h 0 → 100644 +6 −0 Original line number Diff line number Diff line #ifndef _OBJTOOL_ARCH_ELF #define _OBJTOOL_ARCH_ELF #define R_NONE R_X86_64_NONE #endif /* _OBJTOOL_ARCH_ELF */ tools/objtool/check.c +22 −1 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ #include "check.h" #include "special.h" #include "warn.h" #include "arch_elf.h" #include <linux/hashtable.h> #include <linux/kernel.h> Loading Loading @@ -765,6 +766,24 @@ static int add_call_destinations(struct objtool_file *file) } else insn->call_dest = reloc->sym; /* * Many compilers cannot disable KCOV with a function attribute * so they need a little help, NOP out any KCOV calls from noinstr * text. */ if (insn->sec->noinstr && !strncmp(insn->call_dest->name, "__sanitizer_cov_", 16)) { if (reloc) { reloc->type = R_NONE; elf_write_reloc(file->elf, reloc); } elf_write_insn(file->elf, insn->sec, insn->offset, insn->len, arch_nop_insn(insn->len)); insn->type = INSN_NOP; } /* * Whatever stack impact regular CALLs have, should be undone * by the RETURN of the called function. Loading Loading @@ -2740,7 +2759,7 @@ int check(const char *_objname, bool orc) objname = _objname; file.elf = elf_open_read(objname, orc ? O_RDWR : O_RDONLY); file.elf = elf_open_read(objname, O_RDWR); if (!file.elf) return 1; Loading Loading @@ -2801,7 +2820,9 @@ int check(const char *_objname, bool orc) ret = create_orc_sections(&file); if (ret < 0) goto out; } if (file.elf->changed) { ret = elf_write(file.elf); if (ret < 0) goto out; Loading Loading
arch/x86/Kconfig +1 −1 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ config X86 select ARCH_HAS_FILTER_PGPROT select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_KCOV if X86_64 select ARCH_HAS_KCOV if X86_64 && STACK_VALIDATION select ARCH_HAS_MEM_ENCRYPT select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE Loading
tools/objtool/arch.h +2 −0 Original line number Diff line number Diff line Loading @@ -84,4 +84,6 @@ unsigned long arch_jump_destination(struct instruction *insn); unsigned long arch_dest_reloc_offset(int addend); const char *arch_nop_insn(int len); #endif /* _ARCH_H */
tools/objtool/arch/x86/decode.c +18 −0 Original line number Diff line number Diff line Loading @@ -565,3 +565,21 @@ void arch_initial_func_cfi_state(struct cfi_init_state *state) state->regs[16].base = CFI_CFA; state->regs[16].offset = -8; } const char *arch_nop_insn(int len) { static const char nops[5][5] = { /* 1 */ { 0x90 }, /* 2 */ { 0x66, 0x90 }, /* 3 */ { 0x0f, 0x1f, 0x00 }, /* 4 */ { 0x0f, 0x1f, 0x40, 0x00 }, /* 5 */ { 0x0f, 0x1f, 0x44, 0x00, 0x00 }, }; if (len < 1 || len > 5) { WARN("invalid NOP size: %d\n", len); return NULL; } return nops[len-1]; }
tools/objtool/arch/x86/include/arch_elf.h 0 → 100644 +6 −0 Original line number Diff line number Diff line #ifndef _OBJTOOL_ARCH_ELF #define _OBJTOOL_ARCH_ELF #define R_NONE R_X86_64_NONE #endif /* _OBJTOOL_ARCH_ELF */
tools/objtool/check.c +22 −1 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ #include "check.h" #include "special.h" #include "warn.h" #include "arch_elf.h" #include <linux/hashtable.h> #include <linux/kernel.h> Loading Loading @@ -765,6 +766,24 @@ static int add_call_destinations(struct objtool_file *file) } else insn->call_dest = reloc->sym; /* * Many compilers cannot disable KCOV with a function attribute * so they need a little help, NOP out any KCOV calls from noinstr * text. */ if (insn->sec->noinstr && !strncmp(insn->call_dest->name, "__sanitizer_cov_", 16)) { if (reloc) { reloc->type = R_NONE; elf_write_reloc(file->elf, reloc); } elf_write_insn(file->elf, insn->sec, insn->offset, insn->len, arch_nop_insn(insn->len)); insn->type = INSN_NOP; } /* * Whatever stack impact regular CALLs have, should be undone * by the RETURN of the called function. Loading Loading @@ -2740,7 +2759,7 @@ int check(const char *_objname, bool orc) objname = _objname; file.elf = elf_open_read(objname, orc ? O_RDWR : O_RDONLY); file.elf = elf_open_read(objname, O_RDWR); if (!file.elf) return 1; Loading Loading @@ -2801,7 +2820,9 @@ int check(const char *_objname, bool orc) ret = create_orc_sections(&file); if (ret < 0) goto out; } if (file.elf->changed) { ret = elf_write(file.elf); if (ret < 0) goto out; Loading