[yaml2obj/obj2yaml] - Add support for .stack_sizes sections.
[llvm-complete.git] / tools / llvm-objcopy / MachO / MachOReader.h
blob00c8f0d55f61f1564ef15f90478e49eb9f649a71
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 //===----------------------------------------------------------------------===//
9 #include "MachOObjcopy.h"
10 #include "Object.h"
11 #include "llvm/BinaryFormat/MachO.h"
12 #include "llvm/Object/MachO.h"
13 #include <memory>
15 namespace llvm {
16 namespace objcopy {
17 namespace macho {
19 // The hierarchy of readers is responsible for parsing different inputs:
20 // raw binaries and regular MachO object files.
21 class Reader {
22 public:
23 virtual ~Reader(){};
24 virtual std::unique_ptr<Object> create() const = 0;
27 class MachOReader : public Reader {
28 const object::MachOObjectFile &MachOObj;
30 void readHeader(Object &O) const;
31 void readLoadCommands(Object &O) const;
32 void readSymbolTable(Object &O) const;
33 void setSymbolInRelocationInfo(Object &O) const;
34 void readRebaseInfo(Object &O) const;
35 void readBindInfo(Object &O) const;
36 void readWeakBindInfo(Object &O) const;
37 void readLazyBindInfo(Object &O) const;
38 void readExportInfo(Object &O) const;
39 void readDataInCodeData(Object &O) const;
40 void readFunctionStartsData(Object &O) const;
41 void readIndirectSymbolTable(Object &O) const;
43 public:
44 explicit MachOReader(const object::MachOObjectFile &Obj) : MachOObj(Obj) {}
46 std::unique_ptr<Object> create() const override;
49 } // end namespace macho
50 } // end namespace objcopy
51 } // end namespace llvm