blob: 795e5cc2363d31a53efda715c8fb6124e7600d99 [file] [log] [blame]
Alexander Shaposhnikovd911ed12019-02-02 00:38:07 +00001//===- MachOReader.h --------------------------------------------*- C++ -*-===//
2//
Chandler Carruth127252b2019-02-11 08:25:19 +00003// 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
Alexander Shaposhnikovd911ed12019-02-02 00:38:07 +00006//
7//===----------------------------------------------------------------------===//
8
9#include "MachOObjcopy.h"
10#include "Object.h"
11#include "llvm/BinaryFormat/MachO.h"
12#include "llvm/Object/MachO.h"
13#include <memory>
14
15namespace llvm {
16namespace objcopy {
17namespace macho {
18
19// The hierarchy of readers is responsible for parsing different inputs:
20// raw binaries and regular MachO object files.
21class Reader {
22public:
23 virtual ~Reader(){};
24 virtual std::unique_ptr<Object> create() const = 0;
25};
26
27class MachOReader : public Reader {
28 const object::MachOObjectFile &MachOObj;
29
30 void readHeader(Object &O) const;
31 void readLoadCommands(Object &O) const;
32 void readSymbolTable(Object &O) const;
Seiya Nutaf923d9b2019-06-21 00:21:50 +000033 void setSymbolInRelocationInfo(Object &O) const;
Alexander Shaposhnikovd911ed12019-02-02 00:38:07 +000034 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;
Alexander Shaposhnikovd911ed12019-02-02 00:38:07 +000039
40public:
41 explicit MachOReader(const object::MachOObjectFile &Obj) : MachOObj(Obj) {}
42
43 std::unique_ptr<Object> create() const override;
44};
45
46} // end namespace macho
47} // end namespace objcopy
48} // end namespace llvm