Index: lld/COFF/Writer.cpp =================================================================== --- lld/COFF/Writer.cpp +++ lld/COFF/Writer.cpp @@ -743,7 +743,8 @@ add(".idata$2", idata.dirs); add(".idata$4", idata.lookups); add(".idata$5", idata.addresses); - add(".idata$6", idata.hints); + if (!idata.hints.empty()) + add(".idata$6", idata.hints); add(".idata$7", idata.dllNames); } Index: lld/test/COFF/Inputs/ordinal-only-implib.def =================================================================== --- /dev/null +++ lld/test/COFF/Inputs/ordinal-only-implib.def @@ -0,0 +1,3 @@ +LIBRARY test.dll +EXPORTS +ByOrdinalFunction @ 1 NONAME Index: lld/test/COFF/imports-ordinal-only.s =================================================================== --- /dev/null +++ lld/test/COFF/imports-ordinal-only.s @@ -0,0 +1,20 @@ +# REQUIRES: x86 +# +# RUN: llvm-dlltool -k -m i386 --input-def %p/Inputs/ordinal-only-implib.def --output-lib %t-implib.a +# RUN: llvm-mc -triple=i386-pc-win32 %s -filetype=obj -o %t.obj +# RUN: lld-link -out:%t.exe -entry:main -subsystem:console -safeseh:no -debug %t.obj %t-implib.a +# RUN: llvm-objdump -private-headers %t.exe | FileCheck %s + +.text +.global _main +_main: +call _ByOrdinalFunction +ret + +# CHECK: The Import Tables: +# CHECK-NEXT: lookup 000020b4 time 00000000 fwd 00000000 name 000020c4 addr 000020bc +# CHECK-EMPTY: +# CHECK-NEXT: DLL Name: test.dll +# CHECK-NEXT: Hint/Ord Name +# CHECK-NEXT: 1 +# CHECK-EMPTY: