summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2018-04-25 22:34:21 +0000
committerRui Ueyama <ruiu@google.com>2018-04-25 22:34:21 +0000
commit5fcebff4851aa942d82df428990acf5c8410cf25 (patch)
tree6dc05694024e19bdacc17aefb3621ac1ffa90b70
parent76661e0f36bb200226102eb749e7b56ffbd69403 (diff)
downloadbcm5719-llvm-5fcebff4851aa942d82df428990acf5c8410cf25.tar.gz
bcm5719-llvm-5fcebff4851aa942d82df428990acf5c8410cf25.zip
Remove unused features from StringRefZ and move it to Symbols.h.
Differential Revision: https://reviews.llvm.org/D46087 llvm-svn: 330879
-rw-r--r--lld/ELF/Symbols.h30
-rw-r--r--lld/include/lld/Common/Strings.h33
2 files changed, 22 insertions, 41 deletions
diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h
index 9e15f7d8033..78391fc1db2 100644
--- a/lld/ELF/Symbols.h
+++ b/lld/ELF/Symbols.h
@@ -32,6 +32,20 @@ template <class ELFT> class ObjFile;
class OutputSection;
template <class ELFT> class SharedFile;
+// This is a StringRef-like container that doesn't run strlen().
+//
+// ELF string tables contain a lot of null-terminated strings. Most of them
+// are not necessary for the linker because they are names of local symbols,
+// and the linker doesn't use local symbol names for name resolution. So, we
+// use this class to represents strings read from string tables.
+struct StringRefZ {
+ StringRefZ(const char *S) : Data(S), Size(-1) {}
+ StringRefZ(StringRef S) : Data(S.data()), Size(S.size()) {}
+
+ const char *Data;
+ const uint32_t Size;
+};
+
// The base class for real symbol classes.
class Symbol {
public:
@@ -49,7 +63,7 @@ public:
InputFile *File;
protected:
- const char *NameStart;
+ const char *NameData;
mutable uint32_t NameSize;
public:
@@ -117,9 +131,10 @@ public:
StringRef getName() const {
if (NameSize == (uint32_t)-1)
- NameSize = strlen(NameStart);
- return StringRef(NameStart, NameSize);
+ NameSize = strlen(NameData);
+ return {NameData, NameSize};
}
+
void parseSymbolVersion();
bool isInGot() const { return GotIndex != -1U; }
@@ -138,11 +153,10 @@ public:
protected:
Symbol(Kind K, InputFile *File, StringRefZ Name, uint8_t Binding,
uint8_t StOther, uint8_t Type)
- : File(File), NameStart(Name.data()), NameSize(Name.rawSize()),
- Binding(Binding), Type(Type), StOther(StOther), SymbolKind(K),
- NeedsPltAddr(false), IsInGlobalMipsGot(false), Is32BitMipsGot(false),
- IsInIplt(false), IsInIgot(false), IsPreemptible(false),
- Used(!Config->GcSections) {}
+ : File(File), NameData(Name.Data), NameSize(Name.Size), Binding(Binding),
+ Type(Type), StOther(StOther), SymbolKind(K), NeedsPltAddr(false),
+ IsInGlobalMipsGot(false), Is32BitMipsGot(false), IsInIplt(false),
+ IsInIgot(false), IsPreemptible(false), Used(!Config->GcSections) {}
public:
// True the symbol should point to its PLT entry.
diff --git a/lld/include/lld/Common/Strings.h b/lld/include/lld/Common/Strings.h
index 9b1469a3b82..177cc15449f 100644
--- a/lld/include/lld/Common/Strings.h
+++ b/lld/include/lld/Common/Strings.h
@@ -26,39 +26,6 @@ llvm::Optional<std::string> demangleMSVC(llvm::StringRef S);
std::vector<uint8_t> parseHex(llvm::StringRef S);
bool isValidCIdentifier(llvm::StringRef S);
-// This is a lazy version of StringRef. String size is computed lazily
-// when it is needed. It is more efficient than StringRef to instantiate
-// if you have a string whose size is unknown.
-//
-// COFF and ELF string tables contain a lot of null-terminated strings.
-// Most of them are not necessary for the linker because they are names
-// of local symbols and the linker doesn't use local symbol names for
-// name resolution. So, we use this class to represents strings read
-// from string tables.
-class StringRefZ {
-public:
- StringRefZ() : Start(nullptr), Size(0) {}
- StringRefZ(const char *S, size_t Size) : Start(S), Size(Size) {}
-
- /*implicit*/ StringRefZ(const char *S) : Start(S), Size(-1) {}
-
- /*implicit*/ StringRefZ(llvm::StringRef S)
- : Start(S.data()), Size(S.size()) {}
-
- const char *data() const { return Start; }
- size_t rawSize() const { return Size; };
-
- operator llvm::StringRef() const {
- if (Size == (size_t)-1)
- Size = strlen(Start);
- return {Start, Size};
- }
-
-private:
- const char *Start;
- mutable size_t Size;
-};
-
// This class represents multiple glob patterns.
class StringMatcher {
public:
OpenPOWER on IntegriCloud