[llvm-branch-commits] [lld] 4676274 - [LLD][COFF] Print object file name for unsupported directives

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon May 1 21:13:31 PDT 2023


Author: Alvin Wong
Date: 2023-05-01T21:12:25-07:00
New Revision: 4676274c9eb222c745c7402d83872b4a28d66f41

URL: https://github.com/llvm/llvm-project/commit/4676274c9eb222c745c7402d83872b4a28d66f41
DIFF: https://github.com/llvm/llvm-project/commit/4676274c9eb222c745c7402d83872b4a28d66f41.diff

LOG: [LLD][COFF] Print object file name for unsupported directives

This is a small QoL improvement suggested by FrancescElies in
https://github.com/llvm/llvm-project/issues/56300#issuecomment-1172104966.

Differential Revision: https://reviews.llvm.org/D149022

(cherry picked from commit 9b15e9840f5073aa38939fbef1cb0c64dcc5f02f)

Added: 
    lld/test/COFF/directives-unsupported.s

Modified: 
    lld/COFF/Driver.cpp

Removed: 
    


################################################################################
diff  --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index 0a153c8f6cb7..241331b8f161 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -438,7 +438,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) + ")");
     }
   }
 }

diff  --git a/lld/test/COFF/directives-unsupported.s b/lld/test/COFF/directives-unsupported.s
new file mode 100644
index 000000000000..1b8231178df8
--- /dev/null
+++ b/lld/test/COFF/directives-unsupported.s
@@ -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 "


        


More information about the llvm-branch-commits mailing list