[lld] 4d9f6ca - [ELF] Change SharedFile::soName from std::string to StringRef
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 25 15:54:08 PDT 2021
Author: Fangrui Song
Date: 2021-10-25T15:54:04-07:00
New Revision: 4d9f6caee3ac159cd4907f31e0716a3797de5bf0
URL: https://github.com/llvm/llvm-project/commit/4d9f6caee3ac159cd4907f31e0716a3797de5bf0
DIFF: https://github.com/llvm/llvm-project/commit/4d9f6caee3ac159cd4907f31e0716a3797de5bf0.diff
LOG: [ELF] Change SharedFile::soName from std::string to StringRef
Added:
Modified:
lld/ELF/Driver.cpp
lld/ELF/InputFiles.h
Removed:
################################################################################
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 51b35439e790..b9093ff2f286 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -262,16 +262,11 @@ void LinkerDriver::addFile(StringRef path, bool withLOption) {
return;
}
- // DSOs usually have DT_SONAME tags in their ELF headers, and the
- // sonames are used to identify DSOs. But if they are missing,
- // they are identified by filenames. We don't know whether the new
- // file has a DT_SONAME or not because we haven't parsed it yet.
- // Here, we set the default soname for the file because we might
- // need it later.
- //
- // If a file was specified by -lfoo, the directory part is not
- // significant, as a user did not specify it. This behavior is
- // compatible with GNU.
+ // Shared objects are identified by soname. soname is (if specified)
+ // DT_SONAME and falls back to filename. If a file was specified by -lfoo,
+ // the directory part is ignored. Note that path may be a temporary and
+ // cannot be stored into SharedFile::soName.
+ path = mbref.getBufferIdentifier();
files.push_back(
make<SharedFile>(mbref, withLOption ? path::filename(path) : path));
return;
diff --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h
index d925ffd680c1..085f8ef8ae80 100644
--- a/lld/ELF/InputFiles.h
+++ b/lld/ELF/InputFiles.h
@@ -356,7 +356,7 @@ class BitcodeFile : public InputFile {
class SharedFile : public ELFFileBase {
public:
SharedFile(MemoryBufferRef m, StringRef defaultSoName)
- : ELFFileBase(SharedKind, m), soName(std::string(defaultSoName)),
+ : ELFFileBase(SharedKind, m), soName(defaultSoName),
isNeeded(!config->asNeeded) {}
// This is actually a vector of Elf_Verdef pointers.
@@ -370,7 +370,7 @@ class SharedFile : public ELFFileBase {
static unsigned vernauxNum;
std::vector<StringRef> dtNeeded;
- std::string soName;
+ StringRef soName;
static bool classof(const InputFile *f) { return f->kind() == SharedKind; }
More information about the llvm-commits
mailing list