Path: blob/main/contrib/llvm-project/lld/COFF/MinGW.h
34870 views
//===- MinGW.h --------------------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLD_COFF_MINGW_H9#define LLD_COFF_MINGW_H1011#include "Config.h"12#include "Symbols.h"13#include "lld/Common/LLVM.h"14#include "llvm/ADT/ArrayRef.h"15#include "llvm/ADT/DenseSet.h"16#include "llvm/ADT/StringSet.h"17#include "llvm/Option/ArgList.h"18#include <vector>1920namespace lld::coff {21class COFFLinkerContext;2223// Logic for deciding what symbols to export, when exporting all24// symbols for MinGW.25class AutoExporter {26public:27AutoExporter(COFFLinkerContext &ctx,28const llvm::DenseSet<StringRef> &manualExcludeSymbols);2930void addWholeArchive(StringRef path);31void addExcludedSymbol(StringRef symbol);3233llvm::StringSet<> excludeSymbols;34llvm::StringSet<> excludeSymbolPrefixes;35llvm::StringSet<> excludeSymbolSuffixes;36llvm::StringSet<> excludeLibs;37llvm::StringSet<> excludeObjects;3839const llvm::DenseSet<StringRef> &manualExcludeSymbols;4041bool shouldExport(Defined *sym) const;4243private:44COFFLinkerContext &ctx;45};4647void writeDefFile(StringRef name, const std::vector<Export> &exports);4849// The -wrap option is a feature to rename symbols so that you can write50// wrappers for existing functions. If you pass `-wrap:foo`, all51// occurrences of symbol `foo` are resolved to `__wrap_foo` (so, you are52// expected to write `__wrap_foo` function as a wrapper). The original53// symbol becomes accessible as `__real_foo`, so you can call that from your54// wrapper.55//56// This data structure is instantiated for each -wrap option.57struct WrappedSymbol {58Symbol *sym;59Symbol *real;60Symbol *wrap;61};6263std::vector<WrappedSymbol> addWrappedSymbols(COFFLinkerContext &ctx,64llvm::opt::InputArgList &args);6566void wrapSymbols(COFFLinkerContext &ctx, ArrayRef<WrappedSymbol> wrapped);6768} // namespace lld::coff6970#endif717273