1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 12:43:36 +01:00

Reland "[llvm-readobj] Simplify usage of -codeview flag"

Relands r255790 with fixed tests.

llvm-svn: 255793
This commit is contained in:
Reid Kleckner 2015-12-16 18:28:12 +00:00
parent 082d1c6dcb
commit a0000e2429
7 changed files with 19 additions and 17 deletions

View File

@ -1,7 +1,7 @@
; RUN: llc -mcpu=core2 -mtriple=i686-pc-win32 -O0 < %s | FileCheck --check-prefix=X86 %s ; RUN: llc -mcpu=core2 -mtriple=i686-pc-win32 -O0 < %s | FileCheck --check-prefix=X86 %s
; 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 ; 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
; RUN: llc -mcpu=core2 -mtriple=x86_64-pc-win32 -O0 < %s | FileCheck --check-prefix=X64 %s ; RUN: llc -mcpu=core2 -mtriple=x86_64-pc-win32 -O0 < %s | FileCheck --check-prefix=X64 %s
; 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 ; 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
; This LL file was generated by running clang on the following code: ; This LL file was generated by running clang on the following code:
; D:\asm.c: ; D:\asm.c:
@ -94,6 +94,7 @@
; OBJ32-NEXT: 0x44 IMAGE_REL_I386_SECREL _f ; OBJ32-NEXT: 0x44 IMAGE_REL_I386_SECREL _f
; OBJ32-NEXT: 0x48 IMAGE_REL_I386_SECTION _f ; OBJ32-NEXT: 0x48 IMAGE_REL_I386_SECTION _f
; OBJ32-NEXT: ] ; OBJ32-NEXT: ]
; OBJ32: CodeViewDebugInfo [
; OBJ32: Subsection [ ; OBJ32: Subsection [
; OBJ32-NEXT: Type: 0xF1 ; OBJ32-NEXT: Type: 0xF1
; OBJ32-NOT: ] ; OBJ32-NOT: ]
@ -124,7 +125,6 @@
; OBJ32-NEXT: ColEnd: 0 ; OBJ32-NEXT: ColEnd: 0
; OBJ32-NEXT: ] ; OBJ32-NEXT: ]
; OBJ32-NEXT: ] ; OBJ32-NEXT: ]
; OBJ32: }
; X64-LABEL: f: ; X64-LABEL: f:
; X64-NEXT: .L{{.*}}:{{$}} ; X64-NEXT: .L{{.*}}:{{$}}
@ -248,7 +248,6 @@
; OBJ64-NEXT: ColEnd: 0 ; OBJ64-NEXT: ColEnd: 0
; OBJ64-NEXT: ] ; OBJ64-NEXT: ]
; OBJ64-NEXT: ] ; OBJ64-NEXT: ]
; OBJ64: }
; Function Attrs: nounwind ; Function Attrs: nounwind
define void @f() #0 !dbg !4 { define void @f() #0 !dbg !4 {

View File

@ -157,7 +157,6 @@
; OBJ32-NEXT: ColEnd: 0 ; OBJ32-NEXT: ColEnd: 0
; OBJ32-NEXT: ] ; OBJ32-NEXT: ]
; OBJ32-NEXT: ] ; OBJ32-NEXT: ]
; OBJ32: }
; X64-LABEL: f: ; X64-LABEL: f:
; X64-NEXT: .L{{.*}}:{{$}} ; X64-NEXT: .L{{.*}}:{{$}}
@ -324,7 +323,6 @@
; OBJ64-NEXT: ColEnd: 0 ; OBJ64-NEXT: ColEnd: 0
; OBJ64-NEXT: ] ; OBJ64-NEXT: ]
; OBJ64-NEXT: ] ; OBJ64-NEXT: ]
; OBJ64: }
; Function Attrs: nounwind ; Function Attrs: nounwind
define void @f() #0 !dbg !4 { define void @f() #0 !dbg !4 {

View File

@ -307,7 +307,6 @@
; OBJ32-NEXT: ColEnd: 73 ; OBJ32-NEXT: ColEnd: 73
; OBJ32-NEXT: ] ; OBJ32-NEXT: ]
; OBJ32-NEXT: ] ; OBJ32-NEXT: ]
; OBJ32: }
; X64-LABEL: x: ; X64-LABEL: x:
; X64-NEXT: .L{{.*}}: ; X64-NEXT: .L{{.*}}:
@ -627,7 +626,6 @@
; OBJ64-NEXT: ColEnd: 73 ; OBJ64-NEXT: ColEnd: 73
; OBJ64-NEXT: ] ; OBJ64-NEXT: ]
; OBJ64-NEXT: ] ; OBJ64-NEXT: ]
; OBJ64: }
; Function Attrs: nounwind ; Function Attrs: nounwind
define void @x() #0 !dbg !4 { define void @x() #0 !dbg !4 {

View File

