<div dir="ltr">We don't have an i386 bot, I suspect nobody does (or they've been ignoring the fact that these have been red).<div><br></div><div>Something like that sounds very useful. :)<div><br></div><div>- Lang.</div>
</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, May 22, 2014 at 3:48 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Thu, May 22, 2014 at 3:30 PM, Lang Hames <<a href="mailto:lhames@gmail.com">lhames@gmail.com</a>> wrote:<br>
> Author: lhames<br>
> Date: Thu May 22 17:30:13 2014<br>
> New Revision: 209478<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=209478&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=209478&view=rev</a><br>
> Log:<br>
> [RuntimeDyld] Teach RuntimeDyldMachO how to handle scattered VANILLA relocs on<br>
> i386.<br>
><br>
> This fixes two more MCJIT regression tests on i386:<br>
<br>
</div>Do we have a public bot running these tests? (why weren't they XFAIL'd<br>
until now?) Do you have one internally at least that's green (how is<br>
it green if these tests aren't XFAIL'd on i386?) so you'll know (&<br>
presumably tell the community) if these regress?<br>
<div class="HOEnZb"><div class="h5"><br>
><br>
> ExecutionEngine/MCJIT/2003-05-06-LivenessClobber.ll<br>
> ExecutionEngine/MCJIT/2013-04-04-RelocAddend.ll<br>
><br>
> The implementation of processScatteredVANILLA is tasteless (*ba-dum-ching*),<br>
> but I'm working on a substantial tidy-up of RuntimeDyldMachO that should<br>
> improve things.<br>
><br>
> This patch also fixes a type-o in RuntimeDyldMachO::processSECTDIFFRelocation,<br>
> and teaches that method to skip over the PAIR reloc following the SECTDIFF.<br>
><br>
> <rdar://problem/16961886><br>
><br>
><br>
> Modified:<br>
> llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp<br>
> llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h<br>
><br>
> Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp?rev=209478&r1=209477&r2=209478&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp?rev=209478&r1=209477&r2=209478&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp (original)<br>
> +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp Thu May 22 17:30:13 2014<br>
> @@ -460,7 +460,7 @@ relocation_iterator RuntimeDyldMachO::pr<br>
><br>
> uint32_t AddrB = MachO->getScatteredRelocationValue(RE2);<br>
> section_iterator SBI = getSectionByAddress(*MachO, AddrB);<br>
> - assert(SBI != MachO->section_end() && "Can't find seciton for address B");<br>
> + assert(SBI != MachO->section_end() && "Can't find section for address B");<br>
> uint64_t SectionBBase;<br>
> SBI->getAddress(SectionBBase);<br>
> uint64_t SectionBOffset = AddrB - SectionBBase;<br>
> @@ -483,7 +483,48 @@ relocation_iterator RuntimeDyldMachO::pr<br>
> addRelocationForSection(R, SectionAID);<br>
> addRelocationForSection(R, SectionBID);<br>
><br>
> - return RelI;<br>
> + return ++RelI;<br>
> +}<br>
> +<br>
> +relocation_iterator RuntimeDyldMachO::processI386ScatteredVANILLA(<br>
> + unsigned SectionID,<br>
> + relocation_iterator RelI,<br>
> + ObjectImage &Obj,<br>
> + ObjSectionToIDMap &ObjSectionToID) {<br>
> + const MachOObjectFile *MachO =<br>
> + static_cast<const MachOObjectFile*>(Obj.getObjectFile());<br>
> + MachO::any_relocation_info RE =<br>
> + MachO->getRelocation(RelI->getRawDataRefImpl());<br>
> +<br>
> + SectionEntry &Section = Sections[SectionID];<br>
> + uint32_t RelocType = MachO->getAnyRelocationType(RE);<br>
> + bool IsPCRel = MachO->getAnyRelocationPCRel(RE);<br>
> + unsigned Size = MachO->getAnyRelocationLength(RE);<br>
> + uint64_t Offset;<br>
> + RelI->getOffset(Offset);<br>
> + uint8_t *LocalAddress = Section.Address + Offset;<br>
> + unsigned NumBytes = 1 << Size;<br>
> + int64_t Addend = 0;<br>
> + memcpy(&Addend, LocalAddress, NumBytes);<br>
> +<br>
> + unsigned SymbolBaseAddr = MachO->getScatteredRelocationValue(RE);<br>
> + section_iterator TargetSI = getSectionByAddress(*MachO, SymbolBaseAddr);<br>
> + assert(TargetSI != MachO->section_end() && "Can't find section for symbol");<br>
> + uint64_t SectionBaseAddr;<br>
> + TargetSI->getAddress(SectionBaseAddr);<br>
> + SectionRef TargetSection = *TargetSI;<br>
> + bool IsCode;<br>
> + TargetSection.isText(IsCode);<br>
> + uint32_t TargetSectionID = findOrEmitSection(Obj, TargetSection, IsCode,<br>
> + ObjSectionToID);<br>
> +<br>
> + Addend -= SectionBaseAddr;<br>
> + RelocationEntry R(SectionID, Offset, RelocType, Addend,<br>
> + IsPCRel, Size);<br>
> +<br>
> + addRelocationForSection(R, TargetSectionID);<br>
> +<br>
> + return ++RelI;<br>
> }<br>
><br>
> relocation_iterator RuntimeDyldMachO::processRelocationRef(<br>
> @@ -498,17 +539,22 @@ relocation_iterator RuntimeDyldMachO::pr<br>
> uint32_t RelType = MachO->getAnyRelocationType(RE);<br>
><br>
> // FIXME: Properly handle scattered relocations.<br>
> - // For now, optimistically skip these: they can often be ignored, as<br>
> - // the static linker will already have applied the relocation, and it<br>
> - // only needs to be reapplied if symbols move relative to one another.<br>
> - // Note: This will fail horribly where the relocations *do* need to be<br>
> - // applied, but that was already the case.<br>
> + // Special case the couple of scattered relocations that we know how<br>
> + // to handle: SECTDIFF relocations, and scattered VANILLA relocations<br>
> + // on I386.<br>
> + // For all other scattered relocations, just bail out and hope for the<br>
> + // best, since the offsets computed by scattered relocations have often<br>
> + // been optimisticaly filled in by the compiler. This will fail<br>
> + // horribly where the relocations *do* need to be applied, but that was<br>
> + // already the case.<br>
> if (MachO->isRelocationScattered(RE)) {<br>
> if (RelType == MachO::GENERIC_RELOC_SECTDIFF ||<br>
> RelType == MachO::GENERIC_RELOC_LOCAL_SECTDIFF)<br>
> return processSECTDIFFRelocation(SectionID, RelI, Obj, ObjSectionToID);<br>
> -<br>
> - return ++RelI;<br>
> + else if (Arch == Triple::x86 && RelType == MachO::GENERIC_RELOC_VANILLA)<br>
> + return processI386ScatteredVANILLA(SectionID, RelI, Obj, ObjSectionToID);<br>
> + else<br>
> + return ++RelI;<br>
> }<br>
><br>
> RelocationValueRef Value;<br>
><br>
> Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h?rev=209478&r1=209477&r2=209478&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h?rev=209478&r1=209477&r2=209478&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h (original)<br>
> +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.h Thu May 22 17:30:13 2014<br>
> @@ -71,6 +71,12 @@ private:<br>
> ObjectImage &ObjImg,<br>
> ObjSectionToIDMap &ObjSectionToID);<br>
><br>
> + relocation_iterator processI386ScatteredVANILLA(<br>
> + unsigned SectionID,<br>
> + relocation_iterator RelI,<br>
> + ObjectImage &ObjImg,<br>
> + ObjSectionToIDMap &ObjSectionToID);<br>
> +<br>
> struct EHFrameRelatedSections {<br>
> EHFrameRelatedSections()<br>
> : EHFrameSID(RTDYLD_INVALID_SECTION_ID),<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>
</div></div></blockquote></div><br></div>