File tree Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Original file line number Diff line number Diff line change @@ -1996,14 +1996,19 @@ MachOObjectFile::getSectionContents(DataRefImpl Sec) const {
19961996    //  4GB. MachO::section_64 objects only have 32 bit file offsets to the
19971997    //  section contents and can overflow in dSYM files. We can track this and
19981998    //  adjust the section offset to be 64 bit safe.
1999+     //  Assumes the sections are ordered.
2000+     uint64_t  PrevTrueOffset = 0 ;
19992001    uint64_t  SectOffsetAdjust = 0 ;
20002002    for  (uint32_t  SectIdx=0 ; SectIdx<Sec.d .a ; ++SectIdx) {
20012003      MachO::section_64 CurrSect =
20022004          getStruct<MachO::section_64>(*this , Sections[SectIdx]);
2005+        uint64_t  CurrTrueOffset = (uint64_t ) CurrSect.offset  | SectOffsetAdjust;
2006+       assert (SectOffsetAdjust == 0  || (PrevTrueOffset <= CurrTrueOffset) && " Overflowing sections must be ordered for adjustment"  )
20032007      const  uint64_t  EndSectFileOffset =
20042008          (uint64_t )CurrSect.offset  + CurrSect.size ;
20052009      if  (EndSectFileOffset >= UINT32_MAX)
20062010        SectOffsetAdjust += EndSectFileOffset & 0xFFFFFFFF00000000ull ;
2011+       PrevTrueOffset = CurrTrueOffset;
20072012    }
20082013    Offset += SectOffsetAdjust;
20092014  } else  {
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments