Lines Matching defs:cmd

210 static bool shouldDefineSym(Ctx &ctx, SymbolAssignment *cmd) {
211 if (cmd->name == ".")
214 return !cmd->provide || ctx.script->shouldAddProvideSym(cmd->name);
219 void LinkerScript::addSymbol(SymbolAssignment *cmd) {
220 if (!shouldDefineSym(ctx, cmd))
224 ExprValue value = cmd->expression();
226 uint8_t visibility = cmd->hidden ? STV_HIDDEN : STV_DEFAULT;
241 Defined newSym(ctx, createInternalFile(ctx, cmd->location), cmd->name,
244 Symbol *sym = ctx.symtab->insert(cmd->name);
248 cmd->sym = cast<Defined>(sym);
253 void LinkerScript::declareSymbol(SymbolAssignment *cmd) {
254 if (!shouldDefineSym(ctx, cmd))
257 uint8_t visibility = cmd->hidden ? STV_HIDDEN : STV_DEFAULT;
258 Defined newSym(ctx, ctx.internalFile, cmd->name, STB_GLOBAL, visibility,
263 Symbol *sym = ctx.symtab->insert(cmd->name);
265 ctx.scriptSymOrder.insert({sym, cmd->symOrder});
271 cmd->sym = cast<Defined>(sym);
272 cmd->provide = false;
285 for (SectionCommand *cmd : sectionCommands) {
286 if (auto *assign = dyn_cast<SymbolAssignment>(cmd)) {
292 if (isa<SectionClassDesc>(cmd))
294 for (SectionCommand *subCmd : cast<OutputDesc>(cmd)->osec.commands)
321 for (const InsertCommand &cmd : insertCommands) {
326 for (StringRef name : cmd.names) {
340 llvm::find_if(sectionCommands, [&cmd](SectionCommand *subCmd) {
342 return to != nullptr && to->osec.name == cmd.where;
345 ErrAlways(ctx) << "unable to insert " << cmd.names[0]
346 << (cmd.isAfter ? " after " : " before ") << cmd.where;
348 if (cmd.isAfter)
361 for (SectionCommand *cmd : sectionCommands) {
362 if (auto *assign = dyn_cast<SymbolAssignment>(cmd)) {
366 if (isa<SectionClassDesc>(cmd))
373 const OutputSection &sec = cast<OutputDesc>(cmd)->osec;
376 for (SectionCommand *cmd : sec.commands)
377 if (auto *assign = dyn_cast<SymbolAssignment>(cmd))
385 void LinkerScript::assignSymbol(SymbolAssignment *cmd, bool inSec) {
386 if (cmd->name == ".") {
387 setDot(cmd->expression, cmd->location, inSec);
391 if (!cmd->sym)
394 ExprValue v = cmd->expression();
396 cmd->sym->section = nullptr;
397 cmd->sym->value = v.getValue();
399 cmd->sym->section = v.sec;
400 cmd->sym->value = v.getSectionOffset();
402 cmd->sym->type = v.type;
514 LinkerScript::computeInputSections(const InputSectionDescription *cmd,
522 auto flagsMatch = [cmd](InputSectionBase *sec) {
523 return (sec->flags & cmd->withFlags) == cmd->withFlags &&
524 (sec->flags & cmd->withoutFlags) == 0;
528 if (cmd->classRef.empty()) {
542 for (const SectionPattern &pat : cmd->sectionPatterns) {
565 if (!cmd->matchesFile(*sec->file) || pat.excludesFile(*sec->file) ||
616 sectionClasses.lookup(CachedHashStringRef(cmd->classRef));
618 Err(ctx) << "undefined section class '" << cmd->classRef << "'";
622 Err(ctx) << "section class '" << cmd->classRef << "' referenced by '"
656 *sec, const_cast<InputSectionDescription &>(*cmd));
687 for (SectionCommand *cmd : outCmd.commands)
688 if (auto *isd = dyn_cast<InputSectionDescription>(cmd))
698 for (SectionCommand *cmd : outCmd.commands) {
699 if (auto *isd = dyn_cast<InputSectionDescription>(cmd)) {
860 for (SectionCommand *cmd : sectionCommands) {
861 if (auto *assign = dyn_cast<SymbolAssignment>(cmd))
863 else if (auto *osd = dyn_cast<OutputDesc>(cmd))
874 for (SectionCommand *cmd : vec)
875 if (auto *osd = dyn_cast<OutputDesc>(cmd))
1225 for (SectionCommand *cmd : sec->commands) {
1227 if (auto *assign = dyn_cast<SymbolAssignment>(cmd)) {
1235 if (auto *data = dyn_cast<ByteCommand>(cmd)) {
1246 auto &sections = cast<InputSectionDescription>(cmd)->sections;
1296 for (SectionCommand *cmd : sec.commands) {
1297 if (auto assign = dyn_cast<SymbolAssignment>(cmd))
1303 if (!isa<InputSectionDescription>(*cmd))
1348 for (SectionCommand *&cmd : sectionCommands) {
1349 if (!isa<OutputDesc>(cmd))
1351 auto *sec = &cast<OutputDesc>(cmd)->osec;
1394 cmd = nullptr;
1407 llvm::erase_if(sectionCommands, [&](SectionCommand *cmd) { return !cmd; });
1413 for (SectionCommand *cmd : sectionCommands) {
1414 if (auto *osd = dyn_cast<OutputDesc>(cmd)) {
1434 auto firstPtLoad = llvm::find_if(phdrsCommands, [](const PhdrsCommand &cmd) {
1435 return cmd.type == PT_LOAD;
1442 for (SectionCommand *cmd : sectionCommands)
1443 if (auto *osd = dyn_cast<OutputDesc>(cmd))
1467 llvm::any_of(phdrsCommands, [](const PhdrsCommand &cmd) {
1468 return cmd.hasPhdrs || cmd.hasFilehdr;
1530 for (SectionCommand *cmd : sectionCommands) {
1531 if (auto *assign = dyn_cast<SymbolAssignment>(cmd)) {
1537 if (isa<SectionClassDesc>(cmd))
1539 if (assignOffsets(&cast<OutputDesc>(cmd)->osec) && !changedOsec)
1540 changedOsec = &cast<OutputDesc>(cmd)->osec;
1563 for (SectionCommand *cmd : reverse(sectionCommands)) {
1564 auto *osd = dyn_cast<OutputDesc>(cmd);
1575 for (SectionCommand *cmd : reverse(osec->commands)) {
1580 auto *isd = dyn_cast<InputSectionDescription>(cmd);
1661 for (const PhdrsCommand &cmd : phdrsCommands) {
1663 std::make_unique<PhdrEntry>(ctx, cmd.type, cmd.flags.value_or(PF_R));
1665 if (cmd.hasFilehdr)
1667 if (cmd.hasPhdrs)
1670 if (cmd.lmaExpr) {
1671 phdr->p_paddr = cmd.lmaExpr().getValue();
1697 for (PhdrsCommand &cmd : phdrsCommands)
1698 if (cmd.type == PT_INTERP)
1740 SmallVector<size_t, 0> LinkerScript::getPhdrIndices(OutputSection *cmd) {
1743 for (StringRef s : cmd->phdrs) {
1747 ErrAlways(ctx) << cmd->location << ": program header '" << s