summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-rtdyld
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2018-10-23 01:36:33 +0000
committerLang Hames <lhames@gmail.com>2018-10-23 01:36:33 +0000
commit776f1d50c8e56294274eaea90c51ca8d301e8e47 (patch)
tree6d6ff6244f1185c30748e5ead57db0fe40e7f677 /llvm/tools/llvm-rtdyld
parent3d16af69cfec6073c70d1e54d905b2fd155f25c7 (diff)
downloadbcm5719-llvm-776f1d50c8e56294274eaea90c51ca8d301e8e47.tar.gz
bcm5719-llvm-776f1d50c8e56294274eaea90c51ca8d301e8e47.zip
[RuntimeDyld][COFF] Skip non-loaded sections when calculating ImageBase.
Non-loaded sections (whose unused load-address defaults to zero) should not be taken into account when calculating ImageBase, or ImageBase will be incorrectly set to 0. Patch by Andrew Scheidecker. Thanks Andrew! https://reviews.llvm.org/D51343 + // The Sections list may contain sections that weren't loaded for + // whatever reason: they may be debug sections, and ProcessAllSections + // is false, or they may be sections that contain 0 bytes. If the + // section isn't loaded, the load address will be 0, and it should not + // be included in the ImageBase calculation. llvm-svn: 344995
Diffstat (limited to 'llvm/tools/llvm-rtdyld')
-rw-r--r--llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
index 54db1ec113f..6ef28236574 100644
--- a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
+++ b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
@@ -88,25 +88,30 @@ CheckFiles("check",
cl::desc("File containing RuntimeDyld verifier checks."),
cl::ZeroOrMore);
-static cl::opt<uint64_t>
+// Tracking BUG: 19665
+// http://llvm.org/bugs/show_bug.cgi?id=19665
+//
+// Do not change these options to cl::opt<uint64_t> since this silently breaks
+// argument parsing.
+static cl::opt<unsigned long long>
PreallocMemory("preallocate",
cl::desc("Allocate memory upfront rather than on-demand"),
cl::init(0));
-static cl::opt<uint64_t>
+static cl::opt<unsigned long long>
TargetAddrStart("target-addr-start",
cl::desc("For -verify only: start of phony target address "
"range."),
cl::init(4096), // Start at "page 1" - no allocating at "null".
cl::Hidden);
-static cl::opt<uint64_t>
+static cl::opt<unsigned long long>
TargetAddrEnd("target-addr-end",
cl::desc("For -verify only: end of phony target address range."),
cl::init(~0ULL),
cl::Hidden);
-static cl::opt<uint64_t>
+static cl::opt<unsigned long long>
TargetSectionSep("target-section-sep",
cl::desc("For -verify only: Separation between sections in "
"phony target address space."),
@@ -577,7 +582,11 @@ static void remapSectionsAndSymbols(const llvm::Triple &TargetTriple,
if (LoadAddr &&
*LoadAddr != static_cast<uint64_t>(
reinterpret_cast<uintptr_t>(Tmp->first))) {
- AlreadyAllocated[*LoadAddr] = Tmp->second;
+ // A section will have a LoadAddr of 0 if it wasn't loaded for whatever
+ // reason (e.g. zero byte COFF sections). Don't include those sections in
+ // the allocation map.
+ if (*LoadAddr != 0)
+ AlreadyAllocated[*LoadAddr] = Tmp->second;
Worklist.erase(Tmp);
}
}
OpenPOWER on IntegriCloud