-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[llvm-pdbutil] Create DBI section headers in yaml2pdb #166566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| # RUN: llvm-pdbutil yaml2pdb %s --pdb=%t.pdb | ||
| # RUN: llvm-pdbutil dump --section-headers --section-map %t.pdb | FileCheck --check-prefix=CHECK-YAML2PDB %s | ||
|
|
||
| # RUN: llvm-pdbutil pdb2yaml --section-headers %t.pdb > %t.yaml | ||
| # RUN: FileCheck --input-file=%t.yaml --check-prefix=CHECK-PDB2YAML %s | ||
|
|
||
| # CHECK-YAML2PDB: Section Headers | ||
| # CHECK-YAML2PDB: SECTION HEADER #1 | ||
| # CHECK-YAML2PDB: .text name | ||
| # CHECK-YAML2PDB: 47 virtual size | ||
| # CHECK-YAML2PDB: 1000 virtual address | ||
| # CHECK-YAML2PDB: 200 size of raw data | ||
| # CHECK-YAML2PDB: 400 file pointer to raw data | ||
| # CHECK-YAML2PDB: 0 file pointer to relocation table | ||
| # CHECK-YAML2PDB: 0 file pointer to line numbers | ||
| # CHECK-YAML2PDB: 0 number of relocations | ||
| # CHECK-YAML2PDB: 0 number of line numbers | ||
| # CHECK-YAML2PDB: 60000020 flags | ||
| # CHECK-YAML2PDB: IMAGE_SCN_CNT_CODE | ||
| # CHECK-YAML2PDB: IMAGE_SCN_MEM_EXECUTE | ||
| # CHECK-YAML2PDB: IMAGE_SCN_MEM_READ | ||
|
|
||
| # CHECK-YAML2PDB: SECTION HEADER #2 | ||
| # CHECK-YAML2PDB: .rdata name | ||
| # CHECK-YAML2PDB: 64 virtual size | ||
| # CHECK-YAML2PDB: 2000 virtual address | ||
| # CHECK-YAML2PDB: 200 size of raw data | ||
| # CHECK-YAML2PDB: 600 file pointer to raw data | ||
| # CHECK-YAML2PDB: 0 file pointer to relocation table | ||
| # CHECK-YAML2PDB: 0 file pointer to line numbers | ||
| # CHECK-YAML2PDB: 0 number of relocations | ||
| # CHECK-YAML2PDB: 0 number of line numbers | ||
| # CHECK-YAML2PDB: 40000040 flags | ||
| # CHECK-YAML2PDB: IMAGE_SCN_CNT_INITIALIZED_DATA | ||
| # CHECK-YAML2PDB: IMAGE_SCN_MEM_READ | ||
|
|
||
| # CHECK-YAML2PDB: SECTION HEADER #3 | ||
| # CHECK-YAML2PDB: .pdata name | ||
| # CHECK-YAML2PDB: 18 virtual size | ||
| # CHECK-YAML2PDB: 3000 virtual address | ||
| # CHECK-YAML2PDB: 200 size of raw data | ||
| # CHECK-YAML2PDB: 800 file pointer to raw data | ||
| # CHECK-YAML2PDB: 0 file pointer to relocation table | ||
| # CHECK-YAML2PDB: 0 file pointer to line numbers | ||
| # CHECK-YAML2PDB: 0 number of relocations | ||
| # CHECK-YAML2PDB: 0 number of line numbers | ||
| # CHECK-YAML2PDB: 40000040 flags | ||
| # CHECK-YAML2PDB: IMAGE_SCN_CNT_INITIALIZED_DATA | ||
| # CHECK-YAML2PDB: IMAGE_SCN_MEM_READ | ||
|
|
||
| # CHECK-YAML2PDB: Section Map | ||
| # CHECK-YAML2PDB: Section 0000 | ovl = 0, group = 0, frame = 1, name = 65535 | ||
| # CHECK-YAML2PDB: class = 65535, offset = 0, size = 71 | ||
| # CHECK-YAML2PDB: flags = read | execute | 32 bit addr | selector | ||
| # CHECK-YAML2PDB: Section 0001 | ovl = 0, group = 0, frame = 2, name = 65535 | ||
| # CHECK-YAML2PDB: class = 65535, offset = 0, size = 100 | ||
| # CHECK-YAML2PDB: flags = read | 32 bit addr | selector | ||
| # CHECK-YAML2PDB: Section 0002 | ovl = 0, group = 0, frame = 3, name = 65535 | ||
| # CHECK-YAML2PDB: class = 65535, offset = 0, size = 24 | ||
| # CHECK-YAML2PDB: flags = read | 32 bit addr | selector | ||
| # CHECK-YAML2PDB: Section 0003 | ovl = 0, group = 0, frame = 4, name = 65535 | ||
| # CHECK-YAML2PDB: class = 65535, offset = 0, size = 4294967295 | ||
| # CHECK-YAML2PDB: flags = 32 bit addr | absolute addr | ||
|
|
||
| # CHECK-PDB2YAML:DbiStream: | ||
| # CHECK-PDB2YAML: SectionHeaders: | ||
| # CHECK-PDB2YAML: - Name: .text | ||
| # CHECK-PDB2YAML: VirtualSize: 71 | ||
| # CHECK-PDB2YAML: VirtualAddress: 4096 | ||
| # CHECK-PDB2YAML: SizeOfRawData: 512 | ||
| # CHECK-PDB2YAML: PointerToRawData: 1024 | ||
| # CHECK-PDB2YAML: PointerToRelocations: 0 | ||
| # CHECK-PDB2YAML: PointerToLinenumbers: 0 | ||
| # CHECK-PDB2YAML: NumberOfRelocations: 0 | ||
| # CHECK-PDB2YAML: NumberOfLinenumbers: 0 | ||
| # CHECK-PDB2YAML: Characteristics: 1610612768 | ||
| # CHECK-PDB2YAML: - Name: .rdata | ||
| # CHECK-PDB2YAML: VirtualSize: 100 | ||
| # CHECK-PDB2YAML: VirtualAddress: 8192 | ||
| # CHECK-PDB2YAML: SizeOfRawData: 512 | ||
| # CHECK-PDB2YAML: PointerToRawData: 1536 | ||
| # CHECK-PDB2YAML: PointerToRelocations: 0 | ||
| # CHECK-PDB2YAML: PointerToLinenumbers: 0 | ||
| # CHECK-PDB2YAML: NumberOfRelocations: 0 | ||
| # CHECK-PDB2YAML: NumberOfLinenumbers: 0 | ||
| # CHECK-PDB2YAML: Characteristics: 1073741888 | ||
| # CHECK-PDB2YAML: - Name: .pdata | ||
| # CHECK-PDB2YAML: VirtualSize: 24 | ||
| # CHECK-PDB2YAML: VirtualAddress: 12288 | ||
| # CHECK-PDB2YAML: SizeOfRawData: 512 | ||
| # CHECK-PDB2YAML: PointerToRawData: 2048 | ||
| # CHECK-PDB2YAML: PointerToRelocations: 0 | ||
| # CHECK-PDB2YAML: PointerToLinenumbers: 0 | ||
| # CHECK-PDB2YAML: NumberOfRelocations: 0 | ||
| # CHECK-PDB2YAML: NumberOfLinenumbers: 0 | ||
| # CHECK-PDB2YAML: Characteristics: 1073741888 | ||
|
|
||
| --- | ||
| DbiStream: | ||
| SectionHeaders: | ||
| - Name: .text | ||
| VirtualSize: 71 | ||
| VirtualAddress: 4096 | ||
| SizeOfRawData: 512 | ||
| PointerToRawData: 1024 | ||
| PointerToRelocations: 0 | ||
| PointerToLinenumbers: 0 | ||
| NumberOfRelocations: 0 | ||
| NumberOfLinenumbers: 0 | ||
| Characteristics: 1610612768 | ||
| - Name: .rdata | ||
| VirtualSize: 100 | ||
| VirtualAddress: 8192 | ||
| SizeOfRawData: 512 | ||
| PointerToRawData: 1536 | ||
| PointerToRelocations: 0 | ||
| PointerToLinenumbers: 0 | ||
| NumberOfRelocations: 0 | ||
| NumberOfLinenumbers: 0 | ||
| Characteristics: 1073741888 | ||
| - Name: .pdata | ||
| VirtualSize: 24 | ||
| VirtualAddress: 12288 | ||
| SizeOfRawData: 512 | ||
| PointerToRawData: 2048 | ||
| PointerToRelocations: 0 | ||
| PointerToLinenumbers: 0 | ||
| NumberOfRelocations: 0 | ||
| NumberOfLinenumbers: 0 | ||
| Characteristics: 1073741888 | ||
| ... |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -716,6 +716,10 @@ cl::list<ModuleSubsection> DumpModuleSubsections( | |
| cl::opt<bool> DumpModuleSyms("module-syms", cl::desc("dump module symbols"), | ||
| cl::cat(FileOptions), | ||
| cl::sub(PdbToYamlSubcommand)); | ||
| cl::opt<bool> DumpSectionHeaders("section-headers", | ||
| cl::desc("Dump section headers."), | ||
| cl::cat(FileOptions), | ||
| cl::sub(PdbToYamlSubcommand)); | ||
|
|
||
| cl::list<std::string> InputFilename(cl::Positional, | ||
| cl::desc("<input PDB file>"), cl::Required, | ||
|
|
@@ -865,6 +869,18 @@ static void yamlToPdb(StringRef Path) { | |
| } | ||
| } | ||
|
|
||
| std::vector<object::coff_section> Sections; | ||
| if (!Dbi.SectionHeaders.empty()) { | ||
| for (const auto &Hdr : Dbi.SectionHeaders) | ||
| Sections.emplace_back(Hdr.toCoffSection()); | ||
|
|
||
| DbiBuilder.createSectionMap(Sections); | ||
| ExitOnErr(DbiBuilder.addDbgStream( | ||
| pdb::DbgHeaderType::SectionHdr, | ||
| ArrayRef<uint8_t>{(const uint8_t *)Sections.data(), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't do it here, because
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yes the downcasting from
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for the delay. Should I create an issue for this? I can't think of a good name for this function/method(?).
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure github issues are really meant as a code cleanup backlog; at least a FIXME comment above would be enough for now. |
||
| Sections.size() * sizeof(object::coff_section)})); | ||
| } | ||
|
|
||
| auto &TpiBuilder = Builder.getTpiBuilder(); | ||
| const auto &Tpi = YamlObj.TpiStream.value_or(DefaultTpiStream); | ||
| TpiBuilder.setVersionHeader(Tpi.Version); | ||
|
|
@@ -1541,6 +1557,7 @@ int main(int Argc, const char **Argv) { | |
| opts::pdb2yaml::DumpModules = true; | ||
| opts::pdb2yaml::DumpModuleFiles = true; | ||
| opts::pdb2yaml::DumpModuleSyms = true; | ||
| opts::pdb2yaml::DumpSectionHeaders = true; | ||
| opts::pdb2yaml::DumpModuleSubsections.push_back( | ||
| opts::ModuleSubsection::All); | ||
| } | ||
|
|
@@ -1551,6 +1568,9 @@ int main(int Argc, const char **Argv) { | |
|
|
||
| if (opts::pdb2yaml::DumpModules) | ||
| opts::pdb2yaml::DbiStream = true; | ||
|
|
||
| if (opts::pdb2yaml::DumpSectionHeaders) | ||
| opts::pdb2yaml::DbiStream = true; | ||
| } | ||
|
|
||
| llvm::sys::InitializeCOMRAII COM(llvm::sys::COMThreadingMode::MultiThreaded); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.