<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - ld crashes on non-symbolic relocation for cstring entry (r225048 breaks ObjC on AArch64)."
   href="http://llvm.org/bugs/show_bug.cgi?id=22100">22100</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>ld crashes on non-symbolic relocation for cstring entry (r225048 breaks ObjC on AArch64).
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>MC
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>lhames@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=13634" name="attach_13634" title="Reduced test case.">attachment 13634</a> <a href="attachment.cgi?id=13634&action=edit" title="Reduced test case.">[details]</a></span>
Reduced test case.

r225048 broke ObjC on AArch64 - ld doesn't know how to handle relocations to
cstring entries without labels and crashes with an assertion:

0  0x10ca67571  __assert_rtn + 144
1  0x10ca79251 
mach_o::relocatable::PointerToCStringSection<arm64>::targetCString(mach_o::relocatable::Atom<arm64>
const*, ld::IndirectBindingTable const&) const + 297
2  0x10ca78dcc 
mach_o::relocatable::PointerToCStringSection<arm64>::contentHash(mach_o::relocatable::Atom<arm64>
const*, ld::IndirectBindingTable const&) const + 58
3  0x10ca75f6e 
mach_o::relocatable::Atom<arm64>::contentHash(ld::IndirectBindingTable const&)
const + 42
4  0x10caac11e 
std::__1::__hash_iterator<std::__1::__hash_node<std::__1::__hash_value_type<ld::Atom
const*, unsigned int>, void*>*>
std::__1::__hash_table<std::__1::__hash_value_type<ld::Atom const*, unsigned
int>, std::__1::__unordered_map_hasher<ld::Atom const*,
std::__1::__hash_value_type<ld::Atom const*, unsigned int>,
ld::tool::SymbolTable::ReferencesHashFuncs, true>,
std::__1::__unordered_map_equal<ld::Atom const*,
std::__1::__hash_value_type<ld::Atom const*, unsigned int>,
ld::tool::SymbolTable::ReferencesHashFuncs, true>,
std::__1::allocator<std::__1::__hash_value_type<ld::Atom const*, unsigned int>
<span class="quote">> >::find<ld::Atom const*>(ld::Atom const* const&) + 36</span >
5  0x10caab235  ld::tool::SymbolTable::findSlotForReferences(ld::Atom const*,
ld::Atom const**) + 117
6  0x10caab141  ld::tool::SymbolTable::addByReferences(ld::Atom const&) + 25
7  0x10caab31b  ld::tool::SymbolTable::add(ld::Atom const&, bool) + 61
8  0x10cab0371  ld::tool::Resolver::doAtom(ld::Atom const&) + 893
9  0x10ca7a92c 
mach_o::relocatable::File<arm64>::forEachAtom(ld::File::AtomHandler&) const +
54
10  0x10caa7b8f 
ld::tool::InputFiles::forEachInitialAtom(ld::File::AtomHandler&, ld::Internal&)
+ 471
11  0x10cab2a72  ld::tool::Resolver::resolve() + 48
12  0x10ca680e0  main + 682
ld: Assertion failed: (atom->fixupCount() == 1), function targetCString, file
src/ld/parsers/macho_relocatable_file.cpp, line 5707.

To reproduce run:

llvm-mc -arch arm64 -assemble -filetype=obj -o testcase.o testcase.s

ld -dynamic -arch arm64 -iphoneos_version_min 7.0.0 \
   -syslibroot
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.1.sdk
\
   -o testcase testcase.o

With r225048 applied you'll see the crash. With r225048 backed out you'll just
see: 'ld: dynamic main executables must link with libSystem.dylib for
architecture arm64'.

Unfortunately I think this means we can't keep r225048 for the time being:
There are too many linkers with this issue out in the wild. I'm going to revert
on trunk momentarily.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>