mirror of
https://github.com/intel/llvm.git
synced 2026-01-31 16:29:50 +08:00
[ELF] Make TrapInstr and Filler byte arrays. NFC.
The uint32_t type does not clearly convey that these fields are interpreted in the target endianness. Converting them to byte arrays should make this more obvious and less error-prone. Patch by James Clarke Differential Revision: http://reviews.llvm.org/D54207 llvm-svn: 346893
This commit is contained in:
@@ -78,8 +78,8 @@ private:
|
||||
|
||||
SymbolAssignment *readSymbolAssignment(StringRef Name);
|
||||
ByteCommand *readByteCommand(StringRef Tok);
|
||||
uint32_t readFill();
|
||||
uint32_t parseFill(StringRef Tok);
|
||||
std::array<uint8_t, 4> readFill();
|
||||
std::array<uint8_t, 4> parseFill(StringRef Tok);
|
||||
bool readSectionDirective(OutputSection *Cmd, StringRef Tok1, StringRef Tok2);
|
||||
void readSectionAddressType(OutputSection *Cmd);
|
||||
OutputSection *readOverlaySectionDescription();
|
||||
@@ -727,9 +727,9 @@ Expr ScriptParser::readAssert() {
|
||||
// alias for =fillexp section attribute, which is different from
|
||||
// what GNU linkers do.
|
||||
// https://sourceware.org/binutils/docs/ld/Output-Section-Data.html
|
||||
uint32_t ScriptParser::readFill() {
|
||||
std::array<uint8_t, 4> ScriptParser::readFill() {
|
||||
expect("(");
|
||||
uint32_t V = parseFill(next());
|
||||
std::array<uint8_t, 4> V = parseFill(next());
|
||||
expect(")");
|
||||
return V;
|
||||
}
|
||||
@@ -879,13 +879,13 @@ OutputSection *ScriptParser::readOutputSectionDescription(StringRef OutSec) {
|
||||
// When reading a hexstring, ld.bfd handles it as a blob of arbitrary
|
||||
// size, while ld.gold always handles it as a 32-bit big-endian number.
|
||||
// We are compatible with ld.gold because it's easier to implement.
|
||||
uint32_t ScriptParser::parseFill(StringRef Tok) {
|
||||
std::array<uint8_t, 4> ScriptParser::parseFill(StringRef Tok) {
|
||||
uint32_t V = 0;
|
||||
if (!to_integer(Tok, V))
|
||||
setError("invalid filler expression: " + Tok);
|
||||
|
||||
uint32_t Buf;
|
||||
write32be(&Buf, V);
|
||||
std::array<uint8_t, 4> Buf;
|
||||
write32be(Buf.data(), V);
|
||||
return Buf;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user