85 object_error::parse_failed);
101 size_t End = Buf.find(
'\n');
102 Buf = (End == Buf.npos) ?
"" : Buf.drop_front(End);
106 Buf = Buf.drop_front();
107 if (Buf.startswith(
"=")) {
108 Buf = Buf.drop_front();
113 Buf = Buf.drop_front();
121 size_t End = Buf.find_first_of(
"=,;\r\n \t\v");
136 Buf = (End == Buf.npos) ?
"" : Buf.drop_front(End);
137 return Token(K, Word);
149 : Lex(S),
Machine(M), MingwDef(B) {}
153 if (
Error Err = parseOne())
154 return std::move(Err);
155 }
while (Tok.K !=
Eof);
169 Error readAsInt(uint64_t *
I) {
171 if (Tok.K !=
Identifier || Tok.Value.getAsInteger(10, *I))
178 if (Tok.K != Expected)
183 void unget() { Stack.push_back(Tok); }
197 if (
Error Err = parseExport())
201 return parseNumbers(&
Info.HeapReserve, &
Info.HeapCommit);
203 return parseNumbers(&
Info.StackReserve, &
Info.StackCommit);
208 if (
Error Err = parseName(&Name, &
Info.ImageBase))
214 if (
Info.OutputFile.empty()) {
218 Info.OutputFile += IsDll ?
".dll" :
".exe";
226 return createError(
"unknown directive: " + Tok.Value);
230 Error parseExport() {
234 if (Tok.K ==
Equal) {
237 return createError(
"identifier expected, but got " + Tok.Value);
246 E.
Name = (std::string(
"_").append(E.
Name));
253 if (Tok.K ==
Identifier && Tok.Value[0] ==
'@') {
254 if (Tok.Value ==
"@") {
257 Tok.Value.getAsInteger(10, E.
Ordinal);
258 }
else if (Tok.Value.drop_front().getAsInteger(10, E.
Ordinal)) {
262 Info.Exports.push_back(E);
294 Info.Exports.push_back(E);
300 Error parseNumbers(uint64_t *Reserve, uint64_t *Commit) {
301 if (
Error Err = readAsInt(Reserve))
304 if (Tok.K !=
Comma) {
309 if (
Error Err = readAsInt(Commit))
315 Error parseName(std::string *Out, uint64_t *Baseaddr) {
326 if (
Error Err = expect(
Equal,
"'=' expected"))
328 if (
Error Err = readAsInt(Baseaddr))
341 return createError(
"identifier expected, but got " + Tok.Value);
343 std::tie(V1, V2) = Tok.Value.split(
'.');
345 return createError(
"integer expected, but got " + Tok.Value);
349 return createError(
"integer expected, but got " + Tok.Value);
355 std::vector<Token> Stack;
This class represents lattice values for constants.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
LLVM_NODISCARD bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
std::string Name
The name of the export as specified in the .def file or on the command line, i.e. ...
bool has_extension(const Twine &path, Style style=Style::native)
Has extension?
static bool isDecorated(StringRef Sym, bool MingwDef)
Parser(StringRef S, MachineTypes M, bool B)
StringSwitch & Case(StringLiteral S, T Value)
Expected< COFFModuleDefinition > parseCOFFModuleDefinition(MemoryBufferRef MB, COFF::MachineTypes Machine, bool MingwDef=false)
static Error createError(const Twine &Err)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
StringRef getBuffer() const
support::ulittle32_t Word
LLVM_NODISCARD R Default(T Value)
Tagged union holding either a T or a Error.
LLVM_NODISCARD StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
std::string AliasTarget
Creates a weak alias.
COFF::MachineTypes Machine
Analysis containing CSE Info
A switch()-like statement whose cases are string literals.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
LLVM_NODISCARD bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
Token(Kind T=Unknown, StringRef S="")
std::enable_if< std::numeric_limits< T >::is_signed, bool >::type getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
static ErrorSuccess success()
Create a success value.
std::string ExtName
The external, exported name.
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Expected< COFFModuleDefinition > parse()
value_type read(const void *memory, endianness endian)
Read a value of a particular endianness from memory.
std::string str() const
Return the twine contents as a std::string.
static Version parseVersion(StringRef Name)
LLVM Value Representation.
Lightweight error class with error context and mandatory checking.
StringRef - Represent a constant reference to a string, i.e.
static llvm::Error parse(DataExtractor &Data, uint64_t BaseAddr, LineEntryCallback const &Callback)