@ -112,7 +112,6 @@
; OBJ32-NEXT: ColEnd: 0 ; OBJ32-NEXT: ColEnd: 0
; OBJ32-NEXT: ] ; OBJ32-NEXT: ]
; OBJ32-NEXT: ] ; OBJ32-NEXT: ]
; OBJ32: }
; X64-LABEL: f: ; X64-LABEL: f:
; X64-NEXT: .L{{.*}}:{{$}} ; X64-NEXT: .L{{.*}}:{{$}}
@ -226,7 +225,6 @@
; OBJ64-NEXT: ColEnd: 0 ; OBJ64-NEXT: ColEnd: 0
; OBJ64-NEXT: ] ; OBJ64-NEXT: ]
; OBJ64-NEXT: ] ; OBJ64-NEXT: ]
; OBJ64: }
; Function Attrs: nounwind ; Function Attrs: nounwind
define void @f() #0 !dbg !4 { define void @f() #0 !dbg !4 {

View File

@ -60,6 +60,7 @@ public:
void printCOFFExports() override; void printCOFFExports() override;
void printCOFFDirectives() override; void printCOFFDirectives() override;
void printCOFFBaseReloc() override; void printCOFFBaseReloc() override;
void printCodeViewDebugInfo() override;
void printStackMap() const override; void printStackMap() const override;
private: private:
void printSymbol(const SymbolRef &Sym); void printSymbol(const SymbolRef &Sym);
@ -71,7 +72,7 @@ private:
void printBaseOfDataField(const pe32_header *Hdr); void printBaseOfDataField(const pe32_header *Hdr);
void printBaseOfDataField(const pe32plus_header *Hdr); void printBaseOfDataField(const pe32plus_header *Hdr);
void printCodeViewDebugInfo(const SectionRef &Section); void printCodeViewSection(const SectionRef &Section);
void printCodeViewSymbolsSubsection(StringRef Subsection, void printCodeViewSymbolsSubsection(StringRef Subsection,
const SectionRef &Section, const SectionRef &Section,
@ -474,7 +475,16 @@ void COFFDumper::printBaseOfDataField(const pe32_header *Hdr) {
void COFFDumper::printBaseOfDataField(const pe32plus_header *) {} void COFFDumper::printBaseOfDataField(const pe32plus_header *) {}
void COFFDumper::printCodeViewDebugInfo(const SectionRef &Section) { void COFFDumper::printCodeViewDebugInfo() {
for (const SectionRef &S : Obj->sections()) {
StringRef SecName;
error(S.getName(SecName));
if (SecName == ".debug$S")
printCodeViewSection(S);
}
}
void COFFDumper::printCodeViewSection(const SectionRef &Section) {
StringRef Data; StringRef Data;
error(Section.getContents(Data)); error(Section.getContents(Data));
@ -516,8 +526,7 @@ void COFFDumper::printCodeViewDebugInfo(const SectionRef &Section) {
switch (SubSectionType) { switch (SubSectionType) {
case COFF::DEBUG_SYMBOL_SUBSECTION: case COFF::DEBUG_SYMBOL_SUBSECTION:
if (opts::SectionSymbols) printCodeViewSymbolsSubsection(Contents, Section, Offset);
printCodeViewSymbolsSubsection(Contents, Section, Offset);
break; break;
case COFF::DEBUG_LINE_TABLE_SUBSECTION: { case COFF::DEBUG_LINE_TABLE_SUBSECTION: {
// Holds a PC to file:line table. Some data to parse this subsection is // Holds a PC to file:line table. Some data to parse this subsection is
@ -777,9 +786,6 @@ void COFFDumper::printSections() {
} }
} }
if (Name == ".debug$S" && opts::CodeView)
printCodeViewDebugInfo(Sec);
if (opts::SectionData && if (opts::SectionData &&
!(Section->Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA)) { !(Section->Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA)) {
StringRef Data; StringRef Data;

View File

@ -56,6 +56,7 @@ public:
virtual void printCOFFExports() { } virtual void printCOFFExports() { }
virtual void printCOFFDirectives() { } virtual void printCOFFDirectives() { }
virtual void printCOFFBaseReloc() { } virtual void printCOFFBaseReloc() { }
virtual void printCodeViewDebugInfo() { }
// Only implemented for MachO. // Only implemented for MachO.
virtual void printMachODataInCode() { } virtual void printMachODataInCode() { }

View File

@ -354,6 +354,8 @@ static void dumpObject(const ObjectFile *Obj) {
Dumper->printCOFFDirectives(); Dumper->printCOFFDirectives();
if (opts::COFFBaseRelocs) if (opts::COFFBaseRelocs)
Dumper->printCOFFBaseReloc(); Dumper->printCOFFBaseReloc();
if (opts::CodeView)
Dumper->printCodeViewDebugInfo();
} }
if (Obj->isMachO()) { if (Obj->isMachO()) {
if (opts::MachODataInCode) if (opts::MachODataInCode)