blob: 54dcb69de913fc627d36d8f3c28e11d71a92970e [file] [log] [blame]
Nick Kledzikabb69812012-05-31 22:34:00 +00001//===- 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. Spencer64afcb42013-01-23 01:18:43 +000018#include "lld/Core/TargetInfo.h"
Michael J. Spencer19c47562013-01-24 22:52:25 +000019#include "lld/ReaderWriter/Simple.h"
Nick Kledzikabb69812012-05-31 22:34:00 +000020
21namespace lld {
22namespace 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//
29class CRuntimeFile : public SimpleFile {
30public:
Michael J. Spencer64afcb42013-01-23 01:18:43 +000031 CRuntimeFile(const MachOTargetInfo &ti)
Nick Kledzikc314b462013-04-04 18:59:24 +000032 : SimpleFile(ti, "C runtime"), _undefMain(*this, ti.entrySymbolName()) {
Nick Kledzikabb69812012-05-31 22:34:00 +000033 // only main executables need _main
Nick Kledzikc314b462013-04-04 18:59:24 +000034 if (ti.outputFileType() == MH_EXECUTE) {
Nick Kledzikabb69812012-05-31 22:34:00 +000035 this->addAtom(_undefMain);
Nick Kledzikc314b462013-04-04 18:59:24 +000036 }
Nick Kledzikabb69812012-05-31 22:34:00 +000037 }
Nick Kledzikc314b462013-04-04 18:59:24 +000038
Nick Kledzikabb69812012-05-31 22:34:00 +000039private:
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_