Lines Matching defs:tok
82 ByteCommand *readByteCommand(StringRef tok);
84 bool readSectionDirective(OutputSection *cmd, StringRef tok);
93 InputSectionDescription *readInputSectionDescription(StringRef tok);
103 SymbolAssignment *readAssignment(StringRef tok);
190 StringRef tok = peek();
191 if (tok.size()) {
192 setError("EOF expected, but got " + tok);
206 StringRef tok = peek();
207 if (tok.size())
208 setError("EOF expected, but got " + tok);
239 StringRef tok = next();
242 if (tok == ";")
245 if (tok == "ENTRY") {
247 } else if (tok == "EXTERN") {
249 } else if (tok == "GROUP") {
251 } else if (tok == "INCLUDE") {
253 } else if (tok == "INPUT") {
255 } else if (tok == "MEMORY") {
257 } else if (tok == "OUTPUT") {
259 } else if (tok == "OUTPUT_ARCH") {
261 } else if (tok == "OUTPUT_FORMAT") {
263 } else if (tok == "OVERWRITE_SECTIONS") {
265 } else if (tok == "PHDRS") {
267 } else if (tok == "REGION_ALIAS") {
269 } else if (tok == "SEARCH_DIR") {
271 } else if (tok == "SECTIONS") {
273 } else if (tok == "TARGET") {
275 } else if (tok == "VERSION") {
277 } else if (tok == "NOCROSSREFS") {
279 } else if (tok == "NOCROSSREFS_TO") {
281 } else if (SymbolAssignment *cmd = readAssignment(tok)) {
284 setError("unknown directive: " + tok);
306 while (auto tok = till(")"))
307 cmd.outputSections.push_back(unquote(tok));
368 while (auto tok = till(")"))
369 addFile(unquote(tok));
384 while (auto tok = till(")"))
385 ctx.arg.undefined.push_back(unquote(tok));
415 while (auto tok = till(")")) {
416 if (tok == "AS_NEEDED")
419 addFile(unquote(tok));
514 while (auto tok = till("}")) {
516 cmd.name = tok;
617 while (auto tok = till("}")) {
618 if (tok == "(" || tok == ")") {
621 InputSectionDescription *isd = readInputSectionDescription(tok);
640 while (auto tok = till("}"))
641 ctx.script->overwriteSections.push_back(readOutputSectionDescription(tok));
647 while (auto tok = till("}")) {
648 if (tok == "OVERLAY") {
653 if (tok == "CLASS") {
657 if (tok == "INCLUDE") {
662 if (SectionCommand *cmd = readAssignment(tok))
665 v.push_back(readOutputSectionDescription(tok));
703 StringRef tok = readName();
706 if (tok.starts_with("elf"))
708 else if (tok == "binary")
711 setError("unknown target: " + tok);
732 while (auto tok = till(")"))
733 Matcher.addPattern(SingleStringMatcher(tok));
851 ScriptParser::readInputSectionDescription(StringRef tok) {
856 if (tok == "KEEP") {
861 tok = next();
863 if (tok == "CLASS")
867 cmd = readInputSectionRules(tok, withFlags, withoutFlags);
872 if (tok == "INPUT_SECTION_FLAGS") {
874 tok = next();
876 if (tok == "CLASS")
879 return readInputSectionRules(tok, withFlags, withoutFlags);
913 bool ScriptParser::readSectionDirective(OutputSection *cmd, StringRef tok) {
914 if (tok != "NOLOAD" && tok != "COPY" && tok != "INFO" && tok != "OVERLAY" &&
915 tok != "TYPE")
969 StringRef tok = peek();
970 if (!readSectionDirective(cmd, tok))
971 setError("unknown section directive: " + tok);
991 while (auto tok = till("}")) {
994 if (tok == "INPUT_SECTION_FLAGS") {
996 tok = till("");
998 if (tok == "CLASS")
1003 readInputSectionRules(tok, withFlags, withoutFlags));
1037 while (auto tok = till("}")) {
1038 if (tok == ";") {
1040 } else if (SymbolAssignment *assign = readAssignment(tok)) {
1042 } else if (ByteCommand *data = readByteCommand(tok)) {
1044 } else if (tok == "CONSTRUCTORS") {
1048 } else if (tok == "FILL") {
1055 } else if (tok == "SORT") {
1057 } else if (tok == "INCLUDE") {
1059 } else if (tok == "(" || tok == ")") {
1062 osec->commands.push_back(readInputSectionDescription(tok));
1070 auto *isd = make<InputSectionDescription>(tok);
1155 SymbolAssignment *ScriptParser::readAssignment(StringRef tok) {
1157 if (tok == "ASSERT")
1168 cmd = readSymbolAssignment(unquote(tok));
1171 cmd = readSymbolAssignment(unquote(tok));
1172 } else if (tok == "PROVIDE") {
1174 } else if (tok == "HIDDEN") {
1176 } else if (tok == "PROVIDE_HIDDEN") {
1349 static std::optional<uint64_t> parseInt(StringRef tok) {
1352 if (tok.starts_with_insensitive("0x")) {
1353 if (!to_integer(tok.substr(2), val, 16))
1357 if (tok.ends_with_insensitive("H")) {
1358 if (!to_integer(tok.drop_back(), val, 16))
1364 if (tok.ends_with_insensitive("K")) {
1365 if (!to_integer(tok.drop_back(), val, 10))
1369 if (tok.ends_with_insensitive("M")) {
1370 if (!to_integer(tok.drop_back(), val, 10))
1374 if (!to_integer(tok, val, 10))
1379 ByteCommand *ScriptParser::readByteCommand(StringRef tok) {
1380 int size = StringSwitch<int>(tok)
1396 static std::optional<uint64_t> parseFlag(StringRef tok) {
1397 if (std::optional<uint64_t> asInt = parseInt(tok))
1400 return StringSwitch<std::optional<uint64_t>>(tok)
1433 StringRef tok = readName();
1434 bool without = tok.consume_front("!");
1435 if (std::optional<uint64_t> flag = parseFlag(tok)) {
1441 setError("unrecognised flag: " + tok);
1457 StringRef tok = readName();
1460 return tok;
1495 StringRef tok = next();
1500 if (tok == "ABSOLUTE") {
1508 if (tok == "ADDR") {
1517 if (tok == "ALIGN") {
1535 if (tok == "ALIGNOF") {
1543 if (tok == "ASSERT")
1545 if (tok == "CONSTANT")
1547 if (tok == "DATA_SEGMENT_ALIGN") {
1559 if (tok == "DATA_SEGMENT_END") {
1565 if (tok == "DATA_SEGMENT_RELRO_END") {
1579 if (tok == "DEFINED") {
1590 if (tok == "LENGTH") {
1598 if (tok == "LOADADDR") {
1607 if (tok == "LOG2CEIL") {
1616 if (tok == "MAX" || tok == "MIN") {
1622 if (tok == "MIN")
1626 if (tok == "ORIGIN") {
1634 if (tok == "SEGMENT_START") {
1642 if (tok == "SIZEOF") {
1650 if (tok == "SIZEOF_HEADERS")
1654 if (tok == ".")
1655 return [=, s = ctx.script] { return s->getSymbolValue(tok, location); };
1658 if (std::optional<uint64_t> val = parseInt(tok))
1662 if (tok.starts_with("\""))
1663 tok = unquote(tok);
1664 else if (!isValidSymbolName(tok))
1665 setError("malformed number: " + tok);
1667 ctx.script->provideMap[*activeProvideSym].push_back(tok);
1669 ctx.script->referencedSymbols.push_back(tok);
1670 return [=, s = ctx.script] { return s->getSymbolValue(tok, location); };
1690 StringRef tok = next();
1691 phdrs.push_back((tok.size() == 1) ? readName() : tok.substr(1));
1699 StringRef tok = next();
1700 if (std::optional<uint64_t> val = parseInt(tok))
1703 unsigned ret = StringSwitch<unsigned>(tok)
1723 setError("invalid program header type: " + tok);
1778 while (auto tok = till("}")) {
1779 if (tok == "extern") {
1783 if (tok == "local:" || (tok == "local" && consume(":"))) {
1787 if (tok == "global:" || (tok == "global" && consume(":"))) {
1791 v->push_back({unquote(tok), false, hasWildcard(tok)});
1804 StringRef tok = next();
1805 bool isCXX = tok == "\"C++\"";
1806 if (!isCXX && tok != "\"C\"")
1811 while (auto tok = till("}")) {
1813 {unquote(tok), isCXX, !tok.str.starts_with("\"") && hasWildcard(tok)});
1837 while (auto tok = till("}")) {
1838 if (tok == "INCLUDE") {
1858 MemoryRegion *mr = make<MemoryRegion>(tok, origin, length, flags, invFlags,
1860 if (!ctx.script->memoryRegions.insert({tok, mr}).second)
1861 setError("region '" + tok + "' already defined");