Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lld/test/wasm/Inputs/start-lib1.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ foo:
.functype foo () -> ()
call bar
end_function

# Static constructor inserted here to ensure the object file is not
# being processed as "live". Live object files have their static constructors
# preserved even if no symbol within is used.
.section .init_array,"",@
.p2align 2
.int32 foo
4 changes: 0 additions & 4 deletions lld/wasm/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,6 @@ void LinkerDriver::addFile(StringRef path) {
if (inWholeArchive) {
for (const auto &[m, offset] : members) {
auto *object = createObjectFile(m, path, offset);
// Mark object as live; object members are normally not
// live by default but -whole-archive is designed to treat
// them as such.
object->markLive();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was unnecessary because the forth argument to createObjectFile (lazy) defaults to false which then calls markLive.

files.push_back(object);
}

Expand Down
6 changes: 4 additions & 2 deletions lld/wasm/InputFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,10 @@ ObjFile::ObjFile(MemoryBufferRef m, StringRef archiveName, bool lazy)
// https://github.com/llvm/llvm-project/issues/98778
checkArch(wasmObj->getArch());

// If this isn't part of an archive, it's eagerly linked, so mark it live.
if (archiveName.empty())
// Unless we are processing this as a lazy object file (e.g. part of an
// archive file or within `--start-lib`/`--end-lib`, it's eagerly linked, so
// mark it live.
if (!lazy)
markLive();
}

Expand Down