Bug 1481861 - Move the eh_frame sections when they are before the first executable section. r=froydnj

In some rare cases, it is possible for one of the eh_frame sections'
original address to be larger than the address of the injected code
section, which is added before the first executable section. Namely,
this happens in the rare case where that eh_frame section is smaller
than the injected code section, and is adjacent to the first executable
section. We obviously want to move the eh_frame sections in that case,
since one of them is in the way.
This commit is contained in:
Mike Hommey 2018-08-10 18:01:15 +09:00
parent c64a283779
commit 6e62bce406

View File

@ -1109,7 +1109,7 @@ int do_relocation_section(Elf *elf, unsigned int rel_type, unsigned int rel_type
if (eh_frame_hdr && (!eh_frame || strcmp(eh_frame->getName(), ".eh_frame"))) {
throw std::runtime_error("Expected to find an .eh_frame section adjacent to .eh_frame_hdr");
}
if (eh_frame && first->getAddr() > relhack->getAddr() && second->getAddr() < relhackcode->getAddr()) {
if (eh_frame && first->getAddr() > relhack->getAddr() && second->getAddr() < first_executable->getAddr()) {
// The distance between both sections needs to be preserved because eh_frame_hdr
// contains relative offsets to eh_frame. Well, they could be relocated too, but
// it's not worth the effort for the few number of bytes this would save.