COFF: fix an off by one error
authorSaleem Abdulrasool <compnerd@compnerd.org>
Wed, 16 Apr 2014 06:22:53 +0000 (06:22 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Wed, 16 Apr 2014 06:22:53 +0000 (06:22 +0000)
Adjust the tests to validate the number of auxiliary entries used to store the
filename.

Thanks to majnemer's sharp eye for catching the missing - 1 in the round up
calculation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206359 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/WinCOFFObjectWriter.cpp
test/MC/COFF/file.s

index e98777894a714152ea4e8b0d78ae692d62f1d04e..27dc5a12a695ade6f055de8c2fc8e93970e40fe4 100644 (file)
@@ -638,7 +638,7 @@ void WinCOFFObjectWriter::ExecutePostLayoutBinding(MCAssembler &Asm,
   for (auto FI = Asm.file_names_begin(), FE = Asm.file_names_end();
        FI != FE; ++FI) {
     // round up to calculate the number of auxiliary symbols required
-    unsigned Count = (FI->size() + COFF::SymbolSize) / COFF::SymbolSize;
+    unsigned Count = (FI->size() + COFF::SymbolSize - 1) / COFF::SymbolSize;
 
     COFFSymbol *file = createSymbol(".file");
     file->Data.StorageClass = COFF::IMAGE_SYM_CLASS_FILE;
index a258693839c9ff44a07af001ab4828de10f15a72..72eee90842aeb0932faecffadf578fdff46a6873 100644 (file)
@@ -2,16 +2,16 @@
 // RUN:   | FileCheck %s -check-prefix CHECK-PRINT
 
        .file "null-padded.asm"
-// CHECK-PRINT: .file
+// CHECK-PRINT: (nx 1) {{0x[0-9]+}} .file
 // CHECK-PRINT-NEXT: AUX null-padded.asm{{$}}
 
        .file "eighteen-chars.asm"
 
-// CHECK-PRINT: .file
+// CHECK-PRINT: (nx 1) {{0x[0-9]+}} .file
 // CHECK-PRINT-NEXT: AUX eighteen-chars.asm{{$}}
 
        .file "multiple-auxiliary-entries.asm"
 
-// CHECK-PRINT: .file
+// CHECK-PRINT: (nx 2) {{0x[0-9]+}} .file
 // CHECK-PRINT-NEXT: AUX multiple-auxiliary-entries.asm{{$}}