diff options
Diffstat (limited to 'contrib/llvm-project/llvm/tools/llvm-objcopy/MachO/Object.h')
-rw-r--r-- | contrib/llvm-project/llvm/tools/llvm-objcopy/MachO/Object.h | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/contrib/llvm-project/llvm/tools/llvm-objcopy/MachO/Object.h b/contrib/llvm-project/llvm/tools/llvm-objcopy/MachO/Object.h index e825d1867b09..0bb4b344b2eb 100644 --- a/contrib/llvm-project/llvm/tools/llvm-objcopy/MachO/Object.h +++ b/contrib/llvm-project/llvm/tools/llvm-objcopy/MachO/Object.h @@ -44,6 +44,8 @@ struct Section { std::string CanonicalName; uint64_t Addr = 0; uint64_t Size = 0; + // Offset in the input file. + Optional<uint32_t> OriginalOffset; uint32_t Offset = 0; uint32_t Align = 0; uint32_t RelOff = 0; @@ -73,6 +75,10 @@ struct Section { getType() == MachO::S_GB_ZEROFILL || getType() == MachO::S_THREAD_LOCAL_ZEROFILL); } + + bool hasValidOffset() const { + return !(isVirtualSection() || (OriginalOffset && *OriginalOffset == 0)); + } }; struct LoadCommand { @@ -94,6 +100,9 @@ struct LoadCommand { // Returns the segment name if the load command is a segment command. Optional<StringRef> getSegmentName() const; + + // Returns the segment vm address if the load command is a segment command. + Optional<uint64_t> getSegmentVMAddr() const; }; // A symbol information. Fields which starts with "n_" are same as them in the @@ -331,17 +340,17 @@ struct Object { void updateLoadCommandIndexes(); - void addLoadCommand(LoadCommand LC); - /// Creates a new segment load command in the object and returns a reference /// to the newly created load command. The caller should verify that SegName /// is not too long (SegName.size() should be less than or equal to 16). - LoadCommand &addSegment(StringRef SegName); + LoadCommand &addSegment(StringRef SegName, uint64_t SegVMSize); bool is64Bit() const { return Header.Magic == MachO::MH_MAGIC_64 || Header.Magic == MachO::MH_CIGAM_64; } + + uint64_t nextAvailableSegmentAddress() const; }; } // end namespace macho |