2017-10-20 03:49:38 +08:00
|
|
|
//===- MinGW.h --------------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2017-10-20 03:49:38 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLD_COFF_MINGW_H
|
|
|
|
#define LLD_COFF_MINGW_H
|
|
|
|
|
|
|
|
#include "Config.h"
|
|
|
|
#include "Symbols.h"
|
|
|
|
#include "lld/Common/LLVM.h"
|
2020-10-06 18:54:49 +08:00
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
2019-11-15 05:46:00 +08:00
|
|
|
#include "llvm/ADT/StringSet.h"
|
2020-10-06 18:54:49 +08:00
|
|
|
#include "llvm/Option/ArgList.h"
|
|
|
|
#include <vector>
|
2017-10-20 03:49:38 +08:00
|
|
|
|
|
|
|
namespace lld {
|
|
|
|
namespace coff {
|
2021-09-17 07:48:26 +08:00
|
|
|
class COFFLinkerContext;
|
2017-10-20 03:49:38 +08:00
|
|
|
|
|
|
|
// Logic for deciding what symbols to export, when exporting all
|
|
|
|
// symbols for MinGW.
|
|
|
|
class AutoExporter {
|
|
|
|
public:
|
|
|
|
AutoExporter();
|
|
|
|
|
2018-09-05 04:56:56 +08:00
|
|
|
void addWholeArchive(StringRef path);
|
|
|
|
|
2017-10-20 04:19:16 +08:00
|
|
|
llvm::StringSet<> excludeSymbols;
|
2018-09-26 14:13:47 +08:00
|
|
|
llvm::StringSet<> excludeSymbolPrefixes;
|
|
|
|
llvm::StringSet<> excludeSymbolSuffixes;
|
2017-10-20 04:19:16 +08:00
|
|
|
llvm::StringSet<> excludeLibs;
|
|
|
|
llvm::StringSet<> excludeObjects;
|
2017-10-20 03:49:38 +08:00
|
|
|
|
2021-09-17 07:48:26 +08:00
|
|
|
bool shouldExport(const COFFLinkerContext &ctx, Defined *sym) const;
|
2017-10-20 03:49:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
void writeDefFile(StringRef name);
|
|
|
|
|
2020-10-06 18:54:49 +08:00
|
|
|
// The -wrap option is a feature to rename symbols so that you can write
|
|
|
|
// wrappers for existing functions. If you pass `-wrap:foo`, all
|
|
|
|
// occurrences of symbol `foo` are resolved to `__wrap_foo` (so, you are
|
|
|
|
// expected to write `__wrap_foo` function as a wrapper). The original
|
|
|
|
// symbol becomes accessible as `__real_foo`, so you can call that from your
|
|
|
|
// wrapper.
|
|
|
|
//
|
|
|
|
// This data structure is instantiated for each -wrap option.
|
|
|
|
struct WrappedSymbol {
|
|
|
|
Symbol *sym;
|
|
|
|
Symbol *real;
|
|
|
|
Symbol *wrap;
|
|
|
|
};
|
|
|
|
|
2021-09-17 07:48:26 +08:00
|
|
|
std::vector<WrappedSymbol> addWrappedSymbols(COFFLinkerContext &ctx,
|
|
|
|
llvm::opt::InputArgList &args);
|
2020-10-06 18:54:49 +08:00
|
|
|
|
2021-09-17 07:48:26 +08:00
|
|
|
void wrapSymbols(COFFLinkerContext &ctx, ArrayRef<WrappedSymbol> wrapped);
|
2020-10-06 18:54:49 +08:00
|
|
|
|
2017-10-20 03:49:38 +08:00
|
|
|
} // namespace coff
|
|
|
|
} // namespace lld
|
|
|
|
|
|
|
|
#endif
|