This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Remove {ELF,}GNULinkerScript InputElements.
ClosedPublic

Authored by ruiu on Dec 13 2014, 3:13 AM.

Details

Summary

Instead of representing a linker script file as an "InputElement",
parse and evaluate scripts in the driver as we see them.

Linker scripts are not regular input files (regular file is one of
object, archive, or shared library file). They are more like
extended command line options. Linker script handling was needlessly
complicated because of that inappropriate abstraction (besides
excessive class hierarchy -- there is no such thing like ELF linker
script but we had two classes there for some reason.)

LinkerScript was one of a few remaining InputElement subclasses
that can be expanded to multiple files. With this patch, we are one
step closer to retire InputElement.

Diff Detail

Event Timeline

ruiu updated this revision to Diff 17255.Dec 13 2014, 3:13 AM
ruiu retitled this revision from to [ELF] Remove {ELF,}GNULinkerScript InputElements..
ruiu updated this object.
ruiu edited the test plan for this revision. (Show Details)
ruiu added a project: lld.
ruiu added a subscriber: Unknown Object (MLST).

It's best for the linker script to be handled through the registry.

ruiu added a comment.Dec 14 2014, 6:39 AM

No it's not. We could have handled a linker script using the Registry, but
it wouldn't fit well because the Registry is a mechanism to convert a file
to a File object. We could have generalized the Registry to cover the
linker script, but this is exactly what we are trying to eliminate right
now (an excessive abstraction).

Another (obvious) counter example is response file. This should naturally
be handled by the Driver. What this example means is that being an external
file doesn't always mean that the file should be handled through the
Registry mechanism.

We are trying to duplicate getfilemagic in the driver which is actually part of the registry. The linker script should not be parsed in the driver immediately. The whole reason why the linker script is being parsed in the driver is we don't have a way to handle a script when the linker script is specified just like any other input file or library in the parser or registry. It should be parsed late whenever we figure out that the file is a linker script. We should parse more input files by using a lazy parsing method using file locator.

Bigcheese / Nick ?

shankarke accepted this revision.Dec 14 2014, 8:31 PM
shankarke edited edge metadata.
This revision is now accepted and ready to land.Dec 14 2014, 8:31 PM
atanasyan resigned from this revision.Feb 2 2016, 10:29 PM
atanasyan removed a reviewer: atanasyan.
Eugene.Zelenko added a subscriber: Eugene.Zelenko.

Committed in r225330.