Bug 1542958 - fix code section adjustments in elfhack; r=glandium
authorNathan Froyd <froydnj@mozilla.com>
Mon, 22 Apr 2019 23:44:28 +0000
changeset 470426 09240f7397c12707cc0a8ff63051d28568be40e9
parent 470425 8858cc62fe60eab511ed28bdf7f46bd718cdd417
child 470427 181f8519792032d158f03d2757724df99955cd44
push id35905
push userdvarga@mozilla.com
push dateTue, 23 Apr 2019 09:53:27 +0000
treeherdermozilla-central@831918f009f6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1542958
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1542958 - fix code section adjustments in elfhack; r=glandium We were never adjusting `last` in this loop, so we were computing the wrong addresses for all sections beyond the first. Which in turn meant that we would compute the wrong size for the section data we needed to allocate. Differential Revision: https://phabricator.services.mozilla.com/D28195
build/unix/elfhack/elfhack.cpp
--- a/build/unix/elfhack/elfhack.cpp
+++ b/build/unix/elfhack/elfhack.cpp
@@ -172,16 +172,17 @@ class ElfRelHackCode_Section : public El
       unsigned int addr = last->getShdr().sh_addr + last->getSize();
       if (addr & ((*c)->getAddrAlign() - 1))
         addr = (addr | ((*c)->getAddrAlign() - 1)) + 1;
       (*c)->getShdr().sh_addr = addr;
       // We need to align this section depending on the greater
       // alignment required by code sections.
       if (shdr.sh_addralign < (*c)->getAddrAlign())
         shdr.sh_addralign = (*c)->getAddrAlign();
+      last = *c;
     }
     shdr.sh_size = code.back()->getAddr() + code.back()->getSize();
     data = static_cast<char *>(malloc(shdr.sh_size));
     if (!data) {
       throw std::runtime_error("Could not malloc ElfSection data");
     }
     char *buf = data;
     for (c = code.begin(); c != code.end(); ++c) {