Skip to content

Commit

Permalink
[LLD][COFF] Print object file name for unsupported directives
Browse files Browse the repository at this point in the history
This is a small QoL improvement suggested by FrancescElies in
#56300 (comment).

Differential Revision: https://reviews.llvm.org/D149022
  • Loading branch information
alvinhochun committed Apr 24, 2023
1 parent 271a73d commit 9b15e98
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lld/COFF/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,8 @@ void LinkerDriver::parseDirectives(InputFile *file) {
case OPT_throwingnew:
break;
default:
error(arg->getSpelling() + " is not allowed in .drectve");
error(arg->getSpelling() + " is not allowed in .drectve (" +
toString(file) + ")");
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions lld/test/COFF/directives-unsupported.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# REQUIRES: x86

# RUN: llvm-mc -triple=x86_64-windows %s -filetype=obj -o %t.obj

# RUN: not lld-link -dll -out:%t.dll -entry:entry %t.obj -subsystem:console 2>&1 | FileCheck %s

# CHECK: warning: ignoring unknown argument: -unknowndirectivename
# CHECK: error: -unknowndirectivename is not allowed in .drectve ({{.*}}.obj)

.global entry
.text
entry:
ret
.section .drectve
.ascii " -unknowndirectivename "

0 comments on commit 9b15e98

Please sign in to comment.