LLVM  15.0.0git
MachOReader.h
Go to the documentation of this file.
1 //===- MachOReader.h --------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_LIB_OBJCOPY_MACHO_MACHOREADER_H
10 #define LLVM_LIB_OBJCOPY_MACHO_MACHOREADER_H
11 
12 #include "MachOObject.h"
15 #include "llvm/Object/MachO.h"
16 #include <memory>
17 
18 namespace llvm {
19 namespace objcopy {
20 namespace macho {
21 
22 // The hierarchy of readers is responsible for parsing different inputs:
23 // raw binaries and regular MachO object files.
24 class Reader {
25 public:
26  virtual ~Reader(){};
27  virtual Expected<std::unique_ptr<Object>> create() const = 0;
28 };
29 
30 class MachOReader : public Reader {
31  const object::MachOObjectFile &MachOObj;
32 
33  void readHeader(Object &O) const;
34  Error readLoadCommands(Object &O) const;
35  void readSymbolTable(Object &O) const;
36  void setSymbolInRelocationInfo(Object &O) const;
37  void readRebaseInfo(Object &O) const;
38  void readBindInfo(Object &O) const;
39  void readWeakBindInfo(Object &O) const;
40  void readLazyBindInfo(Object &O) const;
41  void readExportInfo(Object &O) const;
42  void readLinkData(Object &O, Optional<size_t> LCIndex, LinkData &LD) const;
43  void readCodeSignature(Object &O) const;
44  void readDataInCodeData(Object &O) const;
45  void readLinkerOptimizationHint(Object &O) const;
46  void readFunctionStartsData(Object &O) const;
47  void readExportsTrie(Object &O) const;
48  void readChainedFixups(Object &O) const;
49  void readIndirectSymbolTable(Object &O) const;
50  void readSwiftVersion(Object &O) const;
51 
52 public:
53  explicit MachOReader(const object::MachOObjectFile &Obj) : MachOObj(Obj) {}
54 
55  Expected<std::unique_ptr<Object>> create() const override;
56 };
57 
58 } // end namespace macho
59 } // end namespace objcopy
60 } // end namespace llvm
61 
62 #endif // LLVM_LIB_OBJCOPY_MACHO_MACHOREADER_H
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::ARM_MB::LD
@ LD
Definition: ARMBaseInfo.h:72
llvm::Optional< size_t >
llvm::objcopy::macho::MachOReader
Definition: MachOReader.h:30
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:41
llvm::objcopy::macho::Reader
Definition: MachOReader.h:24
MachO.h
llvm::objcopy::macho::LinkData
Definition: MachOObject.h:298
llvm::objcopy::macho::Object
Definition: MachOObject.h:302
llvm::objcopy::macho::Reader::~Reader
virtual ~Reader()
Definition: MachOReader.h:26
llvm::objcopy::macho::MachOReader::MachOReader
MachOReader(const object::MachOObjectFile &Obj)
Definition: MachOReader.h:53
llvm::object::MachOObjectFile
Definition: MachO.h:381
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:240
llvm::objcopy::macho::MachOReader::create
Expected< std::unique_ptr< Object > > create() const override
Definition: MachOReader.cpp:354
MachOObjcopy.h
MachOObject.h
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
MachO.h
llvm::objcopy::macho::Reader::create
virtual Expected< std::unique_ptr< Object > > create() const =0