[PATCH] D40849: CodeGen: support an extension to pass linker options on ELF

Saleem Abdulrasool via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 12 09:38:10 PST 2017


compnerd added a comment.

@ruiu I had the same concern and thats why I am doing one option per C-style string with an array that is null terminated to represent the options.  If there are options with spaces they will be a string onto themselves.  That is in the test itself (two options: "spaced option" and "nospace").

@jakehehrlich LLVM currently does 4-byte alignment and this code is following suit.  My reading of the gABI was that it was 4-byte on 32-bit, 8-byte on 64-bit.  Personally, I think that we should pass all options through and let the linker decide which option(s) it permits and rejects.  There are options that I would prefer that the linker flat out reject (e.g. `-nopie`).  This allows us to remain agnostic to the various different linkers and allows someone to implement extensions in a fairly easy manner.  For end users, I was thinking more the `#pragma comment(linker, "...")` approach (again, in line with option 2).  I think that source code annotations would be better and more obvious that they are adding this.  In the short term, even having IR level support and lld support would mean that we could actually start using this for swift immediately :-).



================
Comment at: lib/CodeGen/TargetLoweringObjectFileImpl.cpp:119
+    Streamer.EmitIntValue(0, 1);
+  }
+
----------------
jhenderson wrote:
> For a valid note section, you also need to align the end of the desc field.
Oh, right, forgot about that, good catch!


================
Comment at: test/Feature/elf-linker-options.ll:1
+; RUN: llc -mtriple i686-unknown-linux-gnu -filetype asm -o - %s | FileCheck %s
+
----------------
jhenderson wrote:
> Could we have a 64-bit test-case, as well, please?
Yes, yes we should have one of those, I'll add one.


Repository:
  rL LLVM

https://reviews.llvm.org/D40849





More information about the llvm-commits mailing list