1//===- lib/ReaderWriter/MachO/FlatNamespaceFile.h -------------------------===// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8 9#ifndef LLD_READER_WRITER_MACHO_FLAT_NAMESPACE_FILE_H 10#define LLD_READER_WRITER_MACHO_FLAT_NAMESPACE_FILE_H 11 12#include "Atoms.h" 13#include "lld/Core/SharedLibraryFile.h" 14#include "lld/ReaderWriter/MachOLinkingContext.h" 15#include "llvm/Support/Debug.h" 16 17namespace lld { 18namespace mach_o { 19 20// 21// A FlateNamespaceFile instance may be added as a resolution source of last 22// resort, depending on how -flat_namespace and -undefined are set. 23// 24class FlatNamespaceFile : public SharedLibraryFile { 25public: 26 FlatNamespaceFile(const MachOLinkingContext &context) 27 : SharedLibraryFile("flat namespace") { } 28 29 OwningAtomPtr<SharedLibraryAtom> exports(StringRef name) const override { 30 return new (allocator()) MachOSharedLibraryAtom(*this, name, getDSOName(), 31 false); 32 } 33 34 StringRef getDSOName() const override { return "flat-namespace"; } 35 36 const AtomRange<DefinedAtom> defined() const override { 37 return _noDefinedAtoms; 38 } 39 const AtomRange<UndefinedAtom> undefined() const override { 40 return _noUndefinedAtoms; 41 } 42 43 const AtomRange<SharedLibraryAtom> sharedLibrary() const override { 44 return _noSharedLibraryAtoms; 45 } 46 47 const AtomRange<AbsoluteAtom> absolute() const override { 48 return _noAbsoluteAtoms; 49 } 50 51 void clearAtoms() override { 52 _noDefinedAtoms.clear(); 53 _noUndefinedAtoms.clear(); 54 _noSharedLibraryAtoms.clear(); 55 _noAbsoluteAtoms.clear(); 56 } 57}; 58 59} // namespace mach_o 60} // namespace lld 61 62#endif // LLD_READER_WRITER_MACHO_FLAT_NAMESPACE_FILE_H 63