Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ld crashes on non-symbolic relocation for cstring entry (r225048 breaks ObjC on AArch64). #22474

Closed
lhames opened this issue Jan 6, 2015 · 4 comments
Labels
bugzilla Issues migrated from bugzilla mc Machine (object) code

Comments

@lhames
Copy link
Contributor

lhames commented Jan 6, 2015

Bugzilla Link 22100
Resolution FIXED
Resolved on Jan 12, 2015 12:19
Version trunk
OS MacOS X
Attachments Reduced test case.

Extended Description

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::targetCString(mach_o::relocatable::Atom const*, ld::IndirectBindingTable const&) const + 297
2 0x10ca78dcc mach_o::relocatable::PointerToCStringSection::contentHash(mach_o::relocatable::Atom const*, ld::IndirectBindingTable const&) const + 58
3 0x10ca75f6e mach_o::relocatable::Atom::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> > >::find<ld::Atom const*>(ld::Atom const* const&) + 36
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::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.

@lhames
Copy link
Contributor Author

lhames commented Jan 6, 2015

Reverted in r225228.

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 6, 2015

definitely need labels on cstrings. Otherwise link-time string merging can and does go badly.

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 6, 2015

Reduces to just

.section	__TEXT,__cstring

Lfoo:
.asciz "Hello World!"
Lbar:
.asciz "cString"

.section	__foo,__bar,literal_pointers
.quad	Lbar

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 12, 2015

Making as fixed by r225644.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 9, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla mc Machine (object) code
Projects
None yet
Development

No branches or pull requests

2 participants