| 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" | 
|  | 16 | #include "lld/Core/UndefinedAtom.h" | 
|  | 17 | #include "lld/Core/File.h" | 
|  | 18 | #include "lld/Core/Reference.h" | 
| Rui Ueyama | 0ca149f | 2013-08-06 22:31:59 +0000 | [diff] [blame] | 19 | #include "lld/Core/LinkingContext.h" | 
| Michael J. Spencer | 19c4756 | 2013-01-24 22:52:25 +0000 | [diff] [blame] | 20 | #include "lld/ReaderWriter/Simple.h" | 
| Nick Kledzik | abb6981 | 2012-05-31 22:34:00 +0000 | [diff] [blame] | 21 |  | 
|  | 22 | namespace lld { | 
|  | 23 | namespace mach_o { | 
|  | 24 |  | 
|  | 25 |  | 
|  | 26 | // | 
|  | 27 | // CRuntimeFile adds an UndefinedAtom for "_main" so that the Resolving | 
|  | 28 | // phase will fail if "_main" is undefined. | 
|  | 29 | // | 
|  | 30 | class CRuntimeFile : public SimpleFile { | 
|  | 31 | public: | 
| Rui Ueyama | 170a1a8 | 2013-12-20 07:48:29 +0000 | [diff] [blame] | 32 | CRuntimeFile(const MachOLinkingContext &context) | 
|  | 33 | : SimpleFile("C runtime"), _undefMain(*this, context.entrySymbolName()) { | 
| Nick Kledzik | abb6981 | 2012-05-31 22:34:00 +0000 | [diff] [blame] | 34 | // only main executables need _main | 
| Nick Kledzik | 473933b | 2013-09-27 22:50:00 +0000 | [diff] [blame] | 35 | if (context.outputFileType() == llvm::MachO::MH_EXECUTE) { | 
| Nick Kledzik | abb6981 | 2012-05-31 22:34:00 +0000 | [diff] [blame] | 36 | this->addAtom(_undefMain); | 
| Nick Kledzik | c314b46 | 2013-04-04 18:59:24 +0000 | [diff] [blame] | 37 | } | 
| Nick Kledzik | abb6981 | 2012-05-31 22:34:00 +0000 | [diff] [blame] | 38 | } | 
| Nick Kledzik | c314b46 | 2013-04-04 18:59:24 +0000 | [diff] [blame] | 39 |  | 
| Nick Kledzik | abb6981 | 2012-05-31 22:34:00 +0000 | [diff] [blame] | 40 | private: | 
|  | 41 | SimpleUndefinedAtom   _undefMain; | 
|  | 42 | }; | 
|  | 43 |  | 
| Rui Ueyama | 0ca149f | 2013-08-06 22:31:59 +0000 | [diff] [blame] | 44 | } // namespace mach_o | 
|  | 45 | } // namespace lld | 
| Nick Kledzik | abb6981 | 2012-05-31 22:34:00 +0000 | [diff] [blame] | 46 |  | 
| Rui Ueyama | 014192db | 2013-11-15 03:09:26 +0000 | [diff] [blame] | 47 | #endif // LLD_READER_WRITER_MACHO_EXECUTABLE_ATOMS_H |