blob: e38afbd6b71d8e69271988816370529d981d4c0c [file] [log] [blame]
Alexander Shaposhnikovd911ed12019-02-02 00:38:07 +00001//===- MachOReader.h --------------------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "MachOObjcopy.h"
11#include "Object.h"
12#include "llvm/BinaryFormat/MachO.h"
13#include "llvm/Object/MachO.h"
14#include <memory>
15
16namespace llvm {
17namespace objcopy {
18namespace macho {
19
20// The hierarchy of readers is responsible for parsing different inputs:
21// raw binaries and regular MachO object files.
22class Reader {
23public:
24 virtual ~Reader(){};
25 virtual std::unique_ptr<Object> create() const = 0;
26};
27
28class MachOReader : public Reader {
29 const object::MachOObjectFile &MachOObj;
30
31 void readHeader(Object &O) const;
32 void readLoadCommands(Object &O) const;
33 void readSymbolTable(Object &O) const;
34 void readStringTable(Object &O) const;
35 void readRebaseInfo(Object &O) const;
36 void readBindInfo(Object &O) const;
37 void readWeakBindInfo(Object &O) const;
38 void readLazyBindInfo(Object &O) const;
39 void readExportInfo(Object &O) const;
40
41public:
42 explicit MachOReader(const object::MachOObjectFile &Obj) : MachOObj(Obj) {}
43
44 std::unique_ptr<Object> create() const override;
45};
46
47} // end namespace macho
48} // end namespace objcopy
49} // end namespace llvm