Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / lld / COFF / MinGW.h
blobaa5e53278ca4bf46a7f4be454a5d28b4b1461d1c
1 //===- MinGW.h --------------------------------------------------*- C++ -*-===//
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 //===----------------------------------------------------------------------===//
9 #ifndef LLD_COFF_MINGW_H
10 #define LLD_COFF_MINGW_H
12 #include "Config.h"
13 #include "Symbols.h"
14 #include "lld/Common/LLVM.h"
15 #include "llvm/ADT/ArrayRef.h"
16 #include "llvm/ADT/DenseSet.h"
17 #include "llvm/ADT/StringSet.h"
18 #include "llvm/Option/ArgList.h"
19 #include <vector>
21 namespace lld::coff {
22 class COFFLinkerContext;
24 // Logic for deciding what symbols to export, when exporting all
25 // symbols for MinGW.
26 class AutoExporter {
27 public:
28 AutoExporter(COFFLinkerContext &ctx,
29 const llvm::DenseSet<StringRef> &manualExcludeSymbols);
31 void addWholeArchive(StringRef path);
32 void addExcludedSymbol(StringRef symbol);
34 llvm::StringSet<> excludeSymbols;
35 llvm::StringSet<> excludeSymbolPrefixes;
36 llvm::StringSet<> excludeSymbolSuffixes;
37 llvm::StringSet<> excludeLibs;
38 llvm::StringSet<> excludeObjects;
40 const llvm::DenseSet<StringRef> &manualExcludeSymbols;
42 bool shouldExport(Defined *sym) const;
44 private:
45 COFFLinkerContext &ctx;
48 void writeDefFile(StringRef name, const std::vector<Export> &exports);
50 // The -wrap option is a feature to rename symbols so that you can write
51 // wrappers for existing functions. If you pass `-wrap:foo`, all
52 // occurrences of symbol `foo` are resolved to `__wrap_foo` (so, you are
53 // expected to write `__wrap_foo` function as a wrapper). The original
54 // symbol becomes accessible as `__real_foo`, so you can call that from your
55 // wrapper.
57 // This data structure is instantiated for each -wrap option.
58 struct WrappedSymbol {
59 Symbol *sym;
60 Symbol *real;
61 Symbol *wrap;
64 std::vector<WrappedSymbol> addWrappedSymbols(COFFLinkerContext &ctx,
65 llvm::opt::InputArgList &args);
67 void wrapSymbols(COFFLinkerContext &ctx, ArrayRef<WrappedSymbol> wrapped);
69 } // namespace lld::coff
71 #endif