[llvm] r209158 - Implement MachOObjectFile::isSectionData() and MachOObjectFile::isSectionBSS

Kevin Enderby enderby at apple.com
Mon May 19 16:31:19 PDT 2014


Thanks for the catch David!  Fixed in r209179.

Kev

On May 19, 2014, at 4:18 PM, David Blaikie <dblaikie at gmail.com> wrote:

> On Mon, May 19, 2014 at 1:36 PM, Kevin Enderby <enderby at apple.com> wrote:
>> Author: enderby
>> Date: Mon May 19 15:36:02 2014
>> New Revision: 209158
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=209158&view=rev
>> Log:
>> Implement MachOObjectFile::isSectionData() and MachOObjectFile::isSectionBSS
>> so that llvm-size will total up all the sections in the Berkeley format.  This
>> allows for rough categorizations for Mach-O sections.  And allows the total of
>> llvm-size’s Berkeley and System V formats to be the same.
>> 
>> Added:
>>    llvm/trunk/test/Object/Inputs/macho-text-data-bss.macho-x86_64   (with props)
>>    llvm/trunk/test/Object/size-trivial-macho.test
>> Modified:
>>    llvm/trunk/lib/Object/MachOObjectFile.cpp
>> 
>> Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=209158&r1=209157&r2=209158&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)
>> +++ llvm/trunk/lib/Object/MachOObjectFile.cpp Mon May 19 15:36:02 2014
>> @@ -686,15 +686,21 @@ MachOObjectFile::isSectionText(DataRefIm
>>   return object_error::success;
>> }
>> 
>> -error_code MachOObjectFile::isSectionData(DataRefImpl DRI, bool &Result) const {
>> -  // FIXME: Unimplemented.
>> -  Result = false;
>> +error_code MachOObjectFile::isSectionData(DataRefImpl Sec, bool &Result) const {
>> +  uint32_t Flags = getSectionFlags(this, Sec);
>> +  unsigned SectionType = Flags & MachO::SECTION_TYPE;
>> +  Result = !(Flags & MachO::S_ATTR_PURE_INSTRUCTIONS) &&
>> +           !(SectionType == MachO::S_ZEROFILL ||
>> +             SectionType == MachO::S_GB_ZEROFILL);
>>   return object_error::success;
>> }
>> 
>> -error_code MachOObjectFile::isSectionBSS(DataRefImpl DRI, bool &Result) const {
>> -  // FIXME: Unimplemented.
>> -  Result = false;
>> +error_code MachOObjectFile::isSectionBSS(DataRefImpl Sec, bool &Result) const {
>> +  uint32_t Flags = getSectionFlags(this, Sec);
>> +  unsigned SectionType = Flags & MachO::SECTION_TYPE;
>> +  Result = !(Flags & MachO::S_ATTR_PURE_INSTRUCTIONS) &&
>> +           (SectionType == MachO::S_ZEROFILL ||
>> +            SectionType == MachO::S_GB_ZEROFILL);
>>   return object_error::success;
>> }
>> 
>> 
>> Added: llvm/trunk/test/Object/Inputs/macho-text-data-bss.macho-x86_64
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/Inputs/macho-text-data-bss.macho-x86_64?rev=209158&view=auto
>> ==============================================================================
>> Binary file - no diff available.
>> 
>> Propchange: llvm/trunk/test/Object/Inputs/macho-text-data-bss.macho-x86_64
>> ------------------------------------------------------------------------------
>>    svn:mime-type = application/octet-stream
>> 
>> Added: llvm/trunk/test/Object/size-trivial-macho.test
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/size-trivial-macho.test?rev=209158&view=auto
>> ==============================================================================
>> --- llvm/trunk/test/Object/size-trivial-macho.test (added)
>> +++ llvm/trunk/test/Object/size-trivial-macho.test Mon May 19 15:36:02 2014
>> @@ -0,0 +1,15 @@
>> +RUN: llvm-size -A %p/Inputs/macho-text-data-bss.macho-x86_64 \
>> +RUN:         | FileCheck %s -check-prefix A
>> +RUN: llvm-size -B %p/Inputs/macho-text-data-bss.macho-x86_64 \
>> +RUN:         | FileCheck %s -check-prefix B
> 
> This test fails in the check-llvm target under CMake, probably because
> the test directory doesn't depend on llvm-size. I believe
> test/CMakeFiles.txt needs to have llvm-size added to the list of
> things (where you see other llvm-* tools)
> 
> - David
> 
>> +
>> +A: section              size   addr
>> +A: __text                 12      0
>> +A: __data                  4     12
>> +A: __bss                   4    112
>> +A: __compact_unwind       32     16
>> +A: __eh_frame             64     48
>> +A: Total                 116
>> +
>> +B:   text    data     bss     dec     hex filename
>> +B:     12     100       4     116      74
>> 
>> 
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits





More information about the llvm-commits mailing list