| 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 |  | 
|  | 10 | #ifndef LLD_READER_WRITER_MACHO_EXECUTABLE_ATOM_H_ | 
|  | 11 | #define LLD_READER_WRITER_MACHO_EXECUTABLE_ATOM_H_ | 
|  | 12 |  | 
|  | 13 |  | 
|  | 14 | #include "lld/Core/DefinedAtom.h" | 
|  | 15 | #include "lld/Core/UndefinedAtom.h" | 
|  | 16 | #include "lld/Core/File.h" | 
|  | 17 | #include "lld/Core/Reference.h" | 
| Michael J. Spencer | 64afcb4 | 2013-01-23 01:18:43 +0000 | [diff] [blame] | 18 | #include "lld/Core/TargetInfo.h" | 
| Michael J. Spencer | 19c4756 | 2013-01-24 22:52:25 +0000 | [diff] [blame] | 19 | #include "lld/ReaderWriter/Simple.h" | 
| Nick Kledzik | abb6981 | 2012-05-31 22:34:00 +0000 | [diff] [blame] | 20 |  | 
|  | 21 | namespace lld { | 
|  | 22 | namespace mach_o { | 
|  | 23 |  | 
|  | 24 |  | 
|  | 25 | // | 
|  | 26 | // CRuntimeFile adds an UndefinedAtom for "_main" so that the Resolving | 
|  | 27 | // phase will fail if "_main" is undefined. | 
|  | 28 | // | 
|  | 29 | class CRuntimeFile : public SimpleFile { | 
|  | 30 | public: | 
| Michael J. Spencer | 64afcb4 | 2013-01-23 01:18:43 +0000 | [diff] [blame] | 31 | CRuntimeFile(const MachOTargetInfo &ti) | 
| Nick Kledzik | c314b46 | 2013-04-04 18:59:24 +0000 | [diff] [blame] | 32 | : SimpleFile(ti, "C runtime"), _undefMain(*this, ti.entrySymbolName()) { | 
| Nick Kledzik | abb6981 | 2012-05-31 22:34:00 +0000 | [diff] [blame] | 33 | // only main executables need _main | 
| Nick Kledzik | c314b46 | 2013-04-04 18:59:24 +0000 | [diff] [blame] | 34 | if (ti.outputFileType() == MH_EXECUTE) { | 
| Nick Kledzik | abb6981 | 2012-05-31 22:34:00 +0000 | [diff] [blame] | 35 | this->addAtom(_undefMain); | 
| Nick Kledzik | c314b46 | 2013-04-04 18:59:24 +0000 | [diff] [blame] | 36 | } | 
| Nick Kledzik | abb6981 | 2012-05-31 22:34:00 +0000 | [diff] [blame] | 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; | 
|  | 41 | }; | 
|  | 42 |  | 
|  | 43 |  | 
|  | 44 |  | 
|  | 45 | } // namespace mach_o | 
|  | 46 | } // namespace lld | 
|  | 47 |  | 
|  | 48 |  | 
|  | 49 | #endif // LLD_READER_WRITER_MACHO_EXECUTABLE_ATOM_H_ |