diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 4bb8ff543700c7a..3cf09cec3ede6f8 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -2925,19 +2925,22 @@ void LinkerDriver::link(opt::InputArgList &args) { invokeELFT(markLive,); demoteSharedAndLazySymbols(); - - for (const Symbol *sb : symtab.getSymbols()) { - if (sb->getName().ends_with("::stack_overflow")) { - const StringRef FuncName = sb->getName().substr(0, sb->getName().size()); - 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."); - } else if (sb->getName().ends_with("::call_overflow")) { - const StringRef FuncName = sb->getName().substr(0, sb->getName().size()); - 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."); + if (config->emachine == EM_BPF || config->emachine == EM_SBF) { + for (const Symbol *sb : symtab.getSymbols()) { + if (sb->getName().ends_with("::stack_overflow")) { + const StringRef FuncName = + sb->getName().substr(0, sb->getName().size()); + 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."); + } else if (sb->getName().ends_with("::call_overflow")) { + const StringRef FuncName = + sb->getName().substr(0, sb->getName().size()); + 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."); + } } }