Skip to content

Commit

Permalink
Filter by entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasSte committed Jul 16, 2024
1 parent eecfa34 commit 4bedffa
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions lld/ELF/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2926,22 +2926,32 @@ void LinkerDriver::link(opt::InputArgList &args) {
demoteSharedAndLazySymbols();

if (config->emachine == EM_BPF || config->emachine == EM_SBF) {
std::string StackError;
bool hasEntrypoint = false;
for (const Symbol *sb : symtab.getSymbols()) {
if (sb->getName().ends_with("::stack_overflow")) {
const StringRef FuncName =
sb->getName().substr(0, sb->getName().size() - 16);
report_fatal_error("Function " + FuncName +
" utilizes too much stack space and will cause "
"undefined behavior in the program. Refer to a"
"previously emitted warning for more information.");
StackError = "Function " + FuncName.str() +
" utilizes too much stack space and will cause "
"undefined behavior in the program. Refer to a"
"previously emitted warning for more information.";
break;
} else if (sb->getName().ends_with("::call_overflow")) {
const StringRef FuncName =
sb->getName().substr(0, sb->getName().size() - 15);
report_fatal_error("A function call inside method " + FuncName +
"will overwrite data in the stack frame. Refer to a "
"previously emitted warning for more information.");
StackError = "A function call inside method " + FuncName.str() +
"will overwrite data in the stack frame. Refer to a "
"previously emitted warning for more information.";
break;
} else if (!hasEntrypoint && sb->getName() == "entrypoint") {
hasEntrypoint = true;
}
}

if (!StackError.empty() && hasEntrypoint) {
report_fatal_error(StringRef(StackError));
}
}

// Make copies of any input sections that need to be copied into each
Expand Down

0 comments on commit 4bedffa

Please sign in to comment.