This is an archive of the discontinued LLVM Phabricator instance.

[mc-coff] Forward Linker Option flags into the .drectve section
ClosedPublic

Authored by rnk on Apr 24 2013, 1:45 PM.

Details

Summary

This is modelled on the Mach-O linker options implementation and should
support a Clang implementation of #pragma comment(lib/linker).

Diff Detail

Event Timeline

+
+ // Emit the linker options if present.
+ if (LinkerOptions) {

Please use an early return

if (!LinkerOptions)
return;

+ const MCSection *Sec = getDrectveSection();
+ Streamer.SwitchSection(Sec);
+ for (unsigned i = 0, e = LinkerOptions->getNumOperands(); i != e; ++i) {
+ MDNode *MDOptions = cast<MDNode>(LinkerOptions->getOperand(i));
+ for (unsigned ii = 0, ie = MDOptions->getNumOperands(); ii != ie; ++ii) {
+ MDString *MDOption = cast<MDString>(MDOptions->getOperand(ii));
+ Streamer.EmitBytes(" ");
+ Streamer.EmitBytes(MDOption->getString());

Is the format documented somewhere we could link to?

Index: test/MC/COFF/linker-options.ll

  • /dev/null

+++ test/MC/COFF/linker-options.ll
@@ -0,0 +1,28 @@
+; RUN: llc -O0 -mtriple=i386-pc-win32 -filetype=obj -o - %s | llvm-readobj -s -sd | FileCheck %s
+

Please test the output of the assembly file. No need to use -filetype=obj.

Cheers,
Rafael

rnk closed this revision.Apr 30 2013, 12:18 AM

Closed by commit rL180569 (authored by @rnk).