Closed Quuxplusone closed 3 years ago
Bugzilla Link | PR35819 |
Status | RESOLVED WONTFIX |
Importance | P enhancement |
Reported by | Thomas Schaub (t.schaub@gmx.de) |
Reported on | 2018-01-04 03:32:50 -0800 |
Last modified on | 2021-02-19 16:03:38 -0800 |
Version | unspecified |
Hardware | Macintosh MacOS X |
CC | jezreel@gmail.com, llvm-bugs@lists.llvm.org |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | |
See also |
I just realized that the lld debug build runs into llvm_unreachable in lld::mach_o::ArchHandler_x86_64::applyFixupFinal.
Next insight: the reference passed to applyFixupFinal is created in
normalizedObjectToAtoms and its kindValue is set to handler-
>dataInCodeTransitionStart(*atom), which is not overridden in
ArchHandler_x86_64. In ArchHandler_x86, there's a modeData kind. Naively
copying this yields this patch:
% svn diff 11:06:52
Index: lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
===================================================================
--- lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp (revision 321863)
+++ lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp (working copy)
@@ -181,6 +181,20 @@
FindAddressForAtom addressForAtom,
normalized::Relocations &relocs) override;
+ bool isDataInCodeTransition(Reference::KindValue refKind) override {
+ return refKind == modeCode || refKind == modeData;
+ }
+
+ Reference::KindValue dataInCodeTransitionStart(
+ const MachODefinedAtom &atom) override
{
+ return modeData;
+ }
+
+ Reference::KindValue dataInCodeTransitionEnd(
+ const MachODefinedAtom &atom) override
{
+ return modeCode;
+ }
+
private:
static const Registry::KindStrings _sKindStrings[];
static const StubInfo _sStubInfo;
@@ -188,6 +202,9 @@
enum X86_64Kind: Reference::KindValue {
invalid, /// for error condition
+ modeCode, /// Content starting at this offset is code.
+ modeData, /// Content starting at this offset is data.
+
// Kinds found in mach-o .o files:
branch32, /// ex: call _foo
ripRel32, /// ex: movq _foo(%rip), %rax
@@ -242,7 +259,10 @@
};
const Registry::KindStrings ArchHandler_x86_64::_sKindStrings[] = {
- LLD_KIND_STRING_ENTRY(invalid), LLD_KIND_STRING_ENTRY(branch32),
+ LLD_KIND_STRING_ENTRY(invalid),
+ LLD_KIND_STRING_ENTRY(modeCode),
+ LLD_KIND_STRING_ENTRY(modeData),
+ LLD_KIND_STRING_ENTRY(branch32),
LLD_KIND_STRING_ENTRY(ripRel32), LLD_KIND_STRING_ENTRY(ripRel32Minus1),
LLD_KIND_STRING_ENTRY(ripRel32Minus2), LLD_KIND_STRING_ENTRY(ripRel32Minus4),
LLD_KIND_STRING_ENTRY(ripRel32Anon),
@@ -601,6 +621,8 @@
case negDelta32:
*loc32 = fixupAddress - targetAddress + ref.addend();
return;
+ case modeCode:
+ case modeData:
case lazyPointer:
// Do nothing
return;
@@ -711,6 +733,8 @@
case ripRel32GotLoadNowLea:
llvm_unreachable("ripRel32GotLoadNowLea implies GOT pass was run");
return;
+ case modeCode:
+ case modeData:
case lazyPointer:
case lazyImmediateLocation:
llvm_unreachable("lazy reference kind implies Stubs pass was run");
@@ -743,6 +767,9 @@
assert(ref.kindArch() == Reference::KindArch::x86_64);
uint32_t sectionOffset = atomSectionOffset + ref.offsetInAtom();
switch (static_cast<X86_64Kind>(ref.kindValue())) {
+ case modeCode:
+ case modeData:
+ break;
case branch32:
appendReloc(relocs, sectionOffset, symbolIndexForAtom(*ref.target()), 0,
X86_64_RELOC_BRANCH | rPcRel | rExtern | rLength4);
Closing this as it applies to the old iteration of LLD-MachO which is not being developed. (The new one is named ld64.lld.darwinnew
, and will be receiving active feature development and bug fixes.)