[llvm] r323783 - CodeGen: support an extension to pass linker options on ELF

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 30 23:34:38 PST 2018


Saleem Abdulrasool via llvm-commits <llvm-commits at lists.llvm.org>
writes:
> Author: compnerd
> Date: Tue Jan 30 08:29:29 2018
> New Revision: 323783
>
> URL: http://llvm.org/viewvc/llvm-project?rev=323783&view=rev
> Log:
> CodeGen: support an extension to pass linker options on ELF
>
> Introduce an extension to support passing linker options to the linker.
> These would be ignored by older linkers, but newer linkers which support
> this feature would be able to process the linker.
>
> Emit a special discarded section `.linker-option`.  The content of this
> section is a pair of strings (key, value).  The key is a type identifier for
> the parameter.  This allows for an argument free parameter that will be
> processed by the linker with the value being the parameter.  As an example,
> `lib` identifies a library to be linked against, traditionally the `-l`
> argument for Unix-based linkers with the parameter being the library name.
>
> Thanks to James Henderson, Cary Coutant, Rafael Espinolda, Sean Silva
> for the valuable discussion on the design of this feature.
 ...
> Added: llvm/trunk/test/Feature/elf-linker-options.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Feature/elf-linker-options.ll?rev=323783&view=auto
> ==============================================================================
> --- llvm/trunk/test/Feature/elf-linker-options.ll (added)
> +++ llvm/trunk/test/Feature/elf-linker-options.ll Tue Jan 30 08:29:29 2018
> @@ -0,0 +1,16 @@
> +; RUN: llc -mtriple x86_64-elf -filetype asm -o - %s | FileCheck %s
> +
> +!llvm.linker.options = !{!0, !1}
> +
> +!0 = !{!"option 0", !"value 0"}
> +!1 = !{!"option 1", !"value 1"}
> +
> +; CHECK: .section ".linker-options","e", at llvm_linker_options
> +; CHECK-NEXT: .ascii  "option 0"
> +; CHECK-NEXT: .byte   0
> +; CHECK-NEXT: .ascii  "value 0"
> +; CHECK-NEXT: .byte   0
> +; CHECK-NEXT: .ascii  "option 1"
> +; CHECK-NEXT: .byte   0
> +; CHECK-NEXT: .ascii  "value 1"
> +; CHECK-NEXT: .byte   0
>
> Added: llvm/trunk/test/tools/llvm-readobj/elf-linker-options.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-readobj/elf-linker-options.ll?rev=323783&view=auto
> ==============================================================================
> --- llvm/trunk/test/tools/llvm-readobj/elf-linker-options.ll (added)
> +++ llvm/trunk/test/tools/llvm-readobj/elf-linker-options.ll Tue Jan 30 08:29:29 2018
> @@ -0,0 +1,11 @@
> +; RUN: llc -mtriple x86_64-elf -filetype obj -o - %s | llvm-readobj -elf-linker-options - | FileCheck %s
> +
> +!llvm.linker.options = !{!0, !1}
> +
> +!0 = !{!"option 0", !"value 0"}
> +!1 = !{!"option 1", !"value 1"}
> +
> +; CHECK: LinkerOptions [
> +; CHECK:  option 0: value 0
> +; CHECK:  option 1: value 1
> +; CHECK: ]
>

These two tests both use an x86 triple, so they fail if no x86 backend
is built. I've marked them "REQUIRES: x86-registered-target" in r323847
to unbreak bots, but if the triple isn't needed it might make more sense
to remove it and mark these "REQUIRES: default_triple" instead.


More information about the llvm-commits mailing list