summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorAgent Orange <codegeek98@gmail.com>2017-03-31 18:46:55 +0200
committerPale Moon <git-repo@palemoon.org>2017-03-31 18:46:55 +0200
commit9c7e00fc9f0b7a49d2675c8077ccd2b56f183a81 (patch)
treea888ef938279736127d6ff3975c217f4b17dac9b /build
parentff86d8dc0bee58e55c019aa2885a42789b643e12 (diff)
downloadpalemoon-gre-9c7e00fc9f0b7a49d2675c8077ccd2b56f183a81.tar.gz
Work around recent GNU gold behavior with segments starting before the first section they contain.
Diffstat (limited to 'build')
-rw-r--r--build/unix/elfhack/elf.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/build/unix/elfhack/elf.cpp b/build/unix/elfhack/elf.cpp
index 666b5351e..743afdead 100644
--- a/build/unix/elfhack/elf.cpp
+++ b/build/unix/elfhack/elf.cpp
@@ -258,7 +258,10 @@ Elf::Elf(std::ifstream &file)
segment->addSection(sections[j]);
// Make sure that our view of segments corresponds to the original
// ELF file.
- assert(segment->getFileSize() == phdr.p_filesz);
+ // GNU gold likes to start some segments before the first section
+ // they contain. https://sourceware.org/bugzilla/show_bug.cgi?id=19392
+ unsigned int gold_adjustment = segment->getAddr() - phdr.p_vaddr;
+ assert(segment->getFileSize() == phdr.p_filesz - gold_adjustment);
// gold makes TLS segments end on an aligned virtual address, even
// when the underlying section ends before that, while bfd ld
// doesn't. It's fine if we don't keep that alignment.
@@ -267,7 +270,7 @@ Elf::Elf(std::ifstream &file)
unsigned int align = segment->getAlign();
memsize = (memsize + align - 1) & ~(align - 1);
}
- assert(memsize == phdr.p_memsz);
+ assert(memsize == phdr.p_memsz - gold_adjustment);
segments.push_back(segment);
}