[lld] r213592 - [mach-o] Add test case for armv6 (arm not thumb) hello world

Nick Kledzik kledzik at apple.com
Mon Jul 21 17:49:49 PDT 2014


Author: kledzik
Date: Mon Jul 21 19:49:49 2014
New Revision: 213592

URL: http://llvm.org/viewvc/llvm-project?rev=213592&view=rev
Log:
[mach-o] Add test case for armv6 (arm not thumb) hello world

Added:
    lld/trunk/test/mach-o/hello-world-armv6.yaml
Modified:
    lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp
    lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp

Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp?rev=213592&r1=213591&r2=213592&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp Mon Jul 21 19:49:49 2014
@@ -185,8 +185,8 @@ const ArchHandler::StubInfo ArchHandler_
     0x00, 0xF0, 0x9C, 0xE5,       // ldr	pc, [ip]
     0x00, 0x00, 0x00, 0x00,       // L1: .long fFastStubGOTAtom - (helper+16)
     0x00, 0x00, 0x00, 0x00 },     // L2: .long dyld_stub_binder - (helper+28)
-  { Reference::KindArch::ARM, delta32, 28, 0 },
-  { Reference::KindArch::ARM, delta32, 32, 0 }
+  { Reference::KindArch::ARM, delta32, 28, 0xC },
+  { Reference::KindArch::ARM, delta32, 32, 0x04 }
 };
 
 const ArchHandler::StubInfo &ArchHandler_arm::stubInfo() {
@@ -548,7 +548,7 @@ ArchHandler_arm::getPairReferenceInfo(co
                                            "subtrahend label is not in atom"));
     *kind = delta32;
     value = clearThumbBit(instruction, *target);
-    *addend = value - (toAddress - fromAddress);
+    *addend = (int32_t)(value - (toAddress - fixupAddress));
   } else if (funcRel) {
     toAddress = reloc1.value;
     fromAddress = reloc2.value;
@@ -618,7 +618,6 @@ void ArchHandler_arm::applyFixupFinal(co
   assert(ref.kindArch() == Reference::KindArch::ARM);
   int32_t *loc32 = reinterpret_cast<int32_t *>(location);
   int32_t displacement;
-  // FIXME: these writes may need a swap.
   switch (ref.kindValue()) {
   case thumb_b22:
     // FIXME
@@ -652,10 +651,10 @@ void ArchHandler_arm::applyFixupFinal(co
     // FIXME
     break;
   case pointer32:
-    // FIXME
+    write32(*loc32, _swap, targetAddress + ref.addend());
     break;
   case delta32:
-    // FIXME
+    write32(*loc32, _swap, targetAddress - fixupAddress + ref.addend());
     break;
   case lazyPointer:
   case lazyImmediateLocation:

Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp?rev=213592&r1=213591&r2=213592&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp Mon Jul 21 19:49:49 2014
@@ -951,7 +951,12 @@ void Util::addRebaseAndBindingInfo(const
 }
 
 uint32_t Util::fileFlags() {
-  return 0;  //FIX ME
+  // FIXME: these need to determined at runtime.
+  if (_context.outputMachOType() == MH_OBJECT) {
+    return MH_SUBSECTIONS_VIA_SYMBOLS;
+  } else {
+    return MH_DYLDLINK | MH_NOUNDEFS | MH_TWOLEVEL;
+  }
 }
 
 } // end anonymous namespace

Added: lld/trunk/test/mach-o/hello-world-armv6.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/mach-o/hello-world-armv6.yaml?rev=213592&view=auto
==============================================================================
--- lld/trunk/test/mach-o/hello-world-armv6.yaml (added)
+++ lld/trunk/test/mach-o/hello-world-armv6.yaml Mon Jul 21 19:49:49 2014
@@ -0,0 +1,90 @@
+# RUN: lld -flavor darwin -arch armv6 -ios_version_min 7.0 %s -o %t  && \
+# RUN: llvm-nm %t | FileCheck %s
+#
+# Test that armv6 (arm) hello-world can be linked into a mach-o executable
+#
+
+--- !mach-o
+arch:            armv6
+file-type:       MH_OBJECT
+flags:           [ MH_SUBSECTIONS_VIA_SYMBOLS ]
+has-UUID:        false
+OS:              unknown
+sections:
+  - segment:         __TEXT
+    section:         __text
+    type:            S_REGULAR
+    attributes:      [ S_ATTR_PURE_INSTRUCTIONS, S_ATTR_SOME_INSTRUCTIONS ]
+    alignment:       2
+    address:         0x0000000000000000
+    content:         [ 0x80, 0x40, 0x2D, 0xE9, 0x10, 0x00, 0x9F, 0xE5,
+                       0x0D, 0x70, 0xA0, 0xE1, 0x00, 0x00, 0x8F, 0xE0,
+                       0xFA, 0xFF, 0xFF, 0xEB, 0x00, 0x00, 0xA0, 0xE3,
+                       0x80, 0x80, 0xBD, 0xE8, 0x0C, 0x00, 0x00, 0x00 ]
+    relocations:
+      - offset:          0x0000001C
+        scattered:       true
+        type:            ARM_RELOC_SECTDIFF
+        length:          2
+        pc-rel:          false
+        value:           0x00000020
+      - offset:          0x00000000
+        scattered:       true
+        type:            ARM_RELOC_PAIR
+        length:          2
+        pc-rel:          false
+        value:           0x0000000C
+      - offset:          0x00000010
+        type:            ARM_RELOC_BR24
+        length:          2
+        pc-rel:          true
+        extern:          true
+        symbol:          1
+  - segment:         __TEXT
+    section:         __cstring
+    type:            S_CSTRING_LITERALS
+    attributes:      [  ]
+    address:         0x0000000000000020
+    content:         [ 0x68, 0x65, 0x6C, 0x6C, 0x6F, 0x0A, 0x00 ]
+global-symbols:
+  - name:            _main
+    type:            N_SECT
+    scope:           [ N_EXT ]
+    sect:            1
+    value:           0x0000000000000000
+undefined-symbols:
+  - name:            _printf
+    type:            N_UNDF
+    scope:           [ N_EXT ]
+    value:           0x0000000000000000
+
+--- !mach-o
+arch:            armv6
+file-type:       MH_DYLIB
+flags:           [ ]
+install-name:    /usr/lib/libSystem.B.dylib
+sections:
+  - segment:         __TEXT
+    section:         __text
+    type:            S_REGULAR
+    attributes:      [ S_ATTR_PURE_INSTRUCTIONS, S_ATTR_SOME_INSTRUCTIONS ]
+    address:         0x0000000000000000
+    content:         [ 0x55 ]
+
+global-symbols:
+  - name:            _printf
+    type:            N_SECT
+    scope:           [ N_EXT ]
+    sect:            1
+    value:           0x0000000000000001
+  - name:            dyld_stub_binder
+    type:            N_SECT
+    scope:           [ N_EXT ]
+    sect:            1
+    value:           0x0000000000000001
+
+...
+
+# CHECK:	{{[0-9a-f]+}} T _main
+# CHECK:	U _printf
+# CHECK:	U dyld_stub_binder





More information about the llvm-commits mailing list