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