forked from OSchip/llvm-project
parent
2f4c121d89
commit
f0403c601a
|
@ -595,7 +595,7 @@ void LinkerScript::assignOffsets(OutputSection *Sec) {
|
|||
}
|
||||
|
||||
// Handle BYTE(), SHORT(), LONG(), or QUAD().
|
||||
if (auto *Cmd = dyn_cast<BytesDataCommand>(Base)) {
|
||||
if (auto *Cmd = dyn_cast<ByteCommand>(Base)) {
|
||||
Cmd->Offset = Dot - Ctx->OutSec->Addr;
|
||||
Dot += Cmd->Size;
|
||||
Ctx->OutSec->Size = Dot - Ctx->OutSec->Addr;
|
||||
|
|
|
@ -75,8 +75,8 @@ enum SectionsCommandKind {
|
|||
AssignmentKind, // . = expr or <sym> = expr
|
||||
OutputSectionKind,
|
||||
InputSectionKind,
|
||||
AssertKind, // ASSERT(expr)
|
||||
BytesDataKind // BYTE(expr), SHORT(expr), LONG(expr) or QUAD(expr)
|
||||
AssertKind, // ASSERT(expr)
|
||||
ByteKind // BYTE(expr), SHORT(expr), LONG(expr) or QUAD(expr)
|
||||
};
|
||||
|
||||
struct BaseCommand {
|
||||
|
@ -165,11 +165,11 @@ struct AssertCommand : BaseCommand {
|
|||
};
|
||||
|
||||
// Represents BYTE(), SHORT(), LONG(), or QUAD().
|
||||
struct BytesDataCommand : BaseCommand {
|
||||
BytesDataCommand(Expr E, unsigned Size)
|
||||
: BaseCommand(BytesDataKind), Expression(E), Size(Size) {}
|
||||
struct ByteCommand : BaseCommand {
|
||||
ByteCommand(Expr E, unsigned Size)
|
||||
: BaseCommand(ByteKind), Expression(E), Size(Size) {}
|
||||
|
||||
static bool classof(const BaseCommand *C) { return C->Kind == BytesDataKind; }
|
||||
static bool classof(const BaseCommand *C) { return C->Kind == ByteKind; }
|
||||
|
||||
Expr Expression;
|
||||
unsigned Offset;
|
||||
|
|
|
@ -412,7 +412,7 @@ template <class ELFT> void OutputSection::writeTo(uint8_t *Buf) {
|
|||
// Linker scripts may have BYTE()-family commands with which you
|
||||
// can write arbitrary bytes to the output. Process them if any.
|
||||
for (BaseCommand *Base : SectionCommands)
|
||||
if (auto *Data = dyn_cast<BytesDataCommand>(Base))
|
||||
if (auto *Data = dyn_cast<ByteCommand>(Base))
|
||||
writeInt(Buf + Data->Offset, Data->Expression().getValue(), Data->Size);
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ private:
|
|||
void readVersionScriptCommand();
|
||||
|
||||
SymbolAssignment *readAssignment(StringRef Name);
|
||||
BytesDataCommand *readBytesDataCommand(StringRef Tok);
|
||||
ByteCommand *readByteCommand(StringRef Tok);
|
||||
uint32_t readFill();
|
||||
uint32_t parseFill(StringRef Tok);
|
||||
void readSectionAddressType(OutputSection *Cmd);
|
||||
|
@ -670,7 +670,7 @@ OutputSection *ScriptParser::readOutputSectionDescription(StringRef OutSec) {
|
|||
// Empty commands are allowed. Do nothing here.
|
||||
} else if (SymbolAssignment *Assign = readProvideOrAssignment(Tok)) {
|
||||
Cmd->SectionCommands.push_back(Assign);
|
||||
} else if (BytesDataCommand *Data = readBytesDataCommand(Tok)) {
|
||||
} else if (ByteCommand *Data = readByteCommand(Tok)) {
|
||||
Cmd->SectionCommands.push_back(Data);
|
||||
} else if (Tok == "ASSERT") {
|
||||
Cmd->SectionCommands.push_back(readAssert());
|
||||
|
@ -888,7 +888,7 @@ static Optional<uint64_t> parseInt(StringRef Tok) {
|
|||
return Val;
|
||||
}
|
||||
|
||||
BytesDataCommand *ScriptParser::readBytesDataCommand(StringRef Tok) {
|
||||
ByteCommand *ScriptParser::readByteCommand(StringRef Tok) {
|
||||
int Size = StringSwitch<int>(Tok)
|
||||
.Case("BYTE", 1)
|
||||
.Case("SHORT", 2)
|
||||
|
@ -897,8 +897,7 @@ BytesDataCommand *ScriptParser::readBytesDataCommand(StringRef Tok) {
|
|||
.Default(-1);
|
||||
if (Size == -1)
|
||||
return nullptr;
|
||||
|
||||
return make<BytesDataCommand>(readParenExpr(), Size);
|
||||
return make<ByteCommand>(readParenExpr(), Size);
|
||||
}
|
||||
|
||||
StringRef ScriptParser::readParenLiteral() {
|
||||
|
|
Loading…
Reference in New Issue