diff --git a/lld/COFF/DriverUtils.cpp b/lld/COFF/DriverUtils.cpp
--- a/lld/COFF/DriverUtils.cpp
+++ b/lld/COFF/DriverUtils.cpp
@@ -709,7 +709,7 @@
     if (e.ordinal == 0)
       e.ordinal = ++max;
   if (max > std::numeric_limits<uint16_t>::max())
-    fatal("too many exported symbols (max " +
+    fatal("too many exported symbols (got " + Twine(max) + ", max " +
           Twine(std::numeric_limits<uint16_t>::max()) + ")");
 }
 
diff --git a/lld/test/COFF/export-limit.s b/lld/test/COFF/export-limit.s
--- a/lld/test/COFF/export-limit.s
+++ b/lld/test/COFF/export-limit.s
@@ -5,7 +5,7 @@
 # RUN: lld-link -dll -noentry %t.obj -out:%t.dll -def:%t-65535.def
 # RUN: env LLD_IN_TEST=1 not lld-link -dll -noentry %t.obj -out:%t.dll -def:%t-65536.def 2>&1 | FileCheck %s
 
-# CHECK: error: too many exported symbols
+# CHECK: error: too many exported symbols (got 65536, max 65535)
 
         .text
         .globl f