| Nick Kledzik | abb6981 | 2012-05-31 22:34:00 +0000 | [diff] [blame] | 1 | //===- lib/ReaderWriter/MachO/ExecutableAtoms.hpp -------------------------===// |
| 2 | // |
| 3 | // The LLVM Linker |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| Rui Ueyama | 014192db | 2013-11-15 03:09:26 +0000 | [diff] [blame] | 10 | #ifndef LLD_READER_WRITER_MACHO_EXECUTABLE_ATOMS_H |
| 11 | #define LLD_READER_WRITER_MACHO_EXECUTABLE_ATOMS_H |
| Nick Kledzik | abb6981 | 2012-05-31 22:34:00 +0000 | [diff] [blame] | 12 | |
| Nick Kledzik | 473933b | 2013-09-27 22:50:00 +0000 | [diff] [blame] | 13 | #include "llvm/Support/MachO.h" |
| Nick Kledzik | abb6981 | 2012-05-31 22:34:00 +0000 | [diff] [blame] | 14 | |
| 15 | #include "lld/Core/DefinedAtom.h" |
| Nick Kledzik | abb6981 | 2012-05-31 22:34:00 +0000 | [diff] [blame] | 16 | #include "lld/Core/File.h" |
| Rui Ueyama | 0ca149f | 2013-08-06 22:31:59 +0000 | [diff] [blame] | 17 | #include "lld/Core/LinkingContext.h" |
| Rui Ueyama | e05d380 | 2014-06-11 21:47:51 +0000 | [diff] [blame] | 18 | #include "lld/Core/Reference.h" |
| 19 | #include "lld/Core/Simple.h" |
| 20 | #include "lld/Core/UndefinedAtom.h" |
| Rafael Espindola | 1675d51 | 2014-06-12 17:12:28 +0000 | [diff] [blame] | 21 | #include "lld/ReaderWriter/MachOLinkingContext.h" |
| Nick Kledzik | abb6981 | 2012-05-31 22:34:00 +0000 | [diff] [blame] | 22 | |
| 23 | namespace lld { |
| 24 | namespace mach_o { |
| 25 | |
| 26 | |
| 27 | // |
| Nick Kledzik | ebf09360 | 2014-08-13 23:31:07 +0000 | [diff] [blame^] | 28 | // CEntryFile adds an UndefinedAtom for "_main" so that the Resolving |
| Nick Kledzik | abb6981 | 2012-05-31 22:34:00 +0000 | [diff] [blame] | 29 | // phase will fail if "_main" is undefined. |
| 30 | // |
| Nick Kledzik | ebf09360 | 2014-08-13 23:31:07 +0000 | [diff] [blame^] | 31 | class CEntryFile : public SimpleFile { |
| Nick Kledzik | abb6981 | 2012-05-31 22:34:00 +0000 | [diff] [blame] | 32 | public: |
| Nick Kledzik | ebf09360 | 2014-08-13 23:31:07 +0000 | [diff] [blame^] | 33 | CEntryFile(const MachOLinkingContext &context) |
| 34 | : SimpleFile("C entry"), |
| 35 | _undefMain(*this, context.entrySymbolName()) { |
| 36 | this->addAtom(_undefMain); |
| 37 | } |
| Nick Kledzik | c314b46 | 2013-04-04 18:59:24 +0000 | [diff] [blame] | 38 | |
| Nick Kledzik | abb6981 | 2012-05-31 22:34:00 +0000 | [diff] [blame] | 39 | private: |
| 40 | SimpleUndefinedAtom _undefMain; |
| Nick Kledzik | ebf09360 | 2014-08-13 23:31:07 +0000 | [diff] [blame^] | 41 | }; |
| 42 | |
| 43 | |
| 44 | // |
| 45 | // StubHelperFile adds an UndefinedAtom for "dyld_stub_binder" so that |
| 46 | // the Resolveing phase will fail if "dyld_stub_binder" is undefined. |
| 47 | // |
| 48 | class StubHelperFile : public SimpleFile { |
| 49 | public: |
| 50 | StubHelperFile(const MachOLinkingContext &context) |
| 51 | : SimpleFile("stub runtime"), |
| 52 | _undefBinder(*this, context.binderSymbolName()) { |
| 53 | this->addAtom(_undefBinder); |
| 54 | } |
| 55 | |
| 56 | private: |
| Nick Kledzik | 2458bec | 2014-07-16 19:49:02 +0000 | [diff] [blame] | 57 | SimpleUndefinedAtom _undefBinder; |
| Nick Kledzik | abb6981 | 2012-05-31 22:34:00 +0000 | [diff] [blame] | 58 | }; |
| 59 | |
| Nick Kledzik | ebf09360 | 2014-08-13 23:31:07 +0000 | [diff] [blame^] | 60 | |
| 61 | |
| 62 | |
| 63 | |
| Rui Ueyama | 0ca149f | 2013-08-06 22:31:59 +0000 | [diff] [blame] | 64 | } // namespace mach_o |
| 65 | } // namespace lld |
| Nick Kledzik | abb6981 | 2012-05-31 22:34:00 +0000 | [diff] [blame] | 66 | |
| Rui Ueyama | 014192db | 2013-11-15 03:09:26 +0000 | [diff] [blame] | 67 | #endif // LLD_READER_WRITER_MACHO_EXECUTABLE_ATOMS_H |