summaryrefslogtreecommitdiffstats
path: root/lld
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2017-04-06 21:31:24 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2017-04-06 21:31:24 +0000
commitfeed7506767533338c0f990237452e3f69de0eae (patch)
tree0f625caa07b8572976b839e1ab26c10976a095f1 /lld
parenta521c30dc6a6a81040a02e405aa1b671e8687059 (diff)
downloadbcm5719-llvm-feed7506767533338c0f990237452e3f69de0eae.tar.gz
bcm5719-llvm-feed7506767533338c0f990237452e3f69de0eae.zip
Move call to findMemoryRegion before assignAddresses.
This removes a bit more work from assignAddresses. llvm-svn: 299716
Diffstat (limited to 'lld')
-rw-r--r--lld/ELF/LinkerScript.cpp8
-rw-r--r--lld/ELF/LinkerScript.h25
2 files changed, 19 insertions, 14 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index f20dbff3f31..d97db847304 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -583,8 +583,7 @@ void LinkerScript::assignOffsets(OutputSectionCommand *Cmd) {
if (Cmd->AlignExpr)
Sec->updateAlignment(Cmd->AlignExpr().getValue());
- // Try and find an appropriate memory region to assign offsets in.
- CurMemRegion = findMemoryRegion(Cmd);
+ CurMemRegion = Cmd->MemRegion;
if (CurMemRegion)
Dot = CurMemRegion->Offset;
switchTo(Sec);
@@ -657,6 +656,11 @@ void LinkerScript::adjustSectionsBeforeSorting() {
void LinkerScript::adjustSectionsAfterSorting() {
placeOrphanSections();
+ // Try and find an appropriate memory region to assign offsets in.
+ for (BaseCommand *Base : Opt.Commands)
+ if (auto *Cmd = dyn_cast<OutputSectionCommand>(Base))
+ Cmd->MemRegion = findMemoryRegion(Cmd);
+
// If output section command doesn't specify any segments,
// and we haven't previously assigned any section to segment,
// then we simply assign section to the very first load segment.
diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h
index f27eb651cda..9841f4f7c14 100644
--- a/lld/ELF/LinkerScript.h
+++ b/lld/ELF/LinkerScript.h
@@ -99,6 +99,18 @@ struct SymbolAssignment : BaseCommand {
// with ONLY_IF_RW is created if all input sections are RW.
enum class ConstraintKind { NoConstraint, ReadOnly, ReadWrite };
+// This struct is used to represent the location and size of regions of
+// target memory. Instances of the struct are created by parsing the
+// MEMORY command.
+struct MemoryRegion {
+ std::string Name;
+ uint64_t Origin;
+ uint64_t Length;
+ uint64_t Offset;
+ uint32_t Flags;
+ uint32_t NegFlags;
+};
+
struct OutputSectionCommand : BaseCommand {
OutputSectionCommand(StringRef Name)
: BaseCommand(OutputSectionKind), Name(Name) {}
@@ -106,6 +118,7 @@ struct OutputSectionCommand : BaseCommand {
static bool classof(const BaseCommand *C);
OutputSection *Sec = nullptr;
+ MemoryRegion *MemRegion = nullptr;
StringRef Name;
Expr AddrExpr;
Expr AlignExpr;
@@ -177,18 +190,6 @@ struct PhdrsCommand {
Expr LMAExpr;
};
-// This struct is used to represent the location and size of regions of
-// target memory. Instances of the struct are created by parsing the
-// MEMORY command.
-struct MemoryRegion {
- std::string Name;
- uint64_t Origin;
- uint64_t Length;
- uint64_t Offset;
- uint32_t Flags;
- uint32_t NegFlags;
-};
-
// ScriptConfiguration holds linker script parse results.
struct ScriptConfiguration {
// Used to assign addresses to sections.
OpenPOWER on IntegriCloud