• Athira Rajeev's avatar
    perf symbols: Fix DSO kernel load and symbol process to correctly map DSO to... · e59fea47
    Athira Rajeev authored
    perf symbols: Fix DSO kernel load and symbol process to correctly map DSO to its long_name, type and adjust_symbols
    
    Test "object code reading" fails sometimes for kernel address as below:
    
        Reading object code for memory address: 0xc000000000004c3c
        File is: [kernel.kallsyms]
        On file address is: 0x14c3c
        dso__data_read_offset failed
        test child finished with -1
        ---- end ----
        Object code reading: FAILED!
    
    Here dso__data_read_offset() fails for symbol address
    0xc000000000004c3c. This is because the DSO long_name here is
    "[kernel.kallsyms]" and hence open_dso() fails to open this file. There
    is an incorrect DSO to map handling here. The key points here are:
    
    - The DSO long_name is set to "[kernel.kallsyms]". This file is
      not present and hence returns error
    - The DSO binary type is set to DSO_BINARY_TYPE__NOT_FOUND
    - The DSO adjust_symbols member is set to zero
    
    In the end dso__data_read_offset() returns -1 and the address 0x14c3c
    can not be resolved. Hence the test fails. But the address actually maps
    to the kernel DSO
    
        # objdump -z -d --start-address=0xc000000000004c3c --stop-address=0xc000000000004cbc /home/athira/linux/vmlinux
    
        /home/athira/linux/vmlinux:     file format elf64-powerpcle
    
        Disassembly of section .head.text:
    
        c000000000004c3c <exc_virt_0x4c00_system_call+0x3c>:
        c000000000004c3c:	a6 02 9b 7d 	mfsrr1  r12
        c000000000004c40:	78 13 42 7c 	mr      r2,r2
        c000000000004c44:	18 00 4d e9 	ld      r10,24(r13)
        c000000000004c48:	60 c6 4a 61 	ori     r10,r10,50784
        c000000000004c4c:	a6 03 49 7d 	mtctr   r10
    
    Fix dso__process_kernel_symbol() to set the binary_type and
    adjust_symbols members. dso->adjust_symbols is used by
    map__rip_2objdump() which converts the symbol start address to the
    objdump address. Also set dso->long_name in dso__load_vmlinux().
    Suggested-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
    Signed-off-by: default avatarAthira Rajeev <atrajeev@linux.vnet.ibm.com>
    Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
    Cc: Disha Goel <disgoel@linux.vnet.ibm.com>
    Cc: Ian Rogers <irogers@google.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Kajol Jain <kjain@linux.ibm.com>
    Cc: Madhavan Srinivasan <maddy@linux.ibm.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: linuxppc-dev@lists.ozlabs.org
    Link: https://lore.kernel.org/r/20230811051546.70039-1-atrajeev@linux.vnet.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
    e59fea47
symbol-elf.c 66 KB