llvm.org GIT mirror llvm / c81f000
Reland "[llvm-readobj] Simplify usage of -codeview flag" Relands r255790 with fixed tests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255793 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Kleckner 4 years ago
7 changed file(s) with 19 addition(s) and 17 deletion(s). Raw diff Collapse all Expand all
0 ; RUN: llc -mcpu=core2 -mtriple=i686-pc-win32 -O0 < %s | FileCheck --check-prefix=X86 %s
1 ; RUN: llc -mcpu=core2 -mtriple=i686-pc-win32 -o - -O0 < %s | llvm-mc -triple=i686-pc-win32 -filetype=obj | llvm-readobj -s -sr -codeview -section-symbols | FileCheck --check-prefix=OBJ32 %s
1 ; RUN: llc -mcpu=core2 -mtriple=i686-pc-win32 -o - -O0 < %s | llvm-mc -triple=i686-pc-win32 -filetype=obj | llvm-readobj -s -sr -codeview | FileCheck --check-prefix=OBJ32 %s
22 ; RUN: llc -mcpu=core2 -mtriple=x86_64-pc-win32 -O0 < %s | FileCheck --check-prefix=X64 %s
3 ; RUN: llc -mcpu=core2 -mtriple=x86_64-pc-win32 -o - -O0 < %s | llvm-mc -triple=x86_64-pc-win32 -filetype=obj | llvm-readobj -s -sr -codeview -section-symbols | FileCheck --check-prefix=OBJ64 %s
3 ; RUN: llc -mcpu=core2 -mtriple=x86_64-pc-win32 -o - -O0 < %s | llvm-mc -triple=x86_64-pc-win32 -filetype=obj | llvm-readobj -s -sr -codeview | FileCheck --check-prefix=OBJ64 %s
44
55 ; This LL file was generated by running clang on the following code:
66 ; D:\asm.c:
9393 ; OBJ32-NEXT: 0x44 IMAGE_REL_I386_SECREL _f
9494 ; OBJ32-NEXT: 0x48 IMAGE_REL_I386_SECTION _f
9595 ; OBJ32-NEXT: ]
96 ; OBJ32: CodeViewDebugInfo [
9697 ; OBJ32: Subsection [
9798 ; OBJ32-NEXT: Type: 0xF1
9899 ; OBJ32-NOT: ]
123124 ; OBJ32-NEXT: ColEnd: 0
124125 ; OBJ32-NEXT: ]
125126 ; OBJ32-NEXT: ]
126 ; OBJ32: }
127127
128128 ; X64-LABEL: f:
129129 ; X64-NEXT: .L{{.*}}:{{$}}
247247 ; OBJ64-NEXT: ColEnd: 0
248248 ; OBJ64-NEXT: ]
249249 ; OBJ64-NEXT: ]
250 ; OBJ64: }
251250
252251 ; Function Attrs: nounwind
253252 define void @f() #0 !dbg !4 {
156156 ; OBJ32-NEXT: ColEnd: 0
157157 ; OBJ32-NEXT: ]
158158 ; OBJ32-NEXT: ]
159 ; OBJ32: }
160159
161160 ; X64-LABEL: f:
162161 ; X64-NEXT: .L{{.*}}:{{$}}
323322 ; OBJ64-NEXT: ColEnd: 0
324323 ; OBJ64-NEXT: ]
325324 ; OBJ64-NEXT: ]
326 ; OBJ64: }
327325
328326 ; Function Attrs: nounwind
329327 define void @f() #0 !dbg !4 {
306306 ; OBJ32-NEXT: ColEnd: 73
307307 ; OBJ32-NEXT: ]
308308 ; OBJ32-NEXT: ]
309 ; OBJ32: }
310309
311310 ; X64-LABEL: x:
312311 ; X64-NEXT: .L{{.*}}:
626625 ; OBJ64-NEXT: ColEnd: 73
627626 ; OBJ64-NEXT: ]
628627 ; OBJ64-NEXT: ]
629 ; OBJ64: }
630628
631629 ; Function Attrs: nounwind
632630 define void @x() #0 !dbg !4 {
111111 ; OBJ32-NEXT: ColEnd: 0
112112 ; OBJ32-NEXT: ]
113113 ; OBJ32-NEXT: ]
114 ; OBJ32: }
115114
116115 ; X64-LABEL: f:
117116 ; X64-NEXT: .L{{.*}}:{{$}}
225224 ; OBJ64-NEXT: ColEnd: 0
226225 ; OBJ64-NEXT: ]
227226 ; OBJ64-NEXT: ]
228 ; OBJ64: }
229227
230228 ; Function Attrs: nounwind
231229 define void @f() #0 !dbg !4 {
5959 void printCOFFExports() override;
6060 void printCOFFDirectives() override;
6161 void printCOFFBaseReloc() override;
62 void printCodeViewDebugInfo() override;
6263 void printStackMap() const override;
6364 private:
6465 void printSymbol(const SymbolRef &Sym);
7071 void printBaseOfDataField(const pe32_header *Hdr);
7172 void printBaseOfDataField(const pe32plus_header *Hdr);
7273
73 void printCodeViewDebugInfo(const SectionRef &Section);
74 void printCodeViewSection(const SectionRef &Section);
7475
7576 void printCodeViewSymbolsSubsection(StringRef Subsection,
7677 const SectionRef &Section,
473474
474475 void COFFDumper::printBaseOfDataField(const pe32plus_header *) {}
475476
476 void COFFDumper::printCodeViewDebugInfo(const SectionRef &Section) {
477 void COFFDumper::printCodeViewDebugInfo() {
478 for (const SectionRef &S : Obj->sections()) {
479 StringRef SecName;
480 error(S.getName(SecName));
481 if (SecName == ".debug$S")
482 printCodeViewSection(S);
483 }
484 }
485
486 void COFFDumper::printCodeViewSection(const SectionRef &Section) {
477487 StringRef Data;
478488 error(Section.getContents(Data));
479489
515525
516526 switch (SubSectionType) {
517527 case COFF::DEBUG_SYMBOL_SUBSECTION:
518 if (opts::SectionSymbols)
519 printCodeViewSymbolsSubsection(Contents, Section, Offset);
528 printCodeViewSymbolsSubsection(Contents, Section, Offset);
520529 break;
521530 case COFF::DEBUG_LINE_TABLE_SUBSECTION: {
522531 // Holds a PC to file:line table. Some data to parse this subsection is
776785 }
777786 }
778787
779 if (Name == ".debug$S" && opts::CodeView)
780 printCodeViewDebugInfo(Sec);
781
782788 if (opts::SectionData &&
783789 !(Section->Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA)) {
784790 StringRef Data;
5555 virtual void printCOFFExports() { }
5656 virtual void printCOFFDirectives() { }
5757 virtual void printCOFFBaseReloc() { }
58 virtual void printCodeViewDebugInfo() { }
5859
5960 // Only implemented for MachO.
6061 virtual void printMachODataInCode() { }
353353 Dumper->printCOFFDirectives();
354354 if (opts::COFFBaseRelocs)
355355 Dumper->printCOFFBaseReloc();
356 if (opts::CodeView)
357 Dumper->printCodeViewDebugInfo();
356358 }
357359 if (Obj->isMachO()) {
358360 if (opts::MachODataInCode)