Skip to content

[lld] Use --no-warnings flag to suppress --noinhibit-exec warnings #138056

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lld/ELF/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ ELFSyncStream elf::Log(Ctx &ctx) { return {ctx, DiagLevel::Log}; }
ELFSyncStream elf::Msg(Ctx &ctx) { return {ctx, DiagLevel::Msg}; }
ELFSyncStream elf::Warn(Ctx &ctx) { return {ctx, DiagLevel::Warn}; }
ELFSyncStream elf::Err(Ctx &ctx) {
return {ctx, ctx.arg.noinhibitExec ? DiagLevel::Warn : DiagLevel::Err};
if (ctx.arg.noinhibitExec)
return {ctx, ctx.e.suppressWarnings ? DiagLevel::None : DiagLevel::Warn};
return {ctx, DiagLevel::Err};
}
ELFSyncStream elf::ErrAlways(Ctx &ctx) { return {ctx, DiagLevel::Err}; }
ELFSyncStream elf::Fatal(Ctx &ctx) { return {ctx, DiagLevel::Fatal}; }
Expand Down
6 changes: 5 additions & 1 deletion lld/ELF/Relocations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ static void printLocation(ELFSyncStream &s, InputSectionBase &sec,

void elf::reportRangeError(Ctx &ctx, uint8_t *loc, const Relocation &rel,
const Twine &v, int64_t min, uint64_t max) {
ErrorPlace errPlace = getErrorPlace(ctx, loc);
auto diag = Err(ctx);
if (diag.getDiagLevel() == DiagLevel::None)
return;
ErrorPlace errPlace = getErrorPlace(ctx, loc);
diag << errPlace.loc << "relocation " << rel.type
<< " out of range: " << v.str() << " is not in [" << min << ", " << max
<< ']';
Expand Down Expand Up @@ -119,6 +121,8 @@ void elf::reportRangeError(Ctx &ctx, uint8_t *loc, const Relocation &rel,
void elf::reportRangeError(Ctx &ctx, uint8_t *loc, int64_t v, int n,
const Symbol &sym, const Twine &msg) {
auto diag = Err(ctx);
if (diag.getDiagLevel() == DiagLevel::None)
return;
diag << getErrorPlace(ctx, loc).loc << msg << " is out of range: " << v
<< " is not in [" << llvm::minIntN(n) << ", " << llvm::maxIntN(n) << "]";
if (!sym.getName().empty()) {
Expand Down
1 change: 1 addition & 0 deletions lld/include/lld/Common/ErrorHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ class SyncStream {
~SyncStream();
StringRef str() { return os.str(); }
uint64_t tell() { return os.tell(); }
DiagLevel getDiagLevel() { return level; }
};

[[noreturn]] void exitLld(int val);
Expand Down