llvm.org GIT mirror llvm / 6d49b68
[MC/Mach-O] Implement integrated assembler support for linker options. - Also, fixup syntax errors in LangRef and missing newline in the MCAsmStreamer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172837 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Dunbar 7 years ago
4 changed file(s) with 65 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
26272627 linker options, presumably to link against ``libz`` and the ``Cocoa``
26282628 framework::
26292629
2630 !0 = metadata !{ i32 6, "Linker Options",
2630 !0 = metadata !{ i32 6, metadata !"Linker Options",
26312631 metadata !{
2632 !metadata { metadata !"-lz" },
2633 !metadata { metadata !"-framework", metadata !"Cocoa" } } }
2632 metadata !{ metadata !"-lz" },
2633 metadata !{ metadata !"-framework", metadata !"Cocoa" } } }
26342634 !llvm.module.flags = !{ !0 }
26352635
26362636 The metadata encoding as lists of lists of options, as opposed to a collapsed
405405 // MachO
406406 //===----------------------------------------------------------------------===//
407407
408 /// emitModuleFlags - Emit the module flags that specify the garbage collection
409 /// information.
408 /// emitModuleFlags - Perform code emission for module flags.
410409 void TargetLoweringObjectFileMachO::
411410 emitModuleFlags(MCStreamer &Streamer,
412411 ArrayRef ModuleFlags,
413412 Mangler *Mang, const TargetMachine &TM) const {
414413 unsigned VersionVal = 0;
415414 unsigned ImageInfoFlags = 0;
415 MDNode *LinkerOptions = 0;
416416 StringRef SectionVal;
417417
418418 for (ArrayRef::iterator
426426 StringRef Key = MFE.Key->getString();
427427 Value *Val = MFE.Val;
428428
429 if (Key == "Objective-C Image Info Version")
429 if (Key == "Objective-C Image Info Version") {
430430 VersionVal = cast(Val)->getZExtValue();
431 else if (Key == "Objective-C Garbage Collection" ||
432 Key == "Objective-C GC Only" ||
433 Key == "Objective-C Is Simulated")
431 } else if (Key == "Objective-C Garbage Collection" ||
432 Key == "Objective-C GC Only" ||
433 Key == "Objective-C Is Simulated") {
434434 ImageInfoFlags |= cast(Val)->getZExtValue();
435 else if (Key == "Objective-C Image Info Section")
435 } else if (Key == "Objective-C Image Info Section") {
436436 SectionVal = cast(Val)->getString();
437 } else if (Key == "Linker Options") {
438 LinkerOptions = cast(Val);
439 }
440 }
441
442 // Emit the linker options if present.
443 if (LinkerOptions) {
444 for (unsigned i = 0, e = LinkerOptions->getNumOperands(); i != e; ++i) {
445 MDNode *MDOptions = cast(LinkerOptions->getOperand(i));
446 SmallVector StrOptions;
447
448 // Convert to strings.
449 for (unsigned ii = 0, ie = MDOptions->getNumOperands(); ii != ie; ++ii) {
450 MDString *MDOption = cast(MDOptions->getOperand(ii));
451 StrOptions.push_back(MDOption->getString());
452 }
453
454 Streamer.EmitLinkerOptions(StrOptions);
455 }
437456 }
438457
439458 // The section is mandatory. If we don't have it, then we don't have GC info.
382382 ie = Options.end(); it != ie; ++it) {
383383 OS << ", " << '"' << *it << '"';
384384 }
385 OS << "\n";
385386 }
386387
387388 void MCAsmStreamer::EmitDataRegion(MCDataRegionType Kind) {
0 ; RUN: llc -O0 -mtriple=x86_64-apple-darwin -o - %s > %t
1 ; RUN: FileCheck --check-prefix=CHECK-ASM < %t %s
2
3 ; CHECK-ASM: .linker_option "-lz"
4 ; CHECK-ASM-NEXT: .linker_option "-framework", "Cocoa"
5
6 ; RUN: llc -O0 -mtriple=x86_64-apple-darwin -filetype=obj -o - %s | macho-dump > %t
7 ; RUN: FileCheck --check-prefix=CHECK-OBJ < %t %s
8
9 ; CHECK-OBJ: ('load_commands', [
10 ; CHECK-OBJ: # Load Command 1
11 ; CHECK-OBJ: (('command', 45)
12 ; CHECK-OBJ: ('size', 16)
13 ; CHECK-OBJ: ('count', 1)
14 ; CHECK-OBJ: ('_strings', [
15 ; CHECK-OBJ: "-lz",
16 ; CHECK-OBJ: ])
17 ; CHECK-OBJ: ),
18 ; CHECK-OBJ: # Load Command 2
19 ; CHECK-OBJ: (('command', 45)
20 ; CHECK-OBJ: ('size', 32)
21 ; CHECK-OBJ: ('count', 2)
22 ; CHECK-OBJ: ('_strings', [
23 ; CHECK-OBJ: "-framework",
24 ; CHECK-OBJ: "Cocoa",
25 ; CHECK-OBJ: ])
26 ; CHECK-OBJ: ),
27 ; CHECK-OBJ: ])
28
29 !0 = metadata !{ i32 6, metadata !"Linker Options",
30 metadata !{
31 metadata !{ metadata !"-lz" },
32 metadata !{ metadata !"-framework", metadata !"Cocoa" } } }
33
34 !llvm.module.flags = !{ !0 }