Skip to content

Instantly share code, notes, and snippets.

@nickdesaulniers
Last active July 1, 2019 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickdesaulniers/c0cb8fc67720a5abbadf42fde5440a8e to your computer and use it in GitHub Desktop.
Save nickdesaulniers/c0cb8fc67720a5abbadf42fde5440a8e to your computer and use it in GitHub Desktop.
; $ objdump -d -r -j __jump_table arch/x86/kernel/cpu/mtrr/generic.o
arch/x86/kernel/cpu/mtrr/generic.o: file format elf64-x86-64
Disassembly of section __jump_table:
0000000000000000 <__jump_table>:
...
10: R_X86_64_PC32 .text+0x3f9
14: R_X86_64_PC32 .text+0x400
18: R_X86_64_PC64 __tracepoint_read_msr+0x8
20: R_X86_64_PC32 .text+0x434
24: R_X86_64_PC32 .text+0x400
28: R_X86_64_PC64 __tracepoint_read_msr+0x8
...
; $ gdb -batch -ex "file arch/x86/kernel/cpu/mtrr/generic.o" -ex "disassemble get_fixed_ranges"
Dump of assembler code for function get_fixed_ranges:
...
0x00000000000003f9 <+89>: nopl 0x0(%rax,%rax,1) ---| ; location
0x00000000000003fe <+94>: jmp 0x40f <get_fixed_ranges+111> ---| |
0x0000000000000400 <+96>: mov $0x258,%edi | <---| ; target <---| ; target (actual)
0x0000000000000405 <+101>: mov %rbx,%rsi | ; jmp |
0x0000000000000408 <+104>: xor %edx,%edx | |
0x000000000000040a <+106>: callq 0x40f <get_fixed_ranges+111> | |
0x000000000000040f <+111>: mov %r14d,0x0(%rip) <---| |
0x0000000000000416 <+118>: shr $0x20,%rbx |
0x000000000000041a <+122>: mov %ebx,0x0(%rip) |
0x0000000000000420 <+128>: mov $0x259,%ecx |
0x0000000000000425 <+133>: rdmsr |
0x0000000000000427 <+135>: mov %rax,%r14 |
0x000000000000042a <+138>: mov %rdx,%rbx |
0x000000000000042d <+141>: shl $0x20,%rbx |
0x0000000000000431 <+145>: or %rax,%rbx |
0x0000000000000434 <+148>: nopl 0x0(%rax,%rax,1) ---| ; location
0x0000000000000439 <+153>: jmp 0x44a <get_fixed_ranges+170> ---| |
0x000000000000043b <+155>: mov $0x259,%edi | <---| ; target (expected)
0x0000000000000440 <+160>: mov %rbx,%rsi | ; jump
0x0000000000000443 <+163>: xor %edx,%edx |
0x0000000000000445 <+165>: callq 0x44a <get_fixed_ranges+170> |
0x000000000000044a <+170>: mov %r14d,0x0(%rip) <---|
...
$ make CC=clang
...
arch/x86/kernel/cpu/mtrr/generic.o: warning: objtool: get_fixed_ranges()+0x9b: unreachable instruction
$ python -c 'print(hex(0x3a0 + 0x9b))'
0x43b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment