Skip to content

Commit

Permalink
[ELF] Change SharedFile::soName from std::string to StringRef
Browse files Browse the repository at this point in the history
  • Loading branch information
MaskRay committed Oct 25, 2021
1 parent 16e530d commit 4d9f6ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
15 changes: 5 additions & 10 deletions lld/ELF/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions lld/ELF/InputFiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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; }

Expand Down

0 comments on commit 4d9f6ca

Please sign in to comment.