[llvm-dev] Linker Option support for ELF

Saleem Abdulrasool via llvm-dev llvm-dev at lists.llvm.org
Mon Jan 8 21:15:02 PST 2018



> On Jan 7, 2018, at 5:02 PM, Cary Coutant <ccoutant at gmail.com> wrote:
> 
>> I think we all agree that blindly allowing the linker to honor the options
>> would be scary.  I agree that we should whitelist the options, and am of the
>> opinion that we should force validation on the linker side (use of any
>> option which the linker doesn't support in this form can be fatal).
>> Starting small is the best way, with `-l` and `-L` as a starting point.  I
>> want to retain the ability to add additional options which may not be
>> available in all linkers.  However, whitelisting obviously requires working
>> with the linker as would adding such options, so that could be handled at
>> that time.
> 
> This is actually why I'd prefer a new "language" over just
> whitelisting options. With "lib", "file", and "path", as I suggested,
> there's no question whether an option like "-no-pie" is supported, and
> no temptation to even try. The new language should be tailored for
> process-to-process communication, rather than user-to-shell
> communication.

I suppose I am slightly confused about what you are proposing here now.  From the user side, it would be something to that effect.  Im suggesting that we take lib and transform it to a different representation in the frontend.  Taking an explicit example:

The user input
`#pragma comment(lib, “m”)`

would get transformed to `-lm` in the object file encoding.  However, this would still not permit you from injecting any arbitrary options, but the backend doesn’t change for any new option, only the frontend and the linker.

>> I’m thinking about future enhancements.  MachO does actually provide
>> something like `-L` -`l` in a single go via `-framework`.  But, no such
>> option exists for ELF since it doesn’t have the concept of framework bundles
>> (but the layout itself is interesting), and I just want to try to keep the
>> door open for such features.
> 
> This is why I also included "path" in my suggestion. I imagine
> something very much like -framework, where include files and library
> search paths are handled together.
> 
> -cary



More information about the llvm-dev mailing list