facebookarchive / BOLT

Binary Optimization and Layout Tool - A linux command-line utility used for optimizing performance of binaries
2.52k stars 178 forks source link

Update allocatable relocations dynamically #239

Closed yota9 closed 2 years ago

yota9 commented 3 years ago

This patch changes patchELFAllocatableRelaSections from going through old relocations sections and update the relocation offsets to emitting the relocations stored in binary sections. This is needed in case we would like to remove and add dynamic relocations during BOLT work and it is used by golang support pass. Note: Currently we emit relocations in the old sections, so we the total number of them should be equal or less of old number.

Vladislav Khmelevsky, Advanced Software Technology Lab, Huawei

rafaelauler commented 2 years ago

Is it possible to add a test case?

yota9 commented 2 years ago

Hello @rafaelauler ! Well what kind of testcase? Every PIC binary is the test case, since we will need to patch relative (and irelative) relocations.. So I don't see some specific test case here UPD: If we are talking about adding/removing relocations currently the testcase is impossible, since there is no such code. But! It is not a major thing here, I only pointed out why we may need this, it does not really matter where the relocations are came from - from the original binary or during bolt execution. The major thing here is the patch algorithm by it self, that touches every single PIC binary, C/C++ or Golang binary it does not really matter. So my IMHO that this patch should be submitted separately from golang changes, since you also need to test that your internal tests are OK and the design of this solution is appropriate :)