[llvm-commits] CVS: llvm/lib/Bytecode/Archive/ArchiveReader.cpp ArchiveWriter.cpp

Reid Spencer reid at x10sys.com
Fri Nov 19 09:08:11 PST 2004



Changes in directory llvm/lib/Bytecode/Archive:

ArchiveReader.cpp updated: 1.29 -> 1.30
ArchiveWriter.cpp updated: 1.7 -> 1.8
---
Log message:

Correct the computation of when to add the padding. It is not based on the
member's size. It is based on the oddness/evenness of the file pointer.
This fixes a bug with llvm-ar not being able to read archives produced by
llvm-ranlib when there are members with odd long file name lengths.


---
Diffs of the changes:  (+9 -9)

Index: llvm/lib/Bytecode/Archive/ArchiveReader.cpp
diff -u llvm/lib/Bytecode/Archive/ArchiveReader.cpp:1.29 llvm/lib/Bytecode/Archive/ArchiveReader.cpp:1.30
--- llvm/lib/Bytecode/Archive/ArchiveReader.cpp:1.29	Thu Nov 18 21:44:10 2004
+++ llvm/lib/Bytecode/Archive/ArchiveReader.cpp	Fri Nov 19 11:08:00 2004
@@ -227,7 +227,7 @@
       // with it. It doesn't count as the "first file".
       foreignST = mbr;
       At += mbr->getSize();
-      if ((mbr->getSize() & 1) == 1)
+      if ((intptr_t(At) & 1) == 1)
         At++;
     } else if (mbr->isStringTable()) {
       // Simply suck the entire string table into a string
@@ -236,7 +236,7 @@
       // (SVR4 style long names).
       strtab.assign(At,mbr->getSize());
       At += mbr->getSize();
-      if ((mbr->getSize() & 1) == 1)
+      if ((intptr_t(At) & 1) == 1)
         At++;
       delete mbr;
     } else if (mbr->isLLVMSymbolTable()) { 
@@ -247,7 +247,7 @@
       parseSymbolTable(mbr->getData(),mbr->getSize());
       seenSymbolTable = true;
       At += mbr->getSize();
-      if ((mbr->getSize() & 1) == 1)
+      if ((intptr_t(At) & 1) == 1)
         At++;
       delete mbr; // We don't need this member in the list of members.
     } else {
@@ -259,7 +259,7 @@
       }
       members.push_back(mbr);
       At += mbr->getSize();
-      if ((mbr->getSize() & 1) == 1)
+      if ((intptr_t(At) & 1) == 1)
         At++;
     }
   }
@@ -317,7 +317,7 @@
   if (mbr->isForeignSymbolTable()) {
     // Skip the foreign symbol table, we don't do anything with it
     At += mbr->getSize();
-    if ((mbr->getSize() & 1) == 1)
+    if ((intptr_t(At) & 1) == 1)
       At++;
     delete mbr;
 
@@ -330,7 +330,7 @@
     // Process the string table entry
     strtab.assign((const char*)mbr->getData(),mbr->getSize());
     At += mbr->getSize();
-    if ((mbr->getSize() & 1) == 1)
+    if ((intptr_t(At) & 1) == 1)
       At++;
     delete mbr;
     // Get the next one
@@ -342,7 +342,7 @@
   if (mbr->isLLVMSymbolTable()) {
     parseSymbolTable(mbr->getData(),mbr->getSize());
     FirstFile = At + mbr->getSize();
-    if ((mbr->getSize() & 1) == 1)
+    if ((intptr_t(At) & 1) == 1)
       FirstFile++;
   } else {
     // There's no symbol table in the file. We have to rebuild it from scratch
@@ -454,7 +454,7 @@
 
       // Go to the next file location
       At += mbr->getSize();
-      if ((mbr->getSize() & 1) == 1)
+      if ((intptr_t(At) & 1) == 1)
         At++;
     }
   }


Index: llvm/lib/Bytecode/Archive/ArchiveWriter.cpp
diff -u llvm/lib/Bytecode/Archive/ArchiveWriter.cpp:1.7 llvm/lib/Bytecode/Archive/ArchiveWriter.cpp:1.8
--- llvm/lib/Bytecode/Archive/ArchiveWriter.cpp:1.7	Wed Nov 17 12:28:29 2004
+++ llvm/lib/Bytecode/Archive/ArchiveWriter.cpp	Fri Nov 19 11:08:00 2004
@@ -290,7 +290,7 @@
   ARFile.write(data,fSize);
 
   // Make sure the member is an even length
-  if (ARFile.tellp() % 2 != 0)
+  if (ARFile.tellp() & 1 == 1)
     ARFile << ARFILE_PAD;
 
   // Free the compressed data, if necessary






More information about the llvm-commits mailing list