[lld] r299716 - Move call to findMemoryRegion before assignAddresses.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 6 14:31:25 PDT 2017
Author: rafael
Date: Thu Apr 6 16:31:24 2017
New Revision: 299716
URL: http://llvm.org/viewvc/llvm-project?rev=299716&view=rev
Log:
Move call to findMemoryRegion before assignAddresses.
This removes a bit more work from assignAddresses.
Modified:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/ELF/LinkerScript.h
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=299716&r1=299715&r2=299716&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Thu Apr 6 16:31:24 2017
@@ -583,8 +583,7 @@ void LinkerScript::assignOffsets(OutputS
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::adjustSectionsBeforeS
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.
Modified: lld/trunk/ELF/LinkerScript.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.h?rev=299716&r1=299715&r2=299716&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.h (original)
+++ lld/trunk/ELF/LinkerScript.h Thu Apr 6 16:31:24 2017
@@ -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 : BaseComman
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.
More information about the llvm-commits
mailing list