[llvm] r206359 - COFF: fix an off by one error

Saleem Abdulrasool compnerd at compnerd.org
Tue Apr 15 23:22:53 PDT 2014


Author: compnerd
Date: Wed Apr 16 01:22:53 2014
New Revision: 206359

URL: http://llvm.org/viewvc/llvm-project?rev=206359&view=rev
Log:
COFF: fix an off by one error

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.

Modified:
    llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
    llvm/trunk/test/MC/COFF/file.s

Modified: llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp?rev=206359&r1=206358&r2=206359&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp Wed Apr 16 01:22:53 2014
@@ -638,7 +638,7 @@ void WinCOFFObjectWriter::ExecutePostLay
   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;

Modified: llvm/trunk/test/MC/COFF/file.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/file.s?rev=206359&r1=206358&r2=206359&view=diff
==============================================================================
--- llvm/trunk/test/MC/COFF/file.s (original)
+++ llvm/trunk/test/MC/COFF/file.s Wed Apr 16 01:22:53 2014
@@ -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{{$}}
 





More information about the llvm-commits mailing list