llvm-project/lld/lib/ReaderWriter/MachO/ExecutableAtoms.hpp
Nick Kledzik 2458bec7e7 [mach-o] refactor KindHandler into ArchHandler and simplify passes.
All architecture specific handling is now done in the appropriate
ArchHandler subclass.

The StubsPass and GOTPass have been simplified.  All architecture specific
variations in stubs are now encoded in a table which is vended by the
current ArchHandler.

llvm-svn: 213187
2014-07-16 19:49:02 +00:00

56 lines
1.5 KiB
C++

//===- lib/ReaderWriter/MachO/ExecutableAtoms.hpp -------------------------===//
//
// The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLD_READER_WRITER_MACHO_EXECUTABLE_ATOMS_H
#define LLD_READER_WRITER_MACHO_EXECUTABLE_ATOMS_H
#include "llvm/Support/MachO.h"
#include "lld/Core/DefinedAtom.h"
#include "lld/Core/File.h"
#include "lld/Core/LinkingContext.h"
#include "lld/Core/Reference.h"
#include "lld/Core/Simple.h"
#include "lld/Core/UndefinedAtom.h"
#include "lld/ReaderWriter/MachOLinkingContext.h"
namespace lld {
namespace mach_o {
//
// CRuntimeFile adds an UndefinedAtom for "_main" so that the Resolving
// phase will fail if "_main" is undefined.
//
class CRuntimeFile : public SimpleFile {
public:
CRuntimeFile(const MachOLinkingContext &context)
: SimpleFile("C runtime"),
_undefMain(*this, context.entrySymbolName()),
_undefBinder(*this, context.binderSymbolName()) {
// only main executables need _main
if (context.outputMachOType() == llvm::MachO::MH_EXECUTE) {
this->addAtom(_undefMain);
}
// only dynamic binaries use stubs
if (context.needsStubsPass()) {
this->addAtom(_undefBinder);
}
}
private:
SimpleUndefinedAtom _undefMain;
SimpleUndefinedAtom _undefBinder;
};
} // namespace mach_o
} // namespace lld
#endif // LLD_READER_WRITER_MACHO_EXECUTABLE_ATOMS_H