From 2eff061162819e00ec6379874ceb47caef17bcba Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Fri, 23 Mar 2018 10:12:33 -0300 Subject: perf annotate: Add "_local" to jump/offset validation routines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Because they all really check if we can access data structures/visual constructs where a "jump" instruction targets code in the same function, i.e. things like: __pthread_mutex_lock /usr/lib64/libpthread-2.26.so 1.95 │ mov __pthread_force_elision,%ecx │ ┌──test %ecx,%ecx 0.07 │ ├──je 60 │ │ test $0x300,%esi │ │↓ jne 60 │ │ or $0x100,%esi │ │ mov %esi,0x10(%rdi) │ 42:│ mov %esi,%edx │ │ lea 0x16(%r8),%rsi │ │ mov %r8,%rdi │ │ and $0x80,%edx │ │ add $0x8,%rsp │ │→ jmpq __lll_lock_elision │ │ nop 0.29 │ 60:└─→and $0x80,%esi 0.07 │ mov $0x1,%edi 0.29 │ xor %eax,%eax 2.53 │ lock cmpxchg %edi,(%r8) And not things like that "jmpq __lll_lock_elision", that instead should behave like a "call" instruction and "jump" to the disassembly of "___lll_lock_elision". Cc: Adrian Hunter Cc: Andi Kleen Cc: David Ahern Cc: Jin Yao Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-3cwx39u3h66dfw9xjrlt7ca2@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/annotate.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'tools/perf/util/annotate.c') diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index c299881c640a..9524f322f597 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -1409,7 +1409,7 @@ static int symbol__parse_objdump_line(struct symbol *sym, FILE *file, if (dl == NULL) return -1; - if (!disasm_line__has_offset(dl)) { + if (!disasm_line__has_local_offset(dl)) { dl->ops.target.offset = dl->ops.target.addr - map__rip_2objdump(map, sym->start); dl->ops.target.offset_avail = true; @@ -2176,11 +2176,10 @@ size_t disasm__fprintf(struct list_head *head, FILE *fp) return printed; } - -bool disasm_line__is_valid_jump(struct disasm_line *dl, struct symbol *sym) +bool disasm_line__is_valid_local_jump(struct disasm_line *dl, struct symbol *sym) { if (!dl || !dl->ins.ops || !ins__is_jump(&dl->ins) || - !disasm_line__has_offset(dl) || dl->ops.target.offset < 0 || + !disasm_line__has_local_offset(dl) || dl->ops.target.offset < 0 || dl->ops.target.offset >= (s64)symbol__size(sym)) return false; @@ -2201,7 +2200,7 @@ void annotation__mark_jump_targets(struct annotation *notes, struct symbol *sym) dl = disasm_line(al); - if (!disasm_line__is_valid_jump(dl, sym)) + if (!disasm_line__is_valid_local_jump(dl, sym)) continue; al = notes->offsets[dl->ops.target.offset]; -- cgit