[PATCH] D13232: ELF2: Add basic linker script support.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 29 20:39:52 PDT 2015


On Tue, Sep 29, 2015 at 8:32 PM, Igor Kudrin <ikudrin.dev at gmail.com> wrote:

> ikudrin added a subscriber: ikudrin.
>
> ================
> Comment at: ELF/DriverUtils.cpp:202
> @@ +201,3 @@
> +// Returns true if Path seems to be a linker script.
> +bool isLinkerScript(llvm::StringRef Path) {
> +  // Because the linker script is just a text file that has no magic
> bytes,
> ----------------
> rafael wrote:
> > This opens a file, mmaps it, calls identify_magic and then drops
> everything and returns a bool :-(
> >
> > Could this be reorganized into something like
> >
> > addInptsForArg(StringRef Arg) {
> >   open file
> >   check type
> >    if (archiver or elf) {
> >       add it.
> >       return;
> >   }
> >   parse linker script.
> > }
> >
> > That way we only open, mmap and identify each file once.
> What if we remove intermediate containers like Inputs or InputFiles and
> just put all files into SymbolTable directly? Anyway, I'm going to suggest
> this change in my next patch for support --[no-]whole-archive.
>

The issue I had when I was writing this patch is ownership of MemoryBuffer.
Currently all files are owned by Driver, which opens files as it sees them
in the command line. All files are kept open until the linker exits, and we
are using MemoryBufferRef pointing these files everywhere.

Linker scripts changes the situation. They also see list of files we have
to use, and for simplicity we just open them while reading linker scripts.
Someone has to be the owner of these files.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150929/82bc6aaa/attachment.html>


More information about the llvm-commits mailing list