This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Add --{,no-}as-needed.
Needs RevisionPublic

Authored by ruiu on Jan 15 2015, 2:35 PM.

Details

Summary

The previous default behavior of LLD was --as-needed. LLD linked
against a DSO only if the DSO file was actually used to link an
executable (i.e. at least one symbol was resolved using the shared
library file.) What was missing was --no-as-needed support.

In this patch I added a boolean flag to FileNode for --as-needed.
I also added an accessor to DSO name to shared library file class.

Diff Detail

Event Timeline

ruiu updated this revision to Diff 18259.Jan 15 2015, 2:35 PM
ruiu retitled this revision from to [ELF] Add --{,no-}as-needed..
ruiu updated this object.
ruiu edited the test plan for this revision. (Show Details)
ruiu added reviewers: atanasyan, Bigcheese, shankarke.
ruiu added a project: lld.
ruiu added a subscriber: Unknown Object (MLST).
shankarke requested changes to this revision.Jan 15 2015, 3:49 PM
shankarke edited edge metadata.
shankarke added inline comments.
lib/ReaderWriter/ELF/OutputELFWriter.h
211

It looks like all the needed entries will not be in link order. The loop(just above your change) goes over the list of files that are really needed and add its to the needed list.

This revision now requires changes to proceed.Jan 15 2015, 3:49 PM
ruiu added inline comments.Jan 15 2015, 3:57 PM
lib/ReaderWriter/ELF/OutputELFWriter.h
211

That's true but that's not a new issue. llvm::StringSet doesn't preserve order, so even before this patch the order of DT_NEEDED entries were random. Let me address that issue in a separate patch.

atanasyan accepted this revision.Jan 15 2015, 9:26 PM
atanasyan edited edge metadata.

LGTM

emaste added a subscriber: emaste.Jan 18 2015, 5:50 PM
atanasyan resigned from this revision.Feb 3 2016, 12:30 AM
atanasyan removed a reviewer: atanasyan.