From 6e62bce406744402d0f186341f71144ea6399cbd Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Fri, 10 Aug 2018 18:01:15 +0900 Subject: [PATCH] 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. --- build/unix/elfhack/elfhack.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/unix/elfhack/elfhack.cpp b/build/unix/elfhack/elfhack.cpp index 1d1177ee1633..6b116a5d1037 100644 --- a/build/unix/elfhack/elfhack.cpp +++ b/build/unix/elfhack/elfhack.cpp @@ -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.