[llvm] r260243 - Fix a formatting problems with llvm-size and the -m option.

Kevin Enderby via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 9 10:33:16 PST 2016


Author: enderby
Date: Tue Feb  9 12:33:15 2016
New Revision: 260243

URL: http://llvm.org/viewvc/llvm-project?rev=260243&view=rev
Log:
Fix a formatting problems with llvm-size and the -m option.
It was using format() with a string for 64-bit types but was
passed a 32-bit type in places when printing values for
32-bit Mach-O files.

rdar://24542509

Added:
    llvm/trunk/test/tools/llvm-size/Inputs/darwin-m.o   (with props)
    llvm/trunk/test/tools/llvm-size/darwin-m.test
Modified:
    llvm/trunk/tools/llvm-size/llvm-size.cpp

Added: llvm/trunk/test/tools/llvm-size/Inputs/darwin-m.o
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-size/Inputs/darwin-m.o?rev=260243&view=auto
==============================================================================
Binary file - no diff available.

Propchange: llvm/trunk/test/tools/llvm-size/Inputs/darwin-m.o
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: llvm/trunk/test/tools/llvm-size/darwin-m.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-size/darwin-m.test?rev=260243&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-size/darwin-m.test (added)
+++ llvm/trunk/test/tools/llvm-size/darwin-m.test Tue Feb  9 12:33:15 2016
@@ -0,0 +1,7 @@
+RUN: llvm-size -m %p/Inputs/darwin-m.o | FileCheck --check-prefix="DARWIN" %s
+
+DARWIN: Segment : 8
+DARWIN-NEXT:	Section (__TEXT, __text): 4
+DARWIN-NEXT:	Section (__DATA, __data): 4
+DARWIN-NEXT:	total 8
+DARWIN-NEXT: total 8

Modified: llvm/trunk/tools/llvm-size/llvm-size.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-size/llvm-size.cpp?rev=260243&r1=260242&r2=260243&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-size/llvm-size.cpp (original)
+++ llvm/trunk/tools/llvm-size/llvm-size.cpp Tue Feb  9 12:33:15 2016
@@ -171,10 +171,11 @@ static void PrintDarwinSectionSizes(Mach
         outs() << "\ttotal " << format(fmt.str().c_str(), sec_total) << "\n";
     } else if (Load.C.cmd == MachO::LC_SEGMENT) {
       MachO::segment_command Seg = MachO->getSegmentLoadCommand(Load);
+      uint64_t Seg_vmsize = Seg.vmsize;
       outs() << "Segment " << Seg.segname << ": "
-             << format(fmt.str().c_str(), Seg.vmsize);
+             << format(fmt.str().c_str(), Seg_vmsize);
       if (DarwinLongFormat)
-        outs() << " (vmaddr 0x" << format("%" PRIx64, Seg.vmaddr) << " fileoff "
+        outs() << " (vmaddr 0x" << format("%" PRIx32, Seg.vmaddr) << " fileoff "
                << Seg.fileoff << ")";
       outs() << "\n";
       total += Seg.vmsize;
@@ -186,9 +187,10 @@ static void PrintDarwinSectionSizes(Mach
                  << format("%.16s", &Sec.sectname) << "): ";
         else
           outs() << "\tSection " << format("%.16s", &Sec.sectname) << ": ";
-        outs() << format(fmt.str().c_str(), Sec.size);
+        uint64_t Sec_size = Sec.size;
+        outs() << format(fmt.str().c_str(), Sec_size);
         if (DarwinLongFormat)
-          outs() << " (addr 0x" << format("%" PRIx64, Sec.addr) << " offset "
+          outs() << " (addr 0x" << format("%" PRIx32, Sec.addr) << " offset "
                  << Sec.offset << ")";
         outs() << "\n";
         sec_total += Sec.size;




More information about the llvm-commits mailing list