<div dir="ltr">This change does seem to contain functionality changes.<div><br></div><div>In order to fix the buildbot breakage, the change to MachO/CompactUnwindPass.cpp should suffice.</div><div><br></div><div>You just mixed two changes?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 15, 2014 at 1:26 PM, Tim Northover <span dir="ltr"><<a href="mailto:tnorthover@apple.com" target="_blank">tnorthover@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: tnorthover<br>
Date: Wed Oct 15 15:26:24 2014<br>
New Revision: 219843<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=219843&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=219843&view=rev</a><br>
Log:<br>
[mach-o] avoid overly clever std::find_if<br>
<br>
The bots were complaining (possibly because of a lack of traits on the iterator<br>
I was trying to use). No functional change.<br>
<br>
Modified:<br>
lld/trunk/lib/ReaderWriter/MachO/ArchHandler.h<br>
lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp<br>
lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp<br>
lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp<br>
lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp<br>
lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp<br>
lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp<br>
lld/trunk/test/mach-o/parse-eh-frame-x86-anon.yaml<br>
lld/trunk/test/mach-o/parse-eh-frame.yaml<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler.h?rev=219843&r1=219842&r2=219843&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler.h?rev=219843&r1=219842&r2=219843&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/MachO/ArchHandler.h (original)<br>
+++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler.h Wed Oct 15 15:26:24 2014<br>
@@ -74,6 +74,9 @@ public:<br>
/// actually be used.<br>
virtual uint32_t dwarfCompactUnwindType() = 0;<br>
<br>
+ /// Reference from an __eh_frame FDE to the CIE it's based on.<br>
+ virtual Reference::KindValue unwindRefToCIEKind() = 0;<br>
+<br>
/// Reference from an __eh_frame FDE atom to the function it's<br>
/// describing. Usually pointer-sized and PC-relative, but differs in whether<br>
/// it needs to be in relocatable objects.<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp?rev=219843&r1=219842&r2=219843&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp?rev=219843&r1=219842&r2=219843&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp (original)<br>
+++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp Wed Oct 15 15:26:24 2014<br>
@@ -48,6 +48,10 @@ public:<br>
return invalid;<br>
}<br>
<br>
+ Reference::KindValue unwindRefToCIEKind() override {<br>
+ return invalid;<br>
+ }<br>
+<br>
Reference::KindValue unwindRefToFunctionKind() override {<br>
return invalid;<br>
}<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp?rev=219843&r1=219842&r2=219843&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp?rev=219843&r1=219842&r2=219843&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp (original)<br>
+++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp Wed Oct 15 15:26:24 2014<br>
@@ -91,6 +91,10 @@ public:<br>
return invalid;<br>
}<br>
<br>
+ Reference::KindValue unwindRefToCIEKind() override {<br>
+ return invalid;<br>
+ }<br>
+<br>
Reference::KindValue unwindRefToFunctionKind() override {<br>
return invalid;<br>
}<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp?rev=219843&r1=219842&r2=219843&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp?rev=219843&r1=219842&r2=219843&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp (original)<br>
+++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp Wed Oct 15 15:26:24 2014<br>
@@ -51,6 +51,10 @@ public:<br>
return invalid;<br>
}<br>
<br>
+ Reference::KindValue unwindRefToCIEKind() override {<br>
+ return negDelta32;<br>
+ }<br>
+<br>
Reference::KindValue unwindRefToFunctionKind() override{<br>
return delta32;<br>
}<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp?rev=219843&r1=219842&r2=219843&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp?rev=219843&r1=219842&r2=219843&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp (original)<br>
+++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp Wed Oct 15 15:26:24 2014<br>
@@ -84,6 +84,10 @@ public:<br>
return imageOffsetGot;<br>
}<br>
<br>
+ Reference::KindValue unwindRefToCIEKind() override {<br>
+ return negDelta32;<br>
+ }<br>
+<br>
Reference::KindValue unwindRefToFunctionKind() override{<br>
return unwindFDEToFunction;<br>
}<br>
@@ -167,7 +171,8 @@ private:<br>
delta32, /// ex: .long _foo - .<br>
delta64Anon, /// ex: .quad L1 - .<br>
delta32Anon, /// ex: .long L1 - .<br>
-<br>
+ negDelta32, /// ex: .long . - _foo<br>
+<br>
// Kinds introduced by Passes:<br>
ripRel32GotLoadNowLea, /// Target of GOT load is in linkage unit so<br>
/// "movq _foo@GOTPCREL(%rip), %rax" can be changed<br>
@@ -218,6 +223,7 @@ const Registry::KindStrings ArchHandler_<br>
LLD_KIND_STRING_ENTRY(pointer64), LLD_KIND_STRING_ENTRY(pointer64Anon),<br>
LLD_KIND_STRING_ENTRY(delta32), LLD_KIND_STRING_ENTRY(delta64),<br>
LLD_KIND_STRING_ENTRY(delta32Anon), LLD_KIND_STRING_ENTRY(delta64Anon),<br>
+ LLD_KIND_STRING_ENTRY(negDelta32),<br>
LLD_KIND_STRING_ENTRY(imageOffset), LLD_KIND_STRING_ENTRY(imageOffsetGot),<br>
LLD_KIND_STRING_ENTRY(unwindFDEToFunction),<br>
LLD_KIND_STRING_ENTRY(unwindInfoToEhFrame),<br>
@@ -507,6 +513,9 @@ void ArchHandler_x86_64::applyFixupFinal<br>
location[-2] = 0x8D;<br>
write32(*loc32, _swap, (targetAddress - (fixupAddress + 4)) + ref.addend());<br>
return;<br>
+ case negDelta32:<br>
+ write32(*loc32, _swap, fixupAddress - targetAddress + ref.addend());<br>
+ return;<br>
case lazyPointer:<br>
case lazyImmediateLocation:<br>
// do nothing<br>
@@ -574,6 +583,9 @@ void ArchHandler_x86_64::applyFixupReloc<br>
case delta64Anon:<br>
write64(*loc64, _swap, (targetAddress - fixupAddress) + ref.addend());<br>
return;<br>
+ case negDelta32:<br>
+ write32(*loc32, _swap, fixupAddress - targetAddress + ref.addend());<br>
+ return;<br>
case ripRel32GotLoadNowLea:<br>
llvm_unreachable("ripRel32GotLoadNowLea implies GOT pass was run");<br>
return;<br>
@@ -675,6 +687,7 @@ void ArchHandler_x86_64::appendSectionRe<br>
return;<br>
case unwindFDEToFunction:<br>
case unwindInfoToEhFrame:<br>
+ case negDelta32:<br>
return;<br>
case ripRel32GotLoadNowLea:<br>
llvm_unreachable("ripRel32GotLoadNowLea implies GOT pass was run");<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp?rev=219843&r1=219842&r2=219843&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp?rev=219843&r1=219842&r2=219843&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp (original)<br>
+++ lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp Wed Oct 15 15:26:24 2014<br>
@@ -415,17 +415,14 @@ private:<br>
ArchHandler::isDwarfCIE(_swap, ehFrameAtom))<br>
continue;<br>
<br>
- auto functionRef = std::find_if(ehFrameAtom->begin(), ehFrameAtom->end(),<br>
- [&](const Reference *ref) {<br>
- return ref->kindNamespace() == Reference::KindNamespace::mach_o &&<br>
- ref->kindArch() == _archHandler.kindArch() &&<br>
- ref->kindValue() == _archHandler.unwindRefToFunctionKind();<br>
- });<br>
-<br>
- if (functionRef != ehFrameAtom->end()) {<br>
- const Atom *functionAtom = functionRef->target();<br>
- dwarfFrames.insert(std::make_pair(functionAtom, ehFrameAtom));<br>
- }<br>
+ DefinedAtom::reference_iterator ref = ehFrameAtom->begin();<br>
+ for (; ref != ehFrameAtom->end(); ++ref)<br>
+ if (ref->kindNamespace() == Reference::KindNamespace::mach_o &&<br>
+ ref->kindArch() == _archHandler.kindArch() &&<br>
+ ref->kindValue() == _archHandler.unwindRefToFunctionKind()) {<br>
+ dwarfFrames.insert(std::make_pair(ref->target(), ehFrameAtom));<br>
+ break;<br>
+ }<br>
}<br>
}<br>
<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp?rev=219843&r1=219842&r2=219843&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp?rev=219843&r1=219842&r2=219843&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp (original)<br>
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp Wed Oct 15 15:26:24 2014<br>
@@ -660,15 +660,30 @@ std::error_code addEHFrameReferences(con<br>
<br>
const uint8_t *frameData = atom->rawContent().data();<br>
uint32_t size = read32(swap, *(uint32_t *)frameData);<br>
- uint64_t rangeFieldInFDE = size == 0xffffffffU<br>
- ? 2 * sizeof(uint32_t) + sizeof(uint64_t)<br>
- : 2 * sizeof(uint32_t);<br>
+ uint64_t cieFieldInFDE = size == 0xffffffffU<br>
+ ? sizeof(uint32_t) + sizeof(uint64_t)<br>
+ : sizeof(uint32_t);<br>
+<br>
+ // Linker needs to fixup a reference from the FDE to its parent CIE (a<br>
+ // 32-bit byte offset backwards in the __eh_frame section).<br>
+ uint32_t cieDelta = read32(swap, *(uint32_t *)(frameData + cieFieldInFDE));<br>
+ uint64_t cieAddress = ehFrameSection->address + offset + cieFieldInFDE;<br>
+ cieAddress -= cieDelta;<br>
+<br>
+ Reference::Addend addend;<br>
+ const Atom *cie =<br>
+ findAtomCoveringAddress(normalizedFile, file, cieAddress, &addend);<br>
+ atom->addReference(cieFieldInFDE, handler.unwindRefToCIEKind(), cie,<br>
+ addend, handler.kindArch());<br>
+<br>
+ // Linker needs to fixup reference from the FDE to the function it's<br>
+ // describing.<br>
+ uint64_t rangeFieldInFDE = cieFieldInFDE + sizeof(uint32_t);<br>
<br>
int64_t functionFromFDE = readSPtr(is64, swap, frameData + rangeFieldInFDE);<br>
uint64_t rangeStart = ehFrameSection->address + offset + rangeFieldInFDE;<br>
rangeStart += functionFromFDE;<br>
<br>
- Reference::Addend addend;<br>
const Atom *func =<br>
findAtomCoveringAddress(normalizedFile, file, rangeStart, &addend);<br>
atom->addReference(rangeFieldInFDE, handler.unwindRefToFunctionKind(), func,<br>
<br>
Modified: lld/trunk/test/mach-o/parse-eh-frame-x86-anon.yaml<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/mach-o/parse-eh-frame-x86-anon.yaml?rev=219843&r1=219842&r2=219843&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/test/mach-o/parse-eh-frame-x86-anon.yaml?rev=219843&r1=219842&r2=219843&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/test/mach-o/parse-eh-frame-x86-anon.yaml (original)<br>
+++ lld/trunk/test/mach-o/parse-eh-frame-x86-anon.yaml Wed Oct 15 15:26:24 2014<br>
@@ -105,24 +105,24 @@ undefined-symbols:<br>
...<br>
<br>
# CHECK: defined-atoms:<br>
-# FIXME: - ref-name: [[CIE:L[L0-9]+]]<br>
+# CHECK: - ref-name: [[CIE:L[L0-9]+]]<br>
# CHECK: type: unwind-cfi<br>
# CHECK: content:<br>
# CHECK: - type: unwind-cfi<br>
# CHECK: content:<br>
# CHECK: references:<br>
-# FIXME: - kind: negDelta32<br>
-# FIXME: offset: 4<br>
-# FIXME: target: [[CIE]]<br>
+# CHECK: - kind: negDelta32<br>
+# CHECK: offset: 4<br>
+# CHECK: target: [[CIE]]<br>
# CHECK: - kind: delta32<br>
# CHECK: offset: 8<br>
# CHECK: target: __Z3foov<br>
# CHECK: - type: unwind-cfi<br>
# CHECK: content:<br>
# CHECK: references:<br>
-# FIXME: - kind: negDelta32<br>
-# FIXME: offset: 4<br>
-# FIXME: target: [[CIE]]<br>
+# CHECK: - kind: negDelta32<br>
+# CHECK: offset: 4<br>
+# CHECK: target: [[CIE]]<br>
# CHECK: - kind: delta32<br>
# CHECK: offset: 8<br>
# CHECK: target: __Z3barv<br>
<br>
Modified: lld/trunk/test/mach-o/parse-eh-frame.yaml<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/mach-o/parse-eh-frame.yaml?rev=219843&r1=219842&r2=219843&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/test/mach-o/parse-eh-frame.yaml?rev=219843&r1=219842&r2=219843&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/test/mach-o/parse-eh-frame.yaml (original)<br>
+++ lld/trunk/test/mach-o/parse-eh-frame.yaml Wed Oct 15 15:26:24 2014<br>
@@ -51,7 +51,8 @@ global-symbols:<br>
...<br>
<br>
# CHECK: defined-atoms:<br>
-# CHECK: - type: unwind-cfi<br>
+# CHECK: - ref-name: [[CIE:L[0-9]+]]<br>
+# CHECK: type: unwind-cfi<br>
# CHECK: content: [ 14, 00, 00, 00, 00, 00, 00, 00, 01, 7A, 52, 00,<br>
# CHECK: 01, 78, 10, 01, 10, 0C, 07, 08, 90, 01, 00, 00 ]<br>
# CHECK: - type: unwind-cfi<br>
@@ -60,6 +61,9 @@ global-symbols:<br>
# CHECK: 00, 41, 0E, 10, 86, 02, 43, 0D, 06, 00, 00, 00,<br>
# CHECK: 00, 00, 00, 00 ]<br>
# CHECK: references:<br>
+# CHECK: - kind: negDelta32<br>
+# CHECK: offset: 4<br>
+# CHECK: target: [[CIE]]<br>
# CHECK: - kind: unwindFDEToFunction<br>
# CHECK: offset: 8<br>
# CHECK: target: __Z3barv<br>
@@ -69,6 +73,9 @@ global-symbols:<br>
# CHECK: 00, 41, 0E, 10, 86, 02, 43, 0D, 06, 00, 00, 00,<br>
# CHECK: 00, 00, 00, 00 ]<br>
# CHECK: references:<br>
+# CHECK: - kind: negDelta32<br>
+# CHECK: offset: 4<br>
+# CHECK: target: [[CIE]]<br>
# CHECK: - kind: unwindFDEToFunction<br>
# CHECK: offset: 8<br>
# CHECK: target: __Z3foov<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>