1 //===- lld/Core/Writer.h - Abstract File Format Interface -----------------===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLD_CORE_WRITER_H
10 #define LLD_CORE_WRITER_H
12 #include "lld/Common/LLVM.h"
13 #include "llvm/Support/Error.h"
20 class MachOLinkingContext;
22 /// The Writer is an abstract class for writing object files, shared
23 /// library files, and executable files. Each file format (e.g. mach-o, etc)
24 /// has a concrete subclass of Writer.
29 /// Write a file from the supplied File object
30 virtual llvm::Error writeFile(const File &linkedFile, StringRef path) = 0;
32 /// This method is called by Core Linking to give the Writer a chance
33 /// to add file format specific "files" to set of files to be linked. This is
34 /// how file format specific atoms can be added to the link.
35 virtual void createImplicitFiles(std::vector<std::unique_ptr<File>> &) {}
38 // only concrete subclasses can be instantiated
42 std::unique_ptr<Writer> createWriterMachO(const MachOLinkingContext &);
43 std::unique_ptr<Writer> createWriterYAML(const LinkingContext &);
44 } // end namespace lld