1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00
llvm-mirror/test/tools/llvm-readobj/coff-resources.test
Martin Storsjo 5e8195f9a7 [COFF] Add a ResourceSectionRef method for getting resource contents
This allows llvm-readobj to print the contents of each resource
when printing resources from an object file or executable, like it
already does for plain .res files.

This requires providing the whole COFFObjectFile to ResourceSectionRef.

This supports both object files and executables. For executables,
the DataRVA field is used as is to look up the right section.

For object files, ideally we would need to complete linking of them
and fix up all relocations to know what the DataRVA field would end up
being. In practice, the only thing that makes sense for an RVA field
is an ADDR32NB relocation. Thus, find a relocation pointing at this
field, verify that it has the expected type, locate the symbol it
points at, look up the section the symbol points at, and read from the
right offset in that section.

This works both for GNU windres object files (which use one single
.rsrc section, with all relocations against the base of the .rsrc
section, with the original value of the DataRVA field being the
offset of the data from the beginning of the .rsrc section) and
cvtres object files (with two separate .rsrc$01 and .rsrc$02 sections,
and one symbol per data entry, with the original pre-relocated DataRVA
field being set to zero).

Differential Revision: https://reviews.llvm.org/D66820

llvm-svn: 370433
2019-08-30 06:55:49 +00:00

211 lines
7.7 KiB
Plaintext

