summaryrefslogtreecommitdiff
path: root/lld/ELF/LinkerScript.h
diff options
context:
space:
mode:
Diffstat (limited to 'lld/ELF/LinkerScript.h')
-rw-r--r--lld/ELF/LinkerScript.h46
1 files changed, 32 insertions, 14 deletions
diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h
index 25a14e08dade..ec4fc22db486 100644
--- a/lld/ELF/LinkerScript.h
+++ b/lld/ELF/LinkerScript.h
@@ -109,11 +109,11 @@ struct SymbolAssignment : BaseCommand {
std::string commandString;
// Address of this assignment command.
- unsigned addr;
+ uint64_t addr;
// Size of this assignment command. This is usually 0, but if
// you move '.' this may be greater than 0.
- unsigned size;
+ uint64_t size;
};
// Linker scripts allow additional constraints to be put on output sections.
@@ -126,14 +126,14 @@ enum class ConstraintKind { NoConstraint, ReadOnly, ReadWrite };
// target memory. Instances of the struct are created by parsing the
// MEMORY command.
struct MemoryRegion {
- MemoryRegion(StringRef name, uint64_t origin, uint64_t length, uint32_t flags,
+ MemoryRegion(StringRef name, Expr origin, Expr length, uint32_t flags,
uint32_t negFlags)
- : name(name), origin(origin), length(length), flags(flags),
+ : name(std::string(name)), origin(origin), length(length), flags(flags),
negFlags(negFlags) {}
std::string name;
- uint64_t origin;
- uint64_t length;
+ Expr origin;
+ Expr length;
uint32_t flags;
uint32_t negFlags;
uint64_t curPos = 0;
@@ -155,14 +155,16 @@ struct SectionPattern {
};
struct InputSectionDescription : BaseCommand {
- InputSectionDescription(StringRef filePattern)
- : BaseCommand(InputSectionKind), filePat(filePattern) {}
+ InputSectionDescription(StringRef filePattern, uint64_t withFlags = 0,
+ uint64_t withoutFlags = 0)
+ : BaseCommand(InputSectionKind), filePat(filePattern),
+ withFlags(withFlags), withoutFlags(withoutFlags) {}
static bool classof(const BaseCommand *c) {
return c->kind == InputSectionKind;
}
- StringMatcher filePat;
+ SingleStringMatcher filePat;
// Input sections that matches at least one of SectionPatterns
// will be associated with this InputSectionDescription.
@@ -180,6 +182,10 @@ struct InputSectionDescription : BaseCommand {
// they were created in. This is used to insert newly created ThunkSections
// into Sections at the end of a createThunks() pass.
std::vector<std::pair<ThunkSection *, uint32_t>> thunkSections;
+
+ // SectionPatterns can be filtered with the INPUT_SECTION_FLAGS command.
+ uint64_t withFlags;
+ uint64_t withoutFlags;
};
// Represents BYTE(), SHORT(), LONG(), or QUAD().
@@ -202,6 +208,12 @@ struct ByteCommand : BaseCommand {
unsigned size;
};
+struct InsertCommand {
+ OutputSection *os;
+ bool isAfter;
+ StringRef where;
+};
+
struct PhdrsCommand {
StringRef name;
unsigned type = llvm::ELF::PT_NULL;
@@ -233,10 +245,13 @@ class LinkerScript final {
void expandMemoryRegions(uint64_t size);
std::vector<InputSectionBase *>
- computeInputSections(const InputSectionDescription *);
+ computeInputSections(const InputSectionDescription *,
+ ArrayRef<InputSectionBase *>);
std::vector<InputSectionBase *> createInputSectionList(OutputSection &cmd);
+ void discardSynthetic(OutputSection &);
+
std::vector<size_t> getPhdrIndices(OutputSection *sec);
MemoryRegion *findMemoryRegion(OutputSection *sec);
@@ -270,6 +285,7 @@ public:
ExprValue getSymbolValue(StringRef name, const Twine &loc);
void addOrphanSections();
+ void diagnoseOrphanHandling() const;
void adjustSectionsBeforeSorting();
void adjustSectionsAfterSorting();
@@ -305,10 +321,12 @@ public:
// A list of symbols referenced by the script.
std::vector<llvm::StringRef> referencedSymbols;
- // Used to implement INSERT [AFTER|BEFORE]. Contains commands that need
- // to be inserted into SECTIONS commands list.
- llvm::DenseMap<StringRef, std::vector<BaseCommand *>> insertAfterCommands;
- llvm::DenseMap<StringRef, std::vector<BaseCommand *>> insertBeforeCommands;
+ // Used to implement INSERT [AFTER|BEFORE]. Contains output sections that need
+ // to be reordered.
+ std::vector<InsertCommand> insertCommands;
+
+ // Sections that will be warned/errored by --orphan-handling.
+ std::vector<const InputSectionBase *> orphanSections;
};
extern LinkerScript *script;