[lld] 961439c - [ELF] Add LLVM_LIBRARY_VISIBILITY to some global variables. NFC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 2 13:24:01 PDT 2022


Author: Fangrui Song
Date: 2022-10-02T13:23:52-07:00
New Revision: 961439cd7e1f1e6bfbe3733ede0443d0e02c5c72

URL: https://github.com/llvm/llvm-project/commit/961439cd7e1f1e6bfbe3733ede0443d0e02c5c72
DIFF: https://github.com/llvm/llvm-project/commit/961439cd7e1f1e6bfbe3733ede0443d0e02c5c72.diff

LOG: [ELF] Add LLVM_LIBRARY_VISIBILITY to some global variables. NFC

Added: 
    

Modified: 
    lld/ELF/InputSection.h
    lld/ELF/LinkerScript.h
    lld/ELF/OutputSections.h
    lld/ELF/Symbols.h
    lld/ELF/SyntheticSections.h
    lld/ELF/Target.h

Removed: 
    


################################################################################
diff  --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h
index ce1cdc75cb014..0663b2763e58c 100644
--- a/lld/ELF/InputSection.h
+++ b/lld/ELF/InputSection.h
@@ -17,6 +17,7 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/TinyPtrVector.h"
 #include "llvm/Object/ELF.h"
+#include "llvm/Support/Compiler.h"
 
 namespace lld {
 namespace elf {
@@ -30,7 +31,7 @@ class SyntheticSection;
 template <class ELFT> class ObjFile;
 class OutputSection;
 
-extern std::vector<Partition> partitions;
+LLVM_LIBRARY_VISIBILITY extern std::vector<Partition> partitions;
 
 // Returned by InputSectionBase::relsOrRelas. At least one member is empty.
 template <class ELFT> struct RelsOrRelas {

diff  --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h
index 614e8680f22a5..f50b6c4cec290 100644
--- a/lld/ELF/LinkerScript.h
+++ b/lld/ELF/LinkerScript.h
@@ -17,6 +17,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Compiler.h"
 #include <cstddef>
 #include <cstdint>
 #include <functional>
@@ -362,7 +363,7 @@ class LinkerScript final {
   SmallVector<const InputSectionBase *, 0> orphanSections;
 };
 
-extern std::unique_ptr<LinkerScript> script;
+LLVM_LIBRARY_VISIBILITY extern std::unique_ptr<LinkerScript> script;
 
 } // end namespace lld::elf
 

diff  --git a/lld/ELF/OutputSections.h b/lld/ELF/OutputSections.h
index 2ba8652981624..f7f5dc3514824 100644
--- a/lld/ELF/OutputSections.h
+++ b/lld/ELF/OutputSections.h
@@ -12,6 +12,7 @@
 #include "InputSection.h"
 #include "LinkerScript.h"
 #include "lld/Common/LLVM.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Parallel.h"
 
 #include <array>
@@ -156,7 +157,8 @@ struct Out {
 
 uint64_t getHeaderSize();
 
-extern llvm::SmallVector<OutputSection *, 0> outputSections;
+LLVM_LIBRARY_VISIBILITY extern llvm::SmallVector<OutputSection *, 0>
+    outputSections;
 } // namespace lld::elf
 
 #endif

diff  --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h
index 2d1b1d4a47e79..8fa384428da97 100644
--- a/lld/ELF/Symbols.h
+++ b/lld/ELF/Symbols.h
@@ -18,6 +18,7 @@
 #include "lld/Common/Memory.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/Object/ELF.h"
+#include "llvm/Support/Compiler.h"
 #include <tuple>
 
 namespace lld {
@@ -64,7 +65,7 @@ struct SymbolAux {
   uint32_t tlsGdIdx = -1;
 };
 
-extern SmallVector<SymbolAux, 0> symAux;
+LLVM_LIBRARY_VISIBILITY extern SmallVector<SymbolAux, 0> symAux;
 
 // The base class for real symbol classes.
 class Symbol {

diff  --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h
index a09477e1a4116..e2f719a4618e9 100644
--- a/lld/ELF/SyntheticSections.h
+++ b/lld/ELF/SyntheticSections.h
@@ -25,6 +25,7 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/MC/StringTableBuilder.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/Parallel.h"
 #include "llvm/Support/Threading.h"
@@ -1262,7 +1263,7 @@ struct Partition {
   unsigned getNumber() const { return this - &partitions[0] + 1; }
 };
 
-extern Partition *mainPart;
+LLVM_LIBRARY_VISIBILITY extern Partition *mainPart;
 
 inline Partition &SectionBase::getPartition() const {
   assert(isLive());
@@ -1300,7 +1301,7 @@ struct InStruct {
   void reset();
 };
 
-extern InStruct in;
+LLVM_LIBRARY_VISIBILITY extern InStruct in;
 
 } // namespace lld::elf
 

diff  --git a/lld/ELF/Target.h b/lld/ELF/Target.h
index 14b1f53c6a819..cfe288037f3ed 100644
--- a/lld/ELF/Target.h
+++ b/lld/ELF/Target.h
@@ -13,6 +13,7 @@
 #include "InputSection.h"
 #include "lld/Common/ErrorHandler.h"
 #include "llvm/Object/ELF.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/MathExtras.h"
 #include <array>
 
@@ -238,7 +239,7 @@ class AArch64Relaxer {
                        uint64_t secAddr, uint8_t *buf) const;
 };
 
-extern const TargetInfo *target;
+LLVM_LIBRARY_VISIBILITY extern const TargetInfo *target;
 TargetInfo *getTarget();
 
 template <class ELFT> bool isMipsPIC(const Defined *sym);


        


More information about the llvm-commits mailing list