MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / GetRelocationInfo

Method GetRelocationInfo

arch/x86/arch_x86.cpp:4327–4481  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4325 }
4326
4327 virtual bool GetRelocationInfo(Ref<BinaryView> view, Ref<Architecture> arch, vector<BNRelocationInfo>& result) override
4328 {
4329 /*
4330 From the Intel AMD64 ELF Linux ABI
4331 A Represents the addend used to compute the value of the relocatable field.
4332 B Represents the base address at which a shared object has been loaded into memory during execution.
4333 Generally, a shared object is built with a 0 base virtual address, but the execution address will be different.
4334 G Represents the offset into the global offset table at which the relocation entry’s symbol
4335 will reside during execution.
4336 GOT Represents the address of the global offset table.
4337 L Represents the place (section offset or address) of the Procedure Linkage Table
4338 entry for a symbol.
4339 P Represents the place (section offset or address) of the storage unit being relocated (computed using r_offset).
4340 S Represents the value of the symbol whose index resides in the relocation entry.
4341 Z Represents the size of the symbol whose index resides in the relocation entry.
4342 The AMD64 LP64 ABI architecture uses only Elf64_Rela relocation entries with explicit addends. Theg
4343 r_addend member serves as the relocation addend.
4344 The AMD64 ILP32 ABI architecture uses only Elf32_Rela relocation entries in relocatable files. Relocations
4345 contained within executable files or shared objects may use either Elf32_Rela relocation or Elf32_Rel relocation.
4346 */
4347 (void)view; (void)arch;
4348 set<uint64_t> relocTypes;
4349 for (auto& reloc : result)
4350 {
4351 reloc.type = StandardRelocationType;
4352 switch (reloc.nativeType)
4353 {
4354 case R_X86_64_NONE:
4355 reloc.type = IgnoredRelocation;
4356 break;
4357 case R_X86_64_COPY:
4358 reloc.type = ELFCopyRelocationType;
4359 reloc.pcRelative = false;
4360 reloc.baseRelative = false;
4361 reloc.size = 8;
4362 reloc.truncateSize = 8;
4363 break;
4364 case R_X86_64_GLOB_DAT:
4365 reloc.type = ELFGlobalRelocationType;
4366 reloc.pcRelative = false;
4367 reloc.baseRelative = false;
4368 reloc.size = 8;
4369 reloc.truncateSize = 8;
4370 break;
4371 case R_X86_64_JUMP_SLOT:
4372 reloc.type = ELFJumpSlotRelocationType;
4373 reloc.pcRelative = false;
4374 reloc.baseRelative = false;
4375 reloc.size = 8;
4376 reloc.truncateSize = 8;
4377 break;
4378 case R_X86_64_8:
4379 reloc.pcRelative = false;
4380 reloc.baseRelative = false;
4381 reloc.hasSign = false;
4382 reloc.size = 1;
4383 reloc.truncateSize = 1;
4384 break;

Callers

nothing calls this directly

Calls 2

GetRelocationStringFunction · 0.70
insertMethod · 0.45

Tested by

no test coverage detected