Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tests: Decompress kernel module before objdump

If a kernel modules is compressed, it should be decompressed before
running objdump to parse binary data correctly. This fixes a failure of
object code reading test for me.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: kernel-team@lge.com
Link: http://lkml.kernel.org/r/20170608073109.30699-8-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Namhyung Kim and committed by
Arnaldo Carvalho de Melo
94df1040 8ba29adf

+19 -1
+19 -1
tools/perf/tests/code-reading.c
··· 229 229 unsigned char buf2[BUFSZ]; 230 230 size_t ret_len; 231 231 u64 objdump_addr; 232 + const char *objdump_name; 233 + char decomp_name[KMOD_DECOMP_LEN]; 232 234 int ret; 233 235 234 236 pr_debug("Reading object code for memory address: %#"PRIx64"\n", addr); ··· 291 289 state->done[state->done_cnt++] = al.map->start; 292 290 } 293 291 292 + objdump_name = al.map->dso->long_name; 293 + if (dso__needs_decompress(al.map->dso)) { 294 + if (dso__decompress_kmodule_path(al.map->dso, objdump_name, 295 + decomp_name, 296 + sizeof(decomp_name)) < 0) { 297 + pr_debug("decompression failed\n"); 298 + return -1; 299 + } 300 + 301 + objdump_name = decomp_name; 302 + } 303 + 294 304 /* Read the object code using objdump */ 295 305 objdump_addr = map__rip_2objdump(al.map, al.addr); 296 - ret = read_via_objdump(al.map->dso->long_name, objdump_addr, buf2, len); 306 + ret = read_via_objdump(objdump_name, objdump_addr, buf2, len); 307 + 308 + if (dso__needs_decompress(al.map->dso)) 309 + unlink(objdump_name); 310 + 297 311 if (ret > 0) { 298 312 /* 299 313 * The kernel maps are inaccurate - assume objdump is right in