<div dir="ltr">Hello Peter,<br><br>This commit broke tests on few our builders:<br><br><a href="http://lab.llvm.org:8011/builders/lld-x86_64-win7/builds/26435">http://lab.llvm.org:8011/builders/lld-x86_64-win7/builds/26435</a><br><a href="http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/19298">http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/19298</a><br><br>. . .<br>Failing Tests (1):<br> lld :: ELF/lto-plugin-ignore.s<br><br>Please have a look?<br><br>Thanks<br><br>Galina<br></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Aug 22, 2018 at 4:58 PM Peter Collingbourne 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: pcc<br>
Date: Wed Aug 22 16:58:16 2018<br>
New Revision: 340499<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=340499&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=340499&view=rev</a><br>
Log:<br>
MC: Teach the COFF object writer to write address-significance tables.<br>
<br>
The format is the same as in ELF: a sequence of ULEB128-encoded<br>
symbol indexes.<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D51047" rel="noreferrer" target="_blank">https://reviews.llvm.org/D51047</a><br>
<br>
Added:<br>
llvm/trunk/test/MC/COFF/addrsig.s<br>
Modified:<br>
llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp<br>
llvm/trunk/test/MC/ELF/addrsig.s<br>
llvm/trunk/tools/llvm-readobj/COFFDumper.cpp<br>
llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp<br>
<br>
Modified: llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp?rev=340499&r1=340498&r2=340499&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp?rev=340499&r1=340498&r2=340499&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp (original)<br>
+++ llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp Wed Aug 22 16:58:16 2018<br>
@@ -36,6 +36,7 @@<br>
#include "llvm/Support/Endian.h"<br>
#include "llvm/Support/ErrorHandling.h"<br>
#include "llvm/Support/JamCRC.h"<br>
+#include "llvm/Support/LEB128.h"<br>
#include "llvm/Support/MathExtras.h"<br>
#include "llvm/Support/raw_ostream.h"<br>
#include <algorithm><br>
@@ -145,6 +146,10 @@ public:<br>
<br>
bool UseBigObj;<br>
<br>
+ bool EmitAddrsigSection = false;<br>
+ MCSectionCOFF *AddrsigSection;<br>
+ std::vector<const MCSymbol *> AddrsigSyms;<br>
+<br>
WinCOFFObjectWriter(std::unique_ptr<MCWinCOFFObjectTargetWriter> MOTW,<br>
raw_pwrite_stream &OS);<br>
<br>
@@ -204,6 +209,11 @@ public:<br>
void assignSectionNumbers();<br>
void assignFileOffsets(MCAssembler &Asm, const MCAsmLayout &Layout);<br>
<br>
+ void emitAddrsigSection() override { EmitAddrsigSection = true; }<br>
+ void addAddrsigSymbol(const MCSymbol *Sym) override {<br>
+ AddrsigSyms.push_back(Sym);<br>
+ }<br>
+<br>
uint64_t writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) override;<br>
};<br>
<br>
@@ -657,6 +667,13 @@ void WinCOFFObjectWriter::writeSection(M<br>
<br>
void WinCOFFObjectWriter::executePostLayoutBinding(MCAssembler &Asm,<br>
const MCAsmLayout &Layout) {<br>
+ if (EmitAddrsigSection) {<br>
+ AddrsigSection = Asm.getContext().getCOFFSection(<br>
+ ".llvm_addrsig", COFF::IMAGE_SCN_LNK_REMOVE,<br>
+ SectionKind::getMetadata());<br>
+ Asm.registerSection(*AddrsigSection);<br>
+ }<br>
+<br>
// "Define" each section & symbol. This creates section & symbol<br>
// entries in the staging area.<br>
for (const auto &Section : Asm)<br>
@@ -1024,6 +1041,24 @@ uint64_t WinCOFFObjectWriter::writeObjec<br>
Section->Symbol->Aux[0].Aux.SectionDefinition.Number = AssocSec->Number;<br>
}<br>
<br>
+ // Create the contents of the .llvm_addrsig section.<br>
+ if (EmitAddrsigSection) {<br>
+ auto Frag = new MCDataFragment(AddrsigSection);<br>
+ raw_svector_ostream OS(Frag->getContents());<br>
+ for (const MCSymbol *S : AddrsigSyms) {<br>
+ if (!S->isTemporary()) {<br>
+ encodeULEB128(S->getIndex(), OS);<br>
+ continue;<br>
+ }<br>
+<br>
+ MCSection *TargetSection = &S->getSection();<br>
+ assert(SectionMap.find(TargetSection) != SectionMap.end() &&<br>
+ "Section must already have been defined in "<br>
+ "executePostLayoutBinding!");<br>
+ encodeULEB128(SectionMap[TargetSection]->Symbol->getIndex(), OS);<br>
+ }<br>
+ }<br>
+<br>
assignFileOffsets(Asm, Layout);<br>
<br>
// MS LINK expects to be able to use this timestamp to implement their<br>
<br>
Added: llvm/trunk/test/MC/COFF/addrsig.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/addrsig.s?rev=340499&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/addrsig.s?rev=340499&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/MC/COFF/addrsig.s (added)<br>
+++ llvm/trunk/test/MC/COFF/addrsig.s Wed Aug 22 16:58:16 2018<br>
@@ -0,0 +1,51 @@<br>
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-win32 %s -o - | llvm-readobj -s -t -sd -addrsig | FileCheck %s<br>
+<br>
+// CHECK: Name: .llvm_addrsig<br>
+// CHECK-NEXT: VirtualSize: 0x0<br>
+// CHECK-NEXT: VirtualAddress: 0x0<br>
+// CHECK-NEXT: RawDataSize: 4<br>
+// CHECK-NEXT: PointerToRawData:<br>
+// CHECK-NEXT: PointerToRelocations: 0x0<br>
+// CHECK-NEXT: PointerToLineNumbers: 0x0<br>
+// CHECK-NEXT: RelocationCount: 0<br>
+// CHECK-NEXT: LineNumberCount: 0<br>
+// CHECK-NEXT: Characteristics [ (0x100800)<br>
+// CHECK-NEXT: IMAGE_SCN_ALIGN_1BYTES (0x100000)<br>
+// CHECK-NEXT: IMAGE_SCN_LNK_REMOVE (0x800)<br>
+// CHECK-NEXT: ]<br>
+// CHECK-NEXT: SectionData (<br>
+// CHECK-NEXT: 0000: 080A0B02<br>
+// CHECK-NEXT: )<br>
+<br>
+// CHECK: Symbols [<br>
+// CHECK: Name: .text<br>
+// CHECK: AuxSectionDef<br>
+// CHECK: Name: .data<br>
+// CHECK: AuxSectionDef<br>
+// CHECK: Name: .bss<br>
+// CHECK: AuxSectionDef<br>
+// CHECK: Name: .llvm_addrsig<br>
+// CHECK: AuxSectionDef<br>
+// CHECK: Name: g1<br>
+// CHECK: Name: g2<br>
+// CHECK: Name: g3<br>
+// CHECK: Name: local<br>
+<br>
+// CHECK: Addrsig [<br>
+// CHECK-NEXT: Sym: g1 (8)<br>
+// CHECK-NEXT: Sym: g3 (10)<br>
+// CHECK-NEXT: Sym: local (11)<br>
+// CHECK-NEXT: Sym: .data (2)<br>
+// CHECK-NEXT: ]<br>
+<br>
+.addrsig<br>
+.addrsig_sym g1<br>
+.globl g2<br>
+.addrsig_sym g3<br>
+.addrsig_sym local<br>
+.addrsig_sym .Llocal<br>
+<br>
+local:<br>
+<br>
+.data<br>
+.Llocal:<br>
<br>
Modified: llvm/trunk/test/MC/ELF/addrsig.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/addrsig.s?rev=340499&r1=340498&r2=340499&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/addrsig.s?rev=340499&r1=340498&r2=340499&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/MC/ELF/addrsig.s (original)<br>
+++ llvm/trunk/test/MC/ELF/addrsig.s Wed Aug 22 16:58:16 2018<br>
@@ -1,6 +1,6 @@<br>
// RUN: llvm-mc -filetype=asm -triple x86_64-pc-linux-gnu %s -o - | FileCheck --check-prefix=ASM %s<br>
-// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -t -sd -elf-addrsig | FileCheck %s<br>
-// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -split-dwarf-file %t.dwo -o - | llvm-readobj -s -t -sd -elf-addrsig | FileCheck %s<br>
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -t -sd -addrsig | FileCheck %s<br>
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -split-dwarf-file %t.dwo -o - | llvm-readobj -s -t -sd -addrsig | FileCheck %s<br>
// RUN: llvm-readobj -s %t.dwo | FileCheck --check-prefix=DWO %s<br>
<br>
// CHECK: Name: .llvm_addrsig<br>
<br>
Modified: llvm/trunk/tools/llvm-readobj/COFFDumper.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/COFFDumper.cpp?rev=340499&r1=340498&r2=340499&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/COFFDumper.cpp?rev=340499&r1=340498&r2=340499&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-readobj/COFFDumper.cpp (original)<br>
+++ llvm/trunk/tools/llvm-readobj/COFFDumper.cpp Wed Aug 22 16:58:16 2018<br>
@@ -50,6 +50,7 @@<br>
#include "llvm/Support/ConvertUTF.h"<br>
#include "llvm/Support/FormatVariadic.h"<br>
#include "llvm/Support/ScopedPrinter.h"<br>
+#include "llvm/Support/LEB128.h"<br>
#include "llvm/Support/Win64EH.h"<br>
#include "llvm/Support/raw_ostream.h"<br>
<br>
@@ -98,6 +99,7 @@ public:<br>
mergeCodeViewTypes(llvm::codeview::MergingTypeTableBuilder &CVIDs,<br>
llvm::codeview::MergingTypeTableBuilder &CVTypes) override;<br>
void printStackMap() const override;<br>
+ void printAddrsig() override;<br>
private:<br>
void printSymbol(const SymbolRef &Sym);<br>
void printRelocation(const SectionRef &Section, const RelocationRef &Reloc,<br>
@@ -1830,6 +1832,49 @@ void COFFDumper::printStackMap() const {<br>
StackMapV2Parser<support::big>(StackMapContentsArray));<br>
}<br>
<br>
+void COFFDumper::printAddrsig() {<br>
+ object::SectionRef AddrsigSection;<br>
+ for (auto Sec : Obj->sections()) {<br>
+ StringRef Name;<br>
+ Sec.getName(Name);<br>
+ if (Name == ".llvm_addrsig") {<br>
+ AddrsigSection = Sec;<br>
+ break;<br>
+ }<br>
+ }<br>
+<br>
+ if (AddrsigSection == object::SectionRef())<br>
+ return;<br>
+<br>
+ StringRef AddrsigContents;<br>
+ AddrsigSection.getContents(AddrsigContents);<br>
+ ArrayRef<uint8_t> AddrsigContentsArray(<br>
+ reinterpret_cast<const uint8_t*>(AddrsigContents.data()),<br>
+ AddrsigContents.size());<br>
+<br>
+ ListScope L(W, "Addrsig");<br>
+ auto *Cur = reinterpret_cast<const uint8_t *>(AddrsigContents.begin());<br>
+ auto *End = reinterpret_cast<const uint8_t *>(AddrsigContents.end());<br>
+ while (Cur != End) {<br>
+ unsigned Size;<br>
+ const char *Err;<br>
+ uint64_t SymIndex = decodeULEB128(Cur, &Size, End, &Err);<br>
+ if (Err)<br>
+ reportError(Err);<br>
+<br>
+ Expected<COFFSymbolRef> Sym = Obj->getSymbol(SymIndex);<br>
+ StringRef SymName;<br>
+ std::error_code EC = errorToErrorCode(Sym.takeError());<br>
+ if (EC || (EC = Obj->getSymbolName(*Sym, SymName))) {<br>
+ SymName = "";<br>
+ error(EC);<br>
+ }<br>
+<br>
+ W.printNumber("Sym", SymName, SymIndex);<br>
+ Cur += Size;<br>
+ }<br>
+}<br>
+<br>
void llvm::dumpCodeViewMergedTypes(<br>
ScopedPrinter &Writer, llvm::codeview::MergingTypeTableBuilder &IDTable,<br>
llvm::codeview::MergingTypeTableBuilder &CVTypes) {<br>
<br>
Modified: llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp?rev=340499&r1=340498&r2=340499&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp?rev=340499&r1=340498&r2=340499&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp (original)<br>
+++ llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp Wed Aug 22 16:58:16 2018<br>
@@ -302,7 +302,7 @@ namespace opts {<br>
<br>
cl::opt<bool> CGProfile("elf-cg-profile", cl::desc("Display callgraph profile section"));<br>
<br>
- cl::opt<bool> Addrsig("elf-addrsig",<br>
+ cl::opt<bool> Addrsig("addrsig",<br>
cl::desc("Display address-significance table"));<br>
<br>
cl::opt<OutputStyleTy><br>
@@ -492,6 +492,8 @@ static void dumpObject(const ObjectFile<br>
Dumper->printCOFFResources();<br>
if (opts::COFFLoadConfig)<br>
Dumper->printCOFFLoadConfig();<br>
+ if (opts::Addrsig)<br>
+ Dumper->printAddrsig();<br>
if (opts::CodeView)<br>
Dumper->printCodeViewDebugInfo();<br>
if (opts::CodeViewMergedTypes)<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>