| 4294 | { |
| 4295 | public: |
| 4296 | virtual bool ApplyRelocation(Ref<BinaryView> view, Ref<Architecture> arch, Ref<Relocation> reloc, uint8_t* dest, size_t len) override |
| 4297 | { |
| 4298 | BNRelocationInfo info = reloc->GetInfo(); |
| 4299 | switch (info.nativeType) |
| 4300 | { |
| 4301 | case R_X86_64_REX_GOTPCRELX: { |
| 4302 | // When we're actually applying this we don't need to change the 3 first bytes, |
| 4303 | // just apply it to the immediate and it's fine. However, we track all seven |
| 4304 | // variable bytes so we don't lie to the user. |
| 4305 | dest += 3; |
| 4306 | uint64_t pc = reloc->GetAddress() + 3; |
| 4307 | uint64_t addend = 0; |
| 4308 | if (info.implicitAddend && info.size < sizeof(addend)) |
| 4309 | memcpy(&addend, dest, reloc->GetInfo().size); |
| 4310 | else |
| 4311 | addend = info.addend; |
| 4312 | uint32_t write = (uint32_t)(reloc->GetTarget() + addend - pc); |
| 4313 | memcpy(dest, (uint8_t*)&write, sizeof(uint32_t)); |
| 4314 | return true; |
| 4315 | } |
| 4316 | case R_X86_64_IRELATIVE: { |
| 4317 | // What??????? |
| 4318 | uint64_t write = info.addend; |
| 4319 | memcpy(dest, (uint8_t*)&write, sizeof(uint64_t)); |
| 4320 | return true; |
| 4321 | } |
| 4322 | default: |
| 4323 | return RelocationHandler::ApplyRelocation(view, arch, reloc, dest, len); |
| 4324 | } |
| 4325 | } |
| 4326 | |
| 4327 | virtual bool GetRelocationInfo(Ref<BinaryView> view, Ref<Architecture> arch, vector<BNRelocationInfo>& result) override |
| 4328 | { |
nothing calls this directly
no test coverage detected