<div dir="ltr">Keno,<div><br></div><div>Either this or a previous commit has broken the asan build:</div><div><br></div><div><a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/1229">http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/1229</a><br></div><div><br></div><div><div>==17795==ERROR: AddressSanitizer: heap-use-after-free on address 0x621000009090 at pc 0x000002752b3e bp 0x7ffdc28a1be0 sp 0x7ffdc28a1bd8</div><div>READ of size 4 at 0x621000009090 thread T0</div><div> #0 0x2752b3d in getKeyLength /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/ADT/StringMap.h:45:42</div><div> #1 0x2752b3d in Destroy<llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096, 4096> > /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/ADT/StringMap.h:206</div><div> #2 0x2752b3d in ~StringMap /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/ADT/StringMap.h:439</div><div> #3 0x2752b3d in ~DwarfStringPool /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.h:28</div><div> #4 0x2752b3d in operator() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/libcxx_build_asan/include/c++/v1/memory:2398</div><div> #5 0x2752b3d in reset /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/libcxx_build_asan/include/c++/v1/memory:2604</div><div> #6 0x2752b3d in ~unique_ptr /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/libcxx_build_asan/include/c++/v1/memory:2572</div><div> #7 0x2752b3d in llvm::dwarfgen::Generator::~Generator() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/CodeGen/DwarfGenerator.cpp:114</div><div> #8 0x727d44 in operator() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/libcxx_build_asan/include/c++/v1/memory:2398:13</div><div> #9 0x727d44 in reset /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/libcxx_build_asan/include/c++/v1/memory:2604</div><div> #10 0x727d44 in ~unique_ptr /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/libcxx_build_asan/include/c++/v1/memory:2572</div><div> #11 0x727d44 in ~Expected /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/Support/Error.h:713</div><div> #12 0x727d44 in void (anonymous namespace)::TestReferences<(unsigned short)3, unsigned long>() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp:747</div><div> #13 0x34d0fec in HandleExceptionsInMethodIfSupported<testing::Test, void> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2145:12</div><div> #14 0x34d0fec in testing::Test::Run() /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/utils/unittest/googletest/src/gtest.cc:2161</div></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Dec 7, 2016 at 5:52 PM Keno Fischer via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: kfischer<br class="gmail_msg">
Date: Wed Dec 7 19:40:21 2016<br class="gmail_msg">
New Revision: 289013<br class="gmail_msg">
<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=289013&view=rev" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project?rev=289013&view=rev</a><br class="gmail_msg">
Log:<br class="gmail_msg">
[CodeGen] Fix invalid DWARF info on Win64<br class="gmail_msg">
<br class="gmail_msg">
The relocations for `DIEEntry::EmitValue` were wrong for Win64<br class="gmail_msg">
(emitting FK_Data_4 instead of FK_SecRel_4). This corrects that<br class="gmail_msg">
oversight so that the DWARF data is correct in Win64 COFF files.<br class="gmail_msg">
<br class="gmail_msg">
Fixes PR15393.<br class="gmail_msg">
<br class="gmail_msg">
Patch by Jameson Nash <<a href="mailto:jameson@juliacomputing.com" class="gmail_msg" target="_blank">jameson@juliacomputing.com</a>> based on a patch<br class="gmail_msg">
by David Majnemer.<br class="gmail_msg">
<br class="gmail_msg">
Differential Revision: <a href="https://reviews.llvm.org/D21731" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D21731</a><br class="gmail_msg">
<br class="gmail_msg">
Modified:<br class="gmail_msg">
llvm/trunk/docs/Extensions.rst<br class="gmail_msg">
llvm/trunk/include/llvm/MC/MCStreamer.h<br class="gmail_msg">
llvm/trunk/include/llvm/MC/MCWinCOFFStreamer.h<br class="gmail_msg">
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp<br class="gmail_msg">
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp<br class="gmail_msg">
llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp<br class="gmail_msg">
llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp<br class="gmail_msg">
llvm/trunk/lib/MC/MCAsmStreamer.cpp<br class="gmail_msg">
llvm/trunk/lib/MC/MCCodeView.cpp<br class="gmail_msg">
llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp<br class="gmail_msg">
llvm/trunk/lib/MC/MCStreamer.cpp<br class="gmail_msg">
llvm/trunk/lib/MC/WinCOFFStreamer.cpp<br class="gmail_msg">
llvm/trunk/test/DebugInfo/X86/ref_addr_relocation.ll<br class="gmail_msg">
<br class="gmail_msg">
Modified: llvm/trunk/docs/Extensions.rst<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/Extensions.rst?rev=289013&r1=289012&r2=289013&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/Extensions.rst?rev=289013&r1=289012&r2=289013&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/docs/Extensions.rst (original)<br class="gmail_msg">
+++ llvm/trunk/docs/Extensions.rst Wed Dec 7 19:40:21 2016<br class="gmail_msg">
@@ -67,7 +67,7 @@ the target. It corresponds to the COFF<br class="gmail_msg">
.long 4<br class="gmail_msg">
.long 242<br class="gmail_msg">
.long 40<br class="gmail_msg">
- .secrel32 _function_name<br class="gmail_msg">
+ .secrel32 _function_name + 0<br class="gmail_msg">
.secidx _function_name<br class="gmail_msg">
...<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
Modified: llvm/trunk/include/llvm/MC/MCStreamer.h<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=289013&r1=289012&r2=289013&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=289013&r1=289012&r2=289013&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/include/llvm/MC/MCStreamer.h (original)<br class="gmail_msg">
+++ llvm/trunk/include/llvm/MC/MCStreamer.h Wed Dec 7 19:40:21 2016<br class="gmail_msg">
@@ -471,7 +471,7 @@ public:<br class="gmail_msg">
/// \brief Emits a COFF section relative relocation.<br class="gmail_msg">
///<br class="gmail_msg">
/// \param Symbol - Symbol the section relative relocation should point to.<br class="gmail_msg">
- virtual void EmitCOFFSecRel32(MCSymbol const *Symbol);<br class="gmail_msg">
+ virtual void EmitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset);<br class="gmail_msg">
<br class="gmail_msg">
/// \brief Emit an ELF .size directive.<br class="gmail_msg">
///<br class="gmail_msg">
<br class="gmail_msg">
Modified: llvm/trunk/include/llvm/MC/MCWinCOFFStreamer.h<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCWinCOFFStreamer.h?rev=289013&r1=289012&r2=289013&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCWinCOFFStreamer.h?rev=289013&r1=289012&r2=289013&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/include/llvm/MC/MCWinCOFFStreamer.h (original)<br class="gmail_msg">
+++ llvm/trunk/include/llvm/MC/MCWinCOFFStreamer.h Wed Dec 7 19:40:21 2016<br class="gmail_msg">
@@ -52,7 +52,7 @@ public:<br class="gmail_msg">
void EndCOFFSymbolDef() override;<br class="gmail_msg">
void EmitCOFFSafeSEH(MCSymbol const *Symbol) override;<br class="gmail_msg">
void EmitCOFFSectionIndex(MCSymbol const *Symbol) override;<br class="gmail_msg">
- void EmitCOFFSecRel32(MCSymbol const *Symbol) override;<br class="gmail_msg">
+ void EmitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset) override;<br class="gmail_msg">
void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,<br class="gmail_msg">
unsigned ByteAlignment) override;<br class="gmail_msg">
void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,<br class="gmail_msg">
<br class="gmail_msg">
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=289013&r1=289012&r2=289013&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=289013&r1=289012&r2=289013&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)<br class="gmail_msg">
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Wed Dec 7 19:40:21 2016<br class="gmail_msg">
@@ -1688,7 +1688,7 @@ void AsmPrinter::EmitLabelPlusOffset(con<br class="gmail_msg">
unsigned Size,<br class="gmail_msg">
bool IsSectionRelative) const {<br class="gmail_msg">
if (MAI->needsDwarfSectionOffsetDirective() && IsSectionRelative) {<br class="gmail_msg">
- OutStreamer->EmitCOFFSecRel32(Label);<br class="gmail_msg">
+ OutStreamer->EmitCOFFSecRel32(Label, Offset);<br class="gmail_msg">
return;<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp?rev=289013&r1=289012&r2=289013&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp?rev=289013&r1=289012&r2=289013&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp (original)<br class="gmail_msg">
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp Wed Dec 7 19:40:21 2016<br class="gmail_msg">
@@ -149,7 +149,7 @@ void AsmPrinter::emitDwarfSymbolReferenc<br class="gmail_msg">
if (!ForceOffset) {<br class="gmail_msg">
// On COFF targets, we have to emit the special .secrel32 directive.<br class="gmail_msg">
if (MAI->needsDwarfSectionOffsetDirective()) {<br class="gmail_msg">
- OutStreamer->EmitCOFFSecRel32(Label);<br class="gmail_msg">
+ OutStreamer->EmitCOFFSecRel32(Label, /*Offset=*/0);<br class="gmail_msg">
return;<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=289013&r1=289012&r2=289013&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=289013&r1=289012&r2=289013&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp (original)<br class="gmail_msg">
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp Wed Dec 7 19:40:21 2016<br class="gmail_msg">
@@ -801,7 +801,7 @@ void CodeViewDebug::emitDebugInfoForFunc<br class="gmail_msg">
OS.AddComment("Function type index");<br class="gmail_msg">
OS.EmitIntValue(getFuncIdForSubprogram(GV->getSubprogram()).getIndex(), 4);<br class="gmail_msg">
OS.AddComment("Function section relative address");<br class="gmail_msg">
- OS.EmitCOFFSecRel32(Fn);<br class="gmail_msg">
+ OS.EmitCOFFSecRel32(Fn, /*Offset=*/0);<br class="gmail_msg">
OS.AddComment("Function section index");<br class="gmail_msg">
OS.EmitCOFFSectionIndex(Fn);<br class="gmail_msg">
OS.AddComment("Flags");<br class="gmail_msg">
@@ -2271,7 +2271,7 @@ void CodeViewDebug::emitDebugInfoForGlob<br class="gmail_msg">
OS.AddComment("Type");<br class="gmail_msg">
OS.EmitIntValue(getCompleteTypeIndex(DIGV->getType()).getIndex(), 4);<br class="gmail_msg">
OS.AddComment("DataOffset");<br class="gmail_msg">
- OS.EmitCOFFSecRel32(GVSym);<br class="gmail_msg">
+ OS.EmitCOFFSecRel32(GVSym, /*Offset=*/0);<br class="gmail_msg">
OS.AddComment("Segment");<br class="gmail_msg">
OS.EmitCOFFSectionIndex(GVSym);<br class="gmail_msg">
OS.AddComment("Name");<br class="gmail_msg">
<br class="gmail_msg">
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp?rev=289013&r1=289012&r2=289013&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp?rev=289013&r1=289012&r2=289013&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp (original)<br class="gmail_msg">
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp Wed Dec 7 19:40:21 2016<br class="gmail_msg">
@@ -642,7 +642,7 @@ void DIEEntry::EmitValue(const AsmPrinte<br class="gmail_msg">
MCSection *Section = Unit->getSection();<br class="gmail_msg">
if (Section) {<br class="gmail_msg">
const MCSymbol *SectionSym = Section->getBeginSymbol();<br class="gmail_msg">
- AP->EmitLabelPlusOffset(SectionSym, Addr, SizeOf(AP, Form));<br class="gmail_msg">
+ AP->EmitLabelPlusOffset(SectionSym, Addr, SizeOf(AP, Form), true);<br class="gmail_msg">
return;<br class="gmail_msg">
}<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=289013&r1=289012&r2=289013&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=289013&r1=289012&r2=289013&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original)<br class="gmail_msg">
+++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Wed Dec 7 19:40:21 2016<br class="gmail_msg">
@@ -150,7 +150,7 @@ public:<br class="gmail_msg">
void EndCOFFSymbolDef() override;<br class="gmail_msg">
void EmitCOFFSafeSEH(MCSymbol const *Symbol) override;<br class="gmail_msg">
void EmitCOFFSectionIndex(MCSymbol const *Symbol) override;<br class="gmail_msg">
- void EmitCOFFSecRel32(MCSymbol const *Symbol) override;<br class="gmail_msg">
+ void EmitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset) override;<br class="gmail_msg">
void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override;<br class="gmail_msg">
void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,<br class="gmail_msg">
unsigned ByteAlignment) override;<br class="gmail_msg">
@@ -614,9 +614,11 @@ void MCAsmStreamer::EmitCOFFSectionIndex<br class="gmail_msg">
EmitEOL();<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
-void MCAsmStreamer::EmitCOFFSecRel32(MCSymbol const *Symbol) {<br class="gmail_msg">
+void MCAsmStreamer::EmitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset) {<br class="gmail_msg">
OS << "\t.secrel32\t";<br class="gmail_msg">
Symbol->print(OS, MAI);<br class="gmail_msg">
+ if (Offset != 0)<br class="gmail_msg">
+ OS << '+' << Offset;<br class="gmail_msg">
EmitEOL();<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
Modified: llvm/trunk/lib/MC/MCCodeView.cpp<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCCodeView.cpp?rev=289013&r1=289012&r2=289013&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCCodeView.cpp?rev=289013&r1=289012&r2=289013&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/lib/MC/MCCodeView.cpp (original)<br class="gmail_msg">
+++ llvm/trunk/lib/MC/MCCodeView.cpp Wed Dec 7 19:40:21 2016<br class="gmail_msg">
@@ -200,7 +200,7 @@ void CodeViewContext::emitLineTableForFu<br class="gmail_msg">
OS.EmitIntValue(unsigned(ModuleSubstreamKind::Lines), 4);<br class="gmail_msg">
OS.emitAbsoluteSymbolDiff(LineEnd, LineBegin, 4);<br class="gmail_msg">
OS.EmitLabel(LineBegin);<br class="gmail_msg">
- OS.EmitCOFFSecRel32(FuncBegin);<br class="gmail_msg">
+ OS.EmitCOFFSecRel32(FuncBegin, /*Offset=*/0);<br class="gmail_msg">
OS.EmitCOFFSectionIndex(FuncBegin);<br class="gmail_msg">
<br class="gmail_msg">
// Actual line info.<br class="gmail_msg">
<br class="gmail_msg">
Modified: llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp?rev=289013&r1=289012&r2=289013&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp?rev=289013&r1=289012&r2=289013&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp (original)<br class="gmail_msg">
+++ llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp Wed Dec 7 19:40:21 2016<br class="gmail_msg">
@@ -455,13 +455,26 @@ bool COFFAsmParser::ParseDirectiveSecRel<br class="gmail_msg">
if (getParser().parseIdentifier(SymbolID))<br class="gmail_msg">
return TokError("expected identifier in directive");<br class="gmail_msg">
<br class="gmail_msg">
+ int64_t Offset = 0;<br class="gmail_msg">
+ SMLoc OffsetLoc;<br class="gmail_msg">
+ if (getLexer().is(AsmToken::Plus)) {<br class="gmail_msg">
+ OffsetLoc = getLexer().getLoc();<br class="gmail_msg">
+ if (getParser().parseAbsoluteExpression(Offset))<br class="gmail_msg">
+ return true;<br class="gmail_msg">
+ }<br class="gmail_msg">
+<br class="gmail_msg">
if (getLexer().isNot(AsmToken::EndOfStatement))<br class="gmail_msg">
return TokError("unexpected token in directive");<br class="gmail_msg">
<br class="gmail_msg">
+ if (Offset < 0 || Offset > UINT32_MAX)<br class="gmail_msg">
+ return Error(OffsetLoc,<br class="gmail_msg">
+ "invalid '.secrel32' directive offset, can't be less "<br class="gmail_msg">
+ "than zero or greater than UINT32_MAX");<br class="gmail_msg">
+<br class="gmail_msg">
MCSymbol *Symbol = getContext().getOrCreateSymbol(SymbolID);<br class="gmail_msg">
<br class="gmail_msg">
Lex();<br class="gmail_msg">
- getStreamer().EmitCOFFSecRel32(Symbol);<br class="gmail_msg">
+ getStreamer().EmitCOFFSecRel32(Symbol, Offset);<br class="gmail_msg">
return false;<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
Modified: llvm/trunk/lib/MC/MCStreamer.cpp<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=289013&r1=289012&r2=289013&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=289013&r1=289012&r2=289013&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/lib/MC/MCStreamer.cpp (original)<br class="gmail_msg">
+++ llvm/trunk/lib/MC/MCStreamer.cpp Wed Dec 7 19:40:21 2016<br class="gmail_msg">
@@ -125,7 +125,7 @@ void MCStreamer::EmitSymbolValue(const M<br class="gmail_msg">
if (!IsSectionRelative)<br class="gmail_msg">
EmitValueImpl(MCSymbolRefExpr::create(Sym, getContext()), Size);<br class="gmail_msg">
else<br class="gmail_msg">
- EmitCOFFSecRel32(Sym);<br class="gmail_msg">
+ EmitCOFFSecRel32(Sym, /*Offset=*/0);<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
void MCStreamer::EmitDTPRel64Value(const MCExpr *Value) {<br class="gmail_msg">
@@ -689,8 +689,7 @@ void MCStreamer::EmitCOFFSafeSEH(MCSymbo<br class="gmail_msg">
void MCStreamer::EmitCOFFSectionIndex(MCSymbol const *Symbol) {<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
-void MCStreamer::EmitCOFFSecRel32(MCSymbol const *Symbol) {<br class="gmail_msg">
-}<br class="gmail_msg">
+void MCStreamer::EmitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset) {}<br class="gmail_msg">
<br class="gmail_msg">
/// EmitRawText - If this file is backed by an assembly streamer, this dumps<br class="gmail_msg">
/// the specified string in the output .s file. This capability is<br class="gmail_msg">
<br class="gmail_msg">
Modified: llvm/trunk/lib/MC/WinCOFFStreamer.cpp<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFStreamer.cpp?rev=289013&r1=289012&r2=289013&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFStreamer.cpp?rev=289013&r1=289012&r2=289013&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/lib/MC/WinCOFFStreamer.cpp (original)<br class="gmail_msg">
+++ llvm/trunk/lib/MC/WinCOFFStreamer.cpp Wed Dec 7 19:40:21 2016<br class="gmail_msg">
@@ -195,11 +195,20 @@ void MCWinCOFFStreamer::EmitCOFFSectionI<br class="gmail_msg">
DF->getContents().resize(DF->getContents().size() + 2, 0);<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
-void MCWinCOFFStreamer::EmitCOFFSecRel32(MCSymbol const *Symbol) {<br class="gmail_msg">
+void MCWinCOFFStreamer::EmitCOFFSecRel32(MCSymbol const *Symbol,<br class="gmail_msg">
+ uint64_t Offset) {<br class="gmail_msg">
MCDataFragment *DF = getOrCreateDataFragment();<br class="gmail_msg">
- const MCSymbolRefExpr *SRE = MCSymbolRefExpr::create(Symbol, getContext());<br class="gmail_msg">
- MCFixup Fixup = MCFixup::create(DF->getContents().size(), SRE, FK_SecRel_4);<br class="gmail_msg">
+ // Create Symbol A for the relocation relative reference.<br class="gmail_msg">
+ const MCExpr *MCE = MCSymbolRefExpr::create(Symbol, getContext());<br class="gmail_msg">
+ // Add the constant offset, if given.<br class="gmail_msg">
+ if (Offset)<br class="gmail_msg">
+ MCE = MCBinaryExpr::createAdd(<br class="gmail_msg">
+ MCE, MCConstantExpr::create(Offset, getContext()), getContext());<br class="gmail_msg">
+ // Build the secrel32 relocation.<br class="gmail_msg">
+ MCFixup Fixup = MCFixup::create(DF->getContents().size(), MCE, FK_SecRel_4);<br class="gmail_msg">
+ // Record the relocation.<br class="gmail_msg">
DF->getFixups().push_back(Fixup);<br class="gmail_msg">
+ // Emit 4 bytes (zeros) to the object file.<br class="gmail_msg">
DF->getContents().resize(DF->getContents().size() + 4, 0);<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
Modified: llvm/trunk/test/DebugInfo/X86/ref_addr_relocation.ll<br class="gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/ref_addr_relocation.ll?rev=289013&r1=289012&r2=289013&view=diff" rel="noreferrer" class="gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/ref_addr_relocation.ll?rev=289013&r1=289012&r2=289013&view=diff</a><br class="gmail_msg">
==============================================================================<br class="gmail_msg">
--- llvm/trunk/test/DebugInfo/X86/ref_addr_relocation.ll (original)<br class="gmail_msg">
+++ llvm/trunk/test/DebugInfo/X86/ref_addr_relocation.ll Wed Dec 7 19:40:21 2016<br class="gmail_msg">
@@ -1,10 +1,22 @@<br class="gmail_msg">
-; RUN: llc -filetype=asm -O0 -mtriple=x86_64-linux-gnu < %s | FileCheck %s<br class="gmail_msg">
-; RUN: llc -filetype=obj -O0 %s -mtriple=x86_64-linux-gnu -o %t<br class="gmail_msg">
-; RUN: llvm-dwarfdump %t | FileCheck %s -check-prefix=CHECK-DWARF<br class="gmail_msg">
-<br class="gmail_msg">
-; RUN: llc -filetype=asm -O0 -mtriple=x86_64-apple-darwin < %s | FileCheck --check-prefix=DARWIN-ASM %s<br class="gmail_msg">
-; RUN: llc -filetype=obj %s -mtriple=x86_64-apple-darwin -o %t2<br class="gmail_msg">
-; RUN: llvm-dwarfdump %t2 | FileCheck %s -check-prefix=DARWIN-DWARF<br class="gmail_msg">
+; RUN: llc -filetype=asm -O0 -mtriple=x86_64-linux-gnu < %s -dwarf-version 2 | FileCheck -check-prefixes=CHECK,ELF-ASM %s<br class="gmail_msg">
+; RUN: llc -filetype=obj -O0 %s -mtriple=x86_64-linux-gnu -o %t-2 -dwarf-version 2<br class="gmail_msg">
+; RUN: llvm-dwarfdump %t-2 | FileCheck %s -check-prefix=CHECK-DWARF<br class="gmail_msg">
+; RUN: llc -filetype=obj -O0 %s -mtriple=x86_64-linux-gnu -o %t-4 -dwarf-version 2<br class="gmail_msg">
+; RUN: llvm-dwarfdump %t-4 | FileCheck %s -check-prefix=CHECK-DWARF<br class="gmail_msg">
+<br class="gmail_msg">
+; RUN: llc -filetype=asm -O0 -mtriple=x86_64-apple-darwin < %s -dwarf-version 2 | FileCheck -check-prefixes=CHECK,DARWIN-ASM2 %s<br class="gmail_msg">
+; RUN: llc -filetype=asm -O0 -mtriple=x86_64-apple-darwin < %s -dwarf-version 4 | FileCheck -check-prefixes=CHECK,DARWIN-ASM4 %s<br class="gmail_msg">
+; RUN: llc -filetype=obj %s -mtriple=x86_64-apple-darwin -o %t2-2 -dwarf-version 2<br class="gmail_msg">
+; RUN: llvm-dwarfdump %t2-2 | FileCheck %s -check-prefix=CHECK-DWARF<br class="gmail_msg">
+; RUN: llc -filetype=obj %s -mtriple=x86_64-apple-darwin -o %t2-4 -dwarf-version 4<br class="gmail_msg">
+; RUN: llvm-dwarfdump %t2-4 | FileCheck %s -check-prefix=CHECK-DWARF<br class="gmail_msg">
+<br class="gmail_msg">
+; RUN: llc -filetype=asm -O0 -mtriple=x86_64-pc-win32 < %s -dwarf-version 2 | FileCheck -check-prefixes=CHECK,COFF-ASM %s<br class="gmail_msg">
+; RUN: llc -filetype=asm -O0 -mtriple=x86_64-pc-win32 < %s -dwarf-version 4 | FileCheck -check-prefixes=CHECK,COFF-ASM %s<br class="gmail_msg">
+; RUN: llc -filetype=obj -O0 %s -mtriple=x86_64-pc-win32 -o %t3-2 -dwarf-version 2<br class="gmail_msg">
+; RUN: llvm-dwarfdump %t3-2 | FileCheck %s -check-prefix=CHECK-DWARF2<br class="gmail_msg">
+; RUN: llc -filetype=obj -O0 %s -mtriple=x86_64-pc-win32 -o %t3-4 -dwarf-version 4<br class="gmail_msg">
+; RUN: llvm-dwarfdump %t3-4 | FileCheck %s -check-prefix=CHECK-DWARF<br class="gmail_msg">
<br class="gmail_msg">
; Testing case generated from:<br class="gmail_msg">
; clang++ tu1.cpp tu2.cpp -g -emit-llvm -c<br class="gmail_msg">
@@ -22,7 +34,10 @@<br class="gmail_msg">
; Make sure we use relocation for ref_addr on non-darwin platforms.<br class="gmail_msg">
; CHECK: DW_TAG_compile_unit<br class="gmail_msg">
; CHECK: DW_TAG_variable<br class="gmail_msg">
-; CHECK: .long [[TYPE:.*]] # DW_AT_type<br class="gmail_msg">
+; ELF-ASM: .long [[TYPE:.*]] # DW_AT_type<br class="gmail_msg">
+; DARWIN-ASM2: .long [[TYPE:.*]] ## DW_AT_type<br class="gmail_msg">
+; DARWIN-ASM4: .long [[TYPE:.*]] ## DW_AT_type<br class="gmail_msg">
+; COFF-ASM: .long [[TYPE:.*]] # DW_AT_type<br class="gmail_msg">
; CHECK: DW_TAG_structure_type<br class="gmail_msg">
; CHECK: cu_begin1<br class="gmail_msg">
; CHECK: DW_TAG_compile_unit<br class="gmail_msg">
@@ -30,25 +45,24 @@<br class="gmail_msg">
; This variable's type is in the 1st CU.<br class="gmail_msg">
; CHECK: DW_TAG_variable<br class="gmail_msg">
; Make sure this is relocatable.<br class="gmail_msg">
-; CHECK: .quad .Lsection_info+[[TYPE]] # DW_AT_type<br class="gmail_msg">
+; and test that we don't create the labels to emit a correct COFF relocation<br class="gmail_msg">
+; ELF-ASM: .quad .Lsection_info+[[TYPE]] # DW_AT_type<br class="gmail_msg">
+; COFF-ASM: .secrel32 .Lsection_info+[[TYPE]] # DW_AT_type<br class="gmail_msg">
+; DARWIN-ASM2: .quad [[TYPE]] ## DW_AT_type<br class="gmail_msg">
+; DARWIN-ASM4: .long [[TYPE]] ## DW_AT_type<br class="gmail_msg">
; CHECK-NOT: DW_TAG_structure_type<br class="gmail_msg">
; CHECK: .section<br class="gmail_msg">
<br class="gmail_msg">
-; test that we don't create useless labels<br class="gmail_msg">
-; DARWIN-ASM: .long [[TYPE:.*]] ## DW_AT_type<br class="gmail_msg">
-; DARWIN-ASM: .quad [[TYPE]] ## DW_AT_type<br class="gmail_msg">
-<br class="gmail_msg">
; CHECK-DWARF: DW_TAG_compile_unit<br class="gmail_msg">
; CHECK-DWARF: 0x[[ADDR:.*]]: DW_TAG_structure_type<br class="gmail_msg">
; CHECK-DWARF: DW_TAG_compile_unit<br class="gmail_msg">
; CHECK-DWARF: DW_TAG_variable<br class="gmail_msg">
; CHECK-DWARF: DW_AT_type [DW_FORM_ref_addr] {{.*}}[[ADDR]])<br class="gmail_msg">
<br class="gmail_msg">
-; DARWIN-DWARF: DW_TAG_compile_unit<br class="gmail_msg">
-; DARWIN-DWARF: 0x[[ADDR:.*]]: DW_TAG_structure_type<br class="gmail_msg">
-; DARWIN-DWARF: DW_TAG_compile_unit<br class="gmail_msg">
-; DARWIN-DWARF: DW_TAG_variable<br class="gmail_msg">
-; DARWIN-DWARF: DW_AT_type [DW_FORM_ref_addr] {{.*}}[[ADDR]])<br class="gmail_msg">
+; CHECK-DWARF2: DW_TAG_compile_unit<br class="gmail_msg">
+; CHECK-DWARF2: DW_TAG_variable<br class="gmail_msg">
+; CHECK-DWARF2: DW_AT_type [DW_FORM_ref4] {{.*}} => {[[ADDR:.*]]})<br class="gmail_msg">
+; CHECK-DWARF2: [[ADDR]]: DW_TAG_structure_type<br class="gmail_msg">
<br class="gmail_msg">
%struct.foo = type { i8 }<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
llvm-commits mailing list<br class="gmail_msg">
<a href="mailto:llvm-commits@lists.llvm.org" class="gmail_msg" target="_blank">llvm-commits@lists.llvm.org</a><br class="gmail_msg">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br class="gmail_msg">
</blockquote></div><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature"><div dir="ltr">Mike<br>Sent from phone</div></div>