Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[XCOFF] Decode the relocation entries of loader section of xcoff for …
…llvm-readobj Summary: support decoding the relocation entries of loader section of xcoff for llvm-readobj https://www.ibm.com/docs/en/aix/7.2?topic=formats-xcoff-object-file-format#XCOFF__vra3i31ejbau Reviewers: James Henderson, Esme Yi Differential Revision: https://reviews.llvm.org/D136787
- Loading branch information
Showing
9 changed files
with
375 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
llvm/test/tools/llvm-readobj/XCOFF/loader-section-relocation-invalid-sym-name.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
## Test invalid offset to symbol string table of loader section for --loader-section-relocations option. | ||
|
||
# RUN: yaml2obj %s -o %t_xcoff.o | ||
# RUN: llvm-readobj --loader-section-relocations %t_xcoff.o 2>&1 | FileCheck -DFILE=%t_xcoff.o %s | ||
|
||
--- !XCOFF | ||
FileHeader: | ||
MagicNumber: 0x1DF | ||
Sections: | ||
- Name: .loader | ||
Flags: [ STYP_LOADER ] | ||
SectionData: "0000000100000001000000020000016D00000001000000A40000000c0000005000000000000000A22000028000021105000000000000000020000294000000011f0000022000029c000000031f000002000a66756e63305f5f467600" | ||
## ^------- -Version=1 | ||
## ^------- -NumberOfSymbolEntries=1 | ||
## ^------- -NumberOfRelocationEntries=2 | ||
## ^------- -LengthOfImportFileIDStringTable=365 | ||
## ^------- -NumberOfImportFileIDs=1 | ||
## ^------- -OffsetToImportFileIDs=0xA4 | ||
## ^------- -LengthOfStringTable=12 | ||
## ^------- -OffsetToStringTable=0x050 | ||
## ^-------SymbolZero=0 | ||
## ^-------OffsetToStringTbl=0xA2 (Invalid) | ||
## ^------- Value=0x20000280 | ||
## ^--- sectionNumber = 2 | ||
## ^- SymbolType=0x11 | ||
## ^- StorageClass=0x05 | ||
## ^------- ImportFileID=0 | ||
## ^-------ParameterCheckType=0 | ||
## ^------- Virtual Address = 0x20000294 | ||
## ^------- SymbolIndex = 1 | ||
## ^--- Type =0x1f | ||
## ^--- Section Num =2 | ||
## ^------- Virtual Address = 0x20000294 | ||
## ^------- SymbolIndex = 3 | ||
## ^--- Type =0x1f | ||
## ^--- Section Num =2 | ||
## ^StringTable | ||
|
||
# CHECK: warning: '[[FILE]]': entry with offset 0xa2 in the loader section's string table with size 0xc is invalid |
102 changes: 102 additions & 0 deletions
102
llvm/test/tools/llvm-readobj/XCOFF/loader-section-relocation.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
## Test the --loader-section-relocations option. | ||
|
||
# RUN: yaml2obj --docnum=1 %s -o %t_xcoff32.o | ||
# RUN: yaml2obj --docnum=2 %s -o %t_xcoff64.o | ||
# RUN: llvm-readobj --loader-section-relocations --expand-relocs %t_xcoff32.o | FileCheck --check-prefixes=COMMON,EXPAND %s | ||
# RUN: llvm-readobj --loader-section-relocations --expand-relocs %t_xcoff64.o | FileCheck --check-prefixes=COMMON,EXPAND %s | ||
# RUN: llvm-readobj --loader-section-relocations %t_xcoff32.o | FileCheck --check-prefixes=COMMON,NOEXPAND32 %s | ||
# RUN: llvm-readobj --loader-section-relocations %t_xcoff64.o | FileCheck --check-prefixes=COMMON,NOEXPAND64 %s | ||
|
||
--- !XCOFF | ||
FileHeader: | ||
MagicNumber: 0x1DF | ||
Sections: | ||
- Name: .loader | ||
Flags: [ STYP_LOADER ] | ||
SectionData: "0000000100000001000000020000016D00000001000000A400000000000000506d79696e747661722000028000021105000000000000000020000294000000011f0000022000029c000000031f000002" | ||
## ^------- -Version=1 | ||
## ^------- -NumberOfSymbolEntries=1 | ||
## ^------- -NumberOfRelocationEntries=2 | ||
## ^------- -LengthOfImportFileIDStringTable=365 | ||
## ^------- -NumberOfImportFileIDs=1 | ||
## ^------- -OffsetToImportFileIDs=0xA4 | ||
## ^------- -LengthOfStringTable=0 | ||
## ^------- -OffsetToStringTable=0 | ||
## ^--------------- SymbolName=myintvar | ||
## ^------- Value=0x20000280 | ||
## ^--- sectionNumber = 2 | ||
## ^- SymbolType=0x11 | ||
## ^- StorageClass=0x05 | ||
## ^------- ImportFileID=0 | ||
## ^-------ParameterCheckType=0 | ||
## ^------- Virtual Address = 0x20000294 | ||
## ^------- SymbolIndex = 1 | ||
## ^--- Type =0x1f00 | ||
## ^--- Section Num =2 | ||
## ^------- Virtual Address = 0x20000294 | ||
## ^------- SymbolIndex = 3 | ||
## ^--- Type =0x1f00 | ||
## ^--- Section Num =2 | ||
|
||
--- !XCOFF | ||
FileHeader: | ||
MagicNumber: 0x1F7 | ||
Sections: | ||
- Name: .loader | ||
Flags: [ STYP_LOADER ] | ||
SectionData: "0000000200000001000000020000016D000000010000001200000000000000D000000000000000700000000000000038000000000000005000000001100003000000000200021105000000000000000000000000200002941f00000200000001000000002000029C1f0000020000000300096d79696e747661720000" | ||
## ^------- -Version=2 | ||
## ^------- -NumberOfSymbolEntries=1 | ||
## ^------- -NumberOfRelocationEntries=2 | ||
## ^------- -LengthOfImportFileIDStringTable=365 | ||
## ^------- -NumberOfImportFileIDs=1 | ||
## ^------- --LengthOfStringTable=0x12 | ||
## ^--------------- -OffsetToImportFileIDs=0xD0 | ||
## ^--------------- -OffsetToStringTable=0x70 | ||
## ^--------------- -OffsetToSymbolTable=0x38 | ||
## ^--------------- -OffsetToRelocationEntries=0x50 | ||
## ^--------------- Value=0x0000000110000300 | ||
## ^------- OffsetToStringTbl=2 | ||
## ^--- sectionNumber = 2 | ||
## ^- SymbolType=0x11 | ||
## ^- StorageClass=0x05 | ||
## ^------- ImportFileID=0 | ||
## ^-------ParameterCheckType=0 | ||
## ^--------------- VirtualAddress= 0x20000294 | ||
## ^--- Type= 1f00 | ||
## ^---SectionNumber = 2 | ||
## ^------- SymbolIndex =1 | ||
## ^--------------- VirtualAddress= 0x2000029C | ||
## ^--- Type= 1f00 | ||
## ^---SectionNumber = 2 | ||
## ^------- SymbolIndex =3 | ||
## ^-------------------StringTable | ||
|
||
# COMMON: Loader Section { | ||
# COMMON-NEXT: Loader Section Relocations { | ||
# NOEXPAND64-NEXT: Vaddr Type SecNum SymbolName (Index) | ||
# NOEXPAND64-NEXT: 0x0000000020000294 0x1f00 (R_POS) 2 .data (1) | ||
# NOEXPAND64-NEXT: 0x000000002000029c 0x1f00 (R_POS) 2 myintvar (3) | ||
# NOEXPAND32-NEXT: Vaddr Type SecNum SymbolName (Index) | ||
# NOEXPAND32-NEXT: 0x20000294 0x1f00 (R_POS) 2 .data (1) | ||
# NOEXPAND32-NEXT: 0x2000029c 0x1f00 (R_POS) 2 myintvar (3) | ||
# EXPAND-NEXT: Relocation { | ||
# EXPAND-NEXT: Virtual Address: 0x20000294 | ||
# EXPAND-NEXT: Symbol: .data (1) | ||
# EXPAND-NEXT: IsSigned: No | ||
# EXPAND-NEXT: FixupBitValue: 0 | ||
# EXPAND-NEXT: Length: 32 | ||
# EXPAND-NEXT: Type: R_POS (0x0) | ||
# EXPAND-NEXT: SectionNumber: 2 | ||
# EXPAND-NEXT: } | ||
# EXPAND-NEXT: Relocation { | ||
# EXPAND-NEXT: Virtual Address: 0x2000029C | ||
# EXPAND-NEXT: Symbol: myintvar (3) | ||
# EXPAND-NEXT: IsSigned: No | ||
# EXPAND-NEXT: FixupBitValue: 0 | ||
# EXPAND-NEXT: Length: 32 | ||
# EXPAND-NEXT: Type: R_POS (0x0) | ||
# EXPAND-NEXT: SectionNumber: 2 | ||
# EXPAND-NEXT: } | ||
# EXPAND-NEXT: } | ||
# EXPAND-NEXT: } |
Oops, something went wrong.