// Check dumping of the .rsrc section(s)
// The input was generated with the following commands, using the original Windows
// rc.exe and cvtres.exe:
// > rc /fo test_resource.res /nologo test_resource.rc
// > cvtres /machine:X86 /readonly /nologo /out:test_resource.o test_resource.res
RUN: llvm-readobj --coff-resources --section-data %p/Inputs/zero-string-table.obj.coff-i386 \
RUN: | FileCheck %s -check-prefix ZERO
RUN: llvm-readobj --coff-resources %p/Inputs/resources/test_resource.obj.coff \
RUN: | FileCheck %s -check-prefix TEST_RES
ZERO: Resources [
ZERO-NEXT: Total Number of Resources: 1
ZERO-NEXT: Base Table Address: 0x188
ZERO-DAG: Number of String Entries: 0
ZERO-NEXT: Number of ID Entries: 1
ZERO-NEXT: Type: STRINGTABLE (ID 6) [
ZERO-NEXT: Table Offset: 0x18
ZERO-NEXT: Number of String Entries: 0
ZERO-NEXT: Number of ID Entries: 1
ZERO-NEXT: Name: (ID 1) [
ZERO-NEXT: Table Offset: 0x30
ZERO-NEXT: Number of String Entries: 0
ZERO-NEXT: Number of ID Entries: 1
ZERO-NEXT: Language: (ID 1033) [
ZERO-NEXT: Entry Offset: 0x48
ZERO-NEXT: Time/Date Stamp: 1970-01-01 00:00:00 (0x0)
ZERO-NEXT: Major Version: 0
ZERO-NEXT: Minor Version: 0
ZERO-NEXT: Characteristics: 0
ZERO-NEXT: Data [
ZERO-NEXT: DataRVA: 0x0
ZERO-NEXT: DataSize: 42
ZERO-NEXT: Codepage: 0
ZERO-NEXT: Reserved: 0
ZERO-NEXT: Data (
ZERO-NEXT: 0000: 00000500 48006500 6C006C00 6F000000 |....H.e.l.l.o...|
ZERO-NEXT: 0010: 00000000 00000000 00000000 00000000 |................|
ZERO-NEXT: 0020: 00000000 00000000 0000 |..........|
ZERO-NEXT: )
ZERO-NEXT: ]
ZERO-NEXT: ]
ZERO-NEXT: ]
ZERO-NEXT: ]
TEST_RES: Resources [
TEST_RES-NEXT: Total Number of Resources: 7
TEST_RES-NEXT: Base Table Address: 0x1C0
TEST_RES-DAG: Number of String Entries: 0
TEST_RES-NEXT: Number of ID Entries: 4
TEST_RES-NEXT: Type: BITMAP (ID 2) [
TEST_RES-NEXT: Table Offset: 0x30
TEST_RES-NEXT: Number of String Entries: 2
TEST_RES-NEXT: Number of ID Entries: 0
TEST_RES-NEXT: Name: CURSOR [
TEST_RES-NEXT: Table Offset: 0xA8
TEST_RES-NEXT: Number of String Entries: 0
TEST_RES-NEXT: Number of ID Entries: 1
TEST_RES-NEXT: Language: (ID 1033) [
TEST_RES-NEXT: Entry Offset: 0x150
TEST_RES-NEXT: Time/Date Stamp: 1970-01-01 00:00:00 (0x0)
TEST_RES-NEXT: Major Version: 0
TEST_RES-NEXT: Minor Version: 0
TEST_RES-NEXT: Characteristics: 0
TEST_RES-NEXT: Data [
TEST_RES-NEXT: DataRVA: 0x0
TEST_RES-NEXT: DataSize: 808
TEST_RES-NEXT: Codepage: 0
TEST_RES-NEXT: Reserved: 0
TEST_RES-NEXT: Data (
TEST_RES: )
TEST_RES-NEXT: ]
TEST_RES-NEXT: ]
TEST_RES-NEXT: ]
TEST_RES-NEXT: Name: OKAY [
TEST_RES-NEXT: Table Offset: 0xC0
TEST_RES-NEXT: Number of String Entries: 0
TEST_RES-NEXT: Number of ID Entries: 1
TEST_RES-NEXT: Language: (ID 1033) [
TEST_RES-NEXT: Entry Offset: 0x160
TEST_RES-NEXT: Time/Date Stamp: 1970-01-01 00:00:00 (0x0)
TEST_RES-NEXT: Major Version: 0
TEST_RES-NEXT: Minor Version: 0
TEST_RES-NEXT: Characteristics: 0
TEST_RES-NEXT: Data [
TEST_RES-NEXT: DataRVA: 0x0
TEST_RES-NEXT: DataSize: 808
TEST_RES-NEXT: Codepage: 0
TEST_RES-NEXT: Reserved: 0
TEST_RES-NEXT: Data (
TEST_RES: )
TEST_RES-NEXT: ]
TEST_RES-NEXT: ]
TEST_RES-NEXT: ]
TEST_RES-NEXT: ]
TEST_RES-NEXT: Type: MENU (ID 4) [
TEST_RES-NEXT: Table Offset: 0x50
TEST_RES-NEXT: Number of String Entries: 1
TEST_RES-NEXT: Number of ID Entries: 1
TEST_RES-NEXT: Name: "EAT" [
TEST_RES-NEXT: Table Offset: 0xD8
TEST_RES-NEXT: Number of String Entries: 0
TEST_RES-NEXT: Number of ID Entries: 1
TEST_RES-NEXT: Language: (ID 3081) [
TEST_RES-NEXT: Entry Offset: 0x170
TEST_RES-NEXT: Time/Date Stamp: 1970-01-01 00:00:00 (0x0)
TEST_RES-NEXT: Major Version: 0
TEST_RES-NEXT: Minor Version: 0
TEST_RES-NEXT: Characteristics: 0
TEST_RES-NEXT: Data [
TEST_RES-NEXT: DataRVA: 0x0
TEST_RES-NEXT: DataSize: 48
TEST_RES-NEXT: Codepage: 0
TEST_RES-NEXT: Reserved: 0
TEST_RES-NEXT: Data (
TEST_RES: )
TEST_RES-NEXT: ]
TEST_RES-NEXT: ]
TEST_RES-NEXT: ]
TEST_RES-NEXT: Name: (ID 14432) [
TEST_RES-NEXT: Table Offset: 0xF0
TEST_RES-NEXT: Number of String Entries: 0
TEST_RES-NEXT: Number of ID Entries: 1
TEST_RES-NEXT: Language: (ID 2052) [
TEST_RES-NEXT: Entry Offset: 0x180
TEST_RES-NEXT: Time/Date Stamp: 1970-01-01 00:00:00 (0x0)
TEST_RES-NEXT: Major Version: 0
TEST_RES-NEXT: Minor Version: 0
TEST_RES-NEXT: Characteristics: 0
TEST_RES-NEXT: Data [
TEST_RES-NEXT: DataRVA: 0x0
TEST_RES-NEXT: DataSize: 46
TEST_RES-NEXT: Codepage: 0
TEST_RES-NEXT: Reserved: 0
TEST_RES-NEXT: Data (
TEST_RES: )
TEST_RES-NEXT: ]
TEST_RES-NEXT: ]
TEST_RES-NEXT: ]
TEST_RES-NEXT: ]
TEST_RES-NEXT: Type: DIALOG (ID 5) [
TEST_RES-NEXT: Table Offset: 0x70
TEST_RES-NEXT: Number of String Entries: 1
TEST_RES-NEXT: Number of ID Entries: 0
TEST_RES-NEXT: Name: TESTDIALOG [
TEST_RES-NEXT: Table Offset: 0x108
TEST_RES-NEXT: Number of String Entries: 0
TEST_RES-NEXT: Number of ID Entries: 1
TEST_RES-NEXT: Language: (ID 1033) [
TEST_RES-NEXT: Entry Offset: 0x190
TEST_RES-NEXT: Time/Date Stamp: 1970-01-01 00:00:00 (0x0)
TEST_RES-NEXT: Major Version: 0
TEST_RES-NEXT: Minor Version: 0
TEST_RES-NEXT: Characteristics: 0
TEST_RES-NEXT: Data [
TEST_RES-NEXT: DataRVA: 0x0
TEST_RES-NEXT: DataSize: 108
TEST_RES-NEXT: Codepage: 0
TEST_RES-NEXT: Reserved: 0
TEST_RES-NEXT: Data (
TEST_RES: )
TEST_RES-NEXT: ]
TEST_RES-NEXT: ]
TEST_RES-NEXT: ]
TEST_RES-NEXT: ]
TEST_RES-NEXT: Type: ACCELERATOR (ID 9) [
TEST_RES-NEXT: Table Offset: 0x88
TEST_RES-NEXT: Number of String Entries: 1
TEST_RES-NEXT: Number of ID Entries: 1
TEST_RES-NEXT: Name: MYACCELERATORS [
TEST_RES-NEXT: Table Offset: 0x120
TEST_RES-NEXT: Number of String Entries: 0
TEST_RES-NEXT: Number of ID Entries: 1
TEST_RES-NEXT: Language: (ID 1033) [
TEST_RES-NEXT: Entry Offset: 0x1A0
TEST_RES-NEXT: Time/Date Stamp: 1970-01-01 00:00:00 (0x0)
TEST_RES-NEXT: Major Version: 0
TEST_RES-NEXT: Minor Version: 0
TEST_RES-NEXT: Characteristics: 0
TEST_RES-NEXT: Data [
TEST_RES-NEXT: DataRVA: 0x0
TEST_RES-NEXT: DataSize: 24
TEST_RES-NEXT: Codepage: 0
TEST_RES-NEXT: Reserved: 0
TEST_RES-NEXT: Data (
TEST_RES: )
TEST_RES-NEXT: ]
TEST_RES-NEXT: ]
TEST_RES-NEXT: ]
TEST_RES-NEXT: Name: (ID 12) [
TEST_RES-NEXT: Table Offset: 0x138
TEST_RES-NEXT: Number of String Entries: 0
TEST_RES-NEXT: Number of ID Entries: 1
TEST_RES-NEXT: Language: (ID 1033) [
TEST_RES-NEXT: Entry Offset: 0x1B0
TEST_RES-NEXT: Time/Date Stamp: 1970-01-01 00:00:00 (0x0)
TEST_RES-NEXT: Major Version: 0
TEST_RES-NEXT: Minor Version: 0
TEST_RES-NEXT: Characteristics: 0
TEST_RES-NEXT: Data [
TEST_RES-NEXT: DataRVA: 0x0
TEST_RES-NEXT: DataSize: 24
TEST_RES-NEXT: Codepage: 0
TEST_RES-NEXT: Reserved: 0
TEST_RES-NEXT: Data (
TEST_RES: )
TEST_RES-NEXT: ]
TEST_RES-NEXT: ]
TEST_RES-NEXT: ]
TEST_RES-NEXT: ]