+ case elfcpp::R_X86_64_PC32:
+ {
+ // This relocation may be used both for function calls and
+ // for taking address of a function. We distinguish between
+ // them by checking the opcodes.
+ uint64_t sh_flags = src_obj->section_flags(src_indx);
+ bool is_executable = (sh_flags & elfcpp::SHF_EXECINSTR) != 0;
+ if (is_executable)
+ {
+ section_size_type stype;
+ const unsigned char* view = src_obj->section_contents(src_indx,
+ &stype,
+ true);
+
+ // call
+ if (r_offset >= 1
+ && view[r_offset - 1] == 0xe8)
+ return false;
+
+ // jmp
+ if (r_offset >= 1
+ && view[r_offset - 1] == 0xe9)
+ return false;
+
+ // jo/jno/jb/jnb/je/jne/jna/ja/js/jns/jp/jnp/jl/jge/jle/jg
+ if (r_offset >= 2
+ && view[r_offset - 2] == 0x0f
+ && view[r_offset - 1] >= 0x80
+ && view[r_offset - 1] <= 0x8f)
+ return false;
+ }
+
+ // Be conservative and treat all others as function pointers.
+ return true;
+ }