Skip to content

Commit c8e980a

Browse files
author
Esme-Yi
committed
[XCOFF][llvm-objdump] Dump the debug type in --section-headers option.
Summary: Add XCOFF recognition of debug section types under `--section-headers` option. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D103079
1 parent 0b21371 commit c8e980a

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

llvm/include/llvm/Object/XCOFFObjectFile.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ class XCOFFObjectFile : public ObjectFile {
338338
bool isSectionText(DataRefImpl Sec) const override;
339339
bool isSectionData(DataRefImpl Sec) const override;
340340
bool isSectionBSS(DataRefImpl Sec) const override;
341+
bool isDebugSection(DataRefImpl Sec) const override;
341342

342343
bool isSectionVirtual(DataRefImpl Sec) const override;
343344
relocation_iterator section_rel_begin(DataRefImpl Sec) const override;

llvm/lib/Object/XCOFFObjectFile.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,11 @@ bool XCOFFObjectFile::isSectionBSS(DataRefImpl Sec) const {
311311
return Flags & (XCOFF::STYP_BSS | XCOFF::STYP_TBSS);
312312
}
313313

314+
bool XCOFFObjectFile::isDebugSection(DataRefImpl Sec) const {
315+
uint32_t Flags = getSectionFlags(Sec);
316+
return Flags & (XCOFF::STYP_DEBUG | XCOFF::STYP_DWARF);
317+
}
318+
314319
bool XCOFFObjectFile::isSectionVirtual(DataRefImpl Sec) const {
315320
return is64Bit() ? toSection64(Sec)->FileOffsetToRawData == 0
316321
: toSection32(Sec)->FileOffsetToRawData == 0;

llvm/test/tools/llvm-objdump/XCOFF/section-headers.test

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
# CHECK-NEXT: 2 .bss 00000000 00000010 BSS
1212
# CHECK-NEXT: 3 .tdata 00000004 00000000 DATA
1313
# CHECK-NEXT: 4 .tbss 00000000 00000000 BSS
14+
# CHECK-NEXT: 5 .dwline 00000046 00000000 DEBUG
15+
# CHECK-NEXT: 6 .debug 00000046 00000000 DEBUG
1416

1517
--- !XCOFF
1618
FileHeader:
@@ -33,6 +35,12 @@ Sections:
3335
- Name: .tbss
3436
Size: 0x0
3537
Flags: [ STYP_TBSS ]
38+
- Name: .dwline
39+
Size: 0x46
40+
Flags: [ STYP_DWARF ]
41+
- Name: .debug
42+
Size: 0x46
43+
Flags: [ STYP_DEBUG ]
3644

3745
## Check the -h/--section-headers option prints long section names.
3846
# RUN: yaml2obj %s --docnum=2 -o %t-longname.o

0 commit comments

Comments
 (0)