1//===- COFFImportFile.h - COFF short import file implementation -*- C++ -*-===// 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// COFF short import file is a special kind of file which contains 10// only symbol names for DLL-exported symbols. This class implements 11// exporting of Symbols to create libraries and a SymbolicFile 12// interface for the file type. 14//===----------------------------------------------------------------------===// 16#ifndef LLVM_OBJECT_COFFIMPORTFILE_H 17#define LLVM_OBJECT_COFFIMPORTFILE_H 32"__NULL_IMPORT_DESCRIPTOR";
38enum SymbolIndex { ImpSymbol, ThunkSymbol, ECAuxSymbol, ECThunkSymbol };
61 Symb.
p = ImpSymbol + 1;
63 Symb.
p = ECThunkSymbol + 1;
65 Symb.
p = ThunkSymbol + 1;
69boolis64Bit()
const override{
returnfalse; }
88 /// The name of the export as specified in the .def file or on the command 89 /// line, i.e. "foo" in "/EXPORT:foo", and "bar" in "/EXPORT:foo=bar". This 90 /// may lack mangling, such as underscore prefixing and stdcall suffixing. 93 /// The external, exported name. Only non-empty when export renaming is in 94 /// effect, i.e. "foo" in "/EXPORT:foo=bar". 97 /// The real, mangled symbol name from the object file. Given 98 /// "/export:foo=bar", this could be "_bar@8" if bar is stdcall. 101 /// Creates an import library entry that imports from a DLL export with a 102 /// different name. This is the name of the DLL export that should be 103 /// referenced when linking against this import library entry. In a .def 104 /// file, this is "baz" in "EXPORTS\nfoo = bar == baz". 107 /// Specifies EXPORTAS name. In a .def file, this is "bar" in 108 /// "EXPORTS\nfoo EXPORTAS bar". 118return L.Name == R.Name && L.ExtName == R.ExtName &&
119 L.Ordinal == R.Ordinal && L.Noname == R.Noname &&
120 L.Data == R.Data && L.Private == R.Private;
128/// Writes a COFF import library containing entries described by the Exports 131/// For hybrid targets such as ARM64EC, additional native entry points can be 132/// exposed using the NativeExports parameter. When NativeExports is used, the 133/// output import library will expose these native ARM64 imports alongside the 134/// entries described in the Exports array. Such a library can be used for 135/// linking both ARM64EC and pure ARM64 objects, and the linker will pick only 136/// the exports relevant to the target platform. For non-hybrid targets, 137/// the NativeExports parameter should not be used. COFF::MachineTypes Machine
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
This is an important base class in LLVM.
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
const char * getBufferStart() const
StringRef - Represent a constant reference to a string, i.e.
This is a value type class that represents a single symbol in the list of symbols in the object file.
const coff_import_header * getCOFFImportHeader() const
Expected< uint32_t > getSymbolFlags(DataRefImpl Symb) const override
bool is64Bit() const override
void moveSymbolNext(DataRefImpl &Symb) const override
StringRef getFileFormatName() const
COFFImportFile(MemoryBufferRef Source)
basic_symbol_iterator symbol_begin() const override
StringRef getExportName() const
Error printSymbolName(raw_ostream &OS, DataRefImpl Symb) const override
basic_symbol_iterator symbol_end() const override
static bool classof(Binary const *V)
uint16_t getMachine() const
This class implements an extremely fast bulk output stream that can only output to a stream.
bool isArm64EC(T Machine)
constexpr std::string_view NullImportDescriptorSymbolName
constexpr std::string_view NullThunkDataPrefix
constexpr std::string_view NullThunkDataSuffix
constexpr std::string_view ImportDescriptorPrefix
Error writeImportLibrary(StringRef ImportName, StringRef Path, ArrayRef< COFFShortExport > Exports, COFF::MachineTypes Machine, bool MinGW, ArrayRef< COFFShortExport > NativeExports={})
Writes a COFF import library containing entries described by the Exports array.
This is an optimization pass for GlobalISel generic memory operations.
std::string Name
The name of the export as specified in the .def file or on the command line, i.e.
std::string SymbolName
The real, mangled symbol name from the object file.
std::string ExportAs
Specifies EXPORTAS name.
friend bool operator!=(const COFFShortExport &L, const COFFShortExport &R)
std::string ImportName
Creates an import library entry that imports from a DLL export with a different name.
std::string ExtName
The external, exported name.
friend bool operator==(const COFFShortExport &L, const COFFShortExport &R)
support::ulittle16_t Machine