Index: lld/test/COFF/combined-resources.test =================================================================== --- lld/test/COFF/combined-resources.test +++ lld/test/COFF/combined-resources.test @@ -10,10 +10,206 @@ # RUN: lld-link /out:%t.exe /entry:main %t.obj %p/Inputs/resource.res \ # RUN: %p/Inputs/combined-resources.res %p/Inputs/combined-resources-2.res -# RUN: llvm-readobj -coff-resources -file-headers %t.exe | FileCheck %s - +# RUN: llvm-readobj -coff-resources -file-headers -section-data %t.exe | \ +# RUN: FileCheck %s CHECK: ResourceTableRVA: 0x1000 CHECK-NEXT: ResourceTableSize: 0xC1C CHECK-DAG: Resources [ CHECK-NEXT: Total Number of Resources: 13 +CHECK-DAG: .rsrc Data ( +CHECK-NEXT: 0000: 00000000 00000000 00000000 01000600 |................| +CHECK-NEXT: 0010: 38030080 48000080 02000000 60000080 |8...H.......`...| +CHECK-NEXT: 0020: 04000000 80000080 05000000 A0000080 |................| +CHECK-NEXT: 0030: 06000000 B8000080 09000000 D0000080 |................| +CHECK-NEXT: 0040: 0A000000 F0000080 00000000 00000000 |................| +CHECK-NEXT: 0050: 00000000 01000000 50030080 08010080 |........P.......| +CHECK-NEXT: 0060: 00000000 00000000 00000000 02000000 |................| +CHECK-NEXT: 0070: FE020080 20010080 0C030080 38010080 |.... .......8...| +CHECK-NEXT: 0080: 00000000 00000000 00000000 01000100 |................| +CHECK-NEXT: 0090: 2C030080 50010080 60380000 68010080 |,...P...`8..h...| +CHECK-NEXT: 00A0: 00000000 00000000 00000000 01000000 |................| +CHECK-NEXT: 00B0: 16030080 80010080 00000000 00000000 |................| +CHECK-NEXT: 00C0: 00000000 00000100 01000000 98010080 |................| +CHECK-NEXT: 00D0: 00000000 00000000 00000000 01000100 |................| +CHECK-NEXT: 00E0: E0020080 B0010080 0C000000 D0010080 |................| +CHECK-NEXT: 00F0: 00000000 00000000 00000000 01000000 |................| +CHECK-NEXT: 0100: 66030080 E8010080 00000000 00000000 |f...............| +CHECK-NEXT: 0110: 00000000 00000100 09040000 10020000 |................| +CHECK-NEXT: 0120: 00000000 00000000 00000000 00000100 |................| +CHECK-NEXT: 0130: 09040000 20020000 00000000 00000000 |.... ...........| +CHECK-NEXT: 0140: 00000000 00000100 09040000 30020000 |............0...| +CHECK-NEXT: 0150: 00000000 00000000 00000000 00000100 |................| +CHECK-NEXT: 0160: 090C0000 40020000 00000000 00000000 |....@...........| +CHECK-NEXT: 0170: 00000000 00000100 04080000 50020000 |............P...| +CHECK-NEXT: 0180: 00000000 00000000 00000000 00000100 |................| +CHECK-NEXT: 0190: 09040000 60020000 00000000 00000000 |....`...........| +CHECK-NEXT: 01A0: 00000000 00000100 09040000 70020000 |............p...| +CHECK-NEXT: 01B0: 00000000 00000000 00000000 00000200 |................| +CHECK-NEXT: 01C0: 09040000 80020000 04080000 90020000 |................| +CHECK-NEXT: 01D0: 00000000 00000000 00000000 00000100 |................| +CHECK-NEXT: 01E0: 09040000 A0020000 00000000 00000000 |................| +CHECK-NEXT: 01F0: 00000000 00000300 09040000 B0020000 |................| +CHECK-NEXT: 0200: 04080000 C0020000 07100000 D0020000 |................| +CHECK-NEXT: 0210: FC1A0000 39000000 00000000 00000000 |....9...........| +CHECK-NEXT: 0220: C4130000 28030000 00000000 00000000 |....(...........| +CHECK-NEXT: 0230: EC160000 28030000 00000000 00000000 |....(...........| +CHECK-NEXT: 0240: CC1A0000 30000000 00000000 00000000 |....0...........| +CHECK-NEXT: 0250: 141A0000 2E000000 00000000 00000000 |................| +CHECK-NEXT: 0260: 441A0000 6C000000 00000000 00000000 |D...l...........| +CHECK-NEXT: 0270: 7C130000 2A000000 00000000 00000000 ||...*...........| +CHECK-NEXT: 0280: AC130000 18000000 00000000 00000000 |................| +CHECK-NEXT: 0290: 041C0000 18000000 00000000 00000000 |................| +CHECK-NEXT: 02A0: B41A0000 18000000 00000000 00000000 |................| +CHECK-NEXT: 02B0: 3C1B0000 36000000 00000000 00000000 |<...6...........| +CHECK-NEXT: 02C0: 741B0000 43000000 00000000 00000000 |t...C...........| +CHECK-NEXT: 02D0: BC1B0000 42000000 00000000 00000000 |....B...........| +CHECK-NEXT: 02E0: 0E004D00 59004100 43004300 45004C00 |..M.Y.A.C.C.E.L.| +CHECK-NEXT: 02F0: 45005200 41005400 4F005200 53000600 |E.R.A.T.O.R.S...| +CHECK-NEXT: 0300: 43005500 52005300 4F005200 04004F00 |C.U.R.S.O.R...O.| +CHECK-NEXT: 0310: 4B004100 59000A00 54004500 53005400 |K.A.Y...T.E.S.T.| +CHECK-NEXT: 0320: 44004900 41004C00 4F004700 05002200 |D.I.A.L.O.G...".| +CHECK-NEXT: 0330: 45004100 54002200 0B005300 54005200 |E.A.T."...S.T.R.| +CHECK-NEXT: 0340: 49004E00 47004100 52005200 41005900 |I.N.G.A.R.R.A.Y.| +CHECK-NEXT: 0350: 0A004D00 59005200 45005300 4F005500 |..M.Y.R.E.S.O.U.| +CHECK-NEXT: 0360: 52004300 45000900 52004100 4E004400 |R.C.E...R.A.N.D.| +CHECK-NEXT: 0370: 4F004D00 44004100 54000000 00000500 |O.M.D.A.T.......| +CHECK-NEXT: 0380: 48006500 6C006C00 6F000000 00000000 |H.e.l.l.o.......| +CHECK-NEXT: 0390: 00000000 00000000 00000000 00000000 |................| +CHECK-NEXT: 03A0: 00000000 00000000 00000000 11000300 |................| +CHECK-NEXT: 03B0: E7030000 0D004400 4C040000 82001200 |......D.L.......| +CHECK-NEXT: 03C0: BC010000 28000000 10000000 10000000 |....(...........| +CHECK-NEXT: 03D0: 01001800 00000000 00030000 C40E0000 |................| +CHECK-NEXT: 03E0: C40E0000 00000000 00000000 FFFFFFFF |................| +CHECK-NEXT: 03F0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0400: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0410: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0420: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0430: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0440: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0450: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0460: FF7F7F7F 7C7C7C78 78787575 75FFFFFF |....|||xxxuuu...| +CHECK-NEXT: 0470: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0480: FFFFFFFF FFFFFFFF 979797FF FFFFFFFF |................| +CHECK-NEXT: 0490: FF838383 AAAAAADB DBDB7979 79757575 |..........yyyuuu| +CHECK-NEXT: 04A0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 04B0: FFFFFFFF FFFFFFFF 9C9C9C98 9898FFFF |................| +CHECK-NEXT: 04C0: FF888888 DBDBDBB7 B7B77D7D 7DFFFFFF |..........}}}...| +CHECK-NEXT: 04D0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 04E0: FFFFFFFF FFFFFFFF A0A0A09C 9C9C9393 |................| +CHECK-NEXT: 04F0: 93ADADAD F2F2F284 84848181 81FFFFFF |................| +CHECK-NEXT: 0500: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0510: FFFFFFFF FFFFFFFF A4A4A4D7 D7D79D9D |................| +CHECK-NEXT: 0520: 9DD0D0D0 EEEEEE91 91918D8D 8DFFFFFF |................| +CHECK-NEXT: 0530: FFFFFF81 81817E7E 7EFFFFFF FFFFFFFF |......~~~.......| +CHECK-NEXT: 0540: FFFFFFFF FFFFFFFF A9A9A9F2 F2F2E5E5 |................| +CHECK-NEXT: 0550: E5E2E2E2 95959591 91918D8D 8D898989 |................| +CHECK-NEXT: 0560: 868686FF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0570: FFFFFFFF FFFFFFFF ADADADF2 F2F2E1E1 |................| +CHECK-NEXT: 0580: E1DFDFDF E7E7E7E4 E4E4BBBB BB8E8E8E |................| +CHECK-NEXT: 0590: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 05A0: FFFFFFFF FFFFFFFF B5B5B5F2 F2F2E8E8 |................| +CHECK-NEXT: 05B0: E8E7E7E7 EAEAEAC6 C6C69E9E 9EFFFFFF |................| +CHECK-NEXT: 05C0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 05D0: FFFFFFFF FFFFFFFF B9B9B9F4 F4F4ECEC |................| +CHECK-NEXT: 05E0: ECEDEDED CBCBCBA7 A7A7FFFF FFFFFFFF |................| +CHECK-NEXT: 05F0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0600: FFFFFFFF FFFFFFFF BDBDBDF7 F7F7EFEF |................| +CHECK-NEXT: 0610: EFD0D0D0 AFAFAFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0620: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0630: FFFFFFFF FFFFFFFF C1C1C1F7 F7F7D5D5 |................| +CHECK-NEXT: 0640: D5B6B6B6 FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0650: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0660: FFFFFFFF FFFFFFFF C4C4C4D9 D9D9BEBE |................| +CHECK-NEXT: 0670: BEFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0680: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0690: FFFFFFFF FFFFFFFF C8C8C8C5 C5C5FFFF |................| +CHECK-NEXT: 06A0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 06B0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 06C0: FFFFFFFF FFFFFFFF CBCBCBFF FFFFFFFF |................| +CHECK-NEXT: 06D0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 06E0: FFFFFFFF FFFFFFFF FFFFFFFF 28000000 |............(...| +CHECK-NEXT: 06F0: 10000000 10000000 01001800 00000000 |................| +CHECK-NEXT: 0700: 00030000 C40E0000 C40E0000 00000000 |................| +CHECK-NEXT: 0710: 00000000 FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0720: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0730: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0740: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0750: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0760: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0770: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0780: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0790: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 07A0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 07B0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 07C0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 07D0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 07E0: A0E3A901 B31801B3 1801B318 01B31801 |................| +CHECK-NEXT: 07F0: B31801B3 1861D06F FFFFFFFF FFFFFFFF |.....a.o........| +CHECK-NEXT: 0800: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0810: 01B31800 D7331CDB 49DBF9E2 9BEFAF00 |.....3..I.......| +CHECK-NEXT: 0820: D73300D7 3301B318 FFFFFFFF FFFFFFFF |.3..3...........| +CHECK-NEXT: 0830: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0840: 01B31800 DE55F6FE F9DBFAE7 FEFFFE86 |.....U..........| +CHECK-NEXT: 0850: EFAE00DE 5501B318 FFFFFFFF FFFFFFFF |....U...........| +CHECK-NEXT: 0860: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0870: 01B31800 E676DBFB EC00E676 57EFA5FB |.....v.....vW...| +CHECK-NEXT: 0880: FFFD55EE A401B318 FFFFFFFF FFFFFFFF |..U.............| +CHECK-NEXT: 0890: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 08A0: 01B31800 ED9800ED 9800ED98 00ED9887 |................| +CHECK-NEXT: 08B0: F7CFFEFF FF01B318 FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 08C0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 08D0: 01B31800 F4BA00F4 BA00F4BA 00F4BA00 |................| +CHECK-NEXT: 08E0: F4BA9CFB E401B318 FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 08F0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0900: 01B31800 FBDB00FB DB00FBDB 00FBDB00 |................| +CHECK-NEXT: 0910: FBDB00FB DB01B318 FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0920: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0930: 9FE2A801 B31801B3 1801B318 01B31801 |................| +CHECK-NEXT: 0940: B31801B3 1861D06F FFFFFFFF FFFFFFFF |.....a.o........| +CHECK-NEXT: 0950: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0960: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0970: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0980: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0990: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 09A0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 09B0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 09C0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 09D0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 09E0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 09F0: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0A00: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................| +CHECK-NEXT: 0A10: FFFFFFFF 00000000 00006400 79007500 |..........d.y.u.| +CHECK-NEXT: 0A20: 00000000 65007300 68006100 6C006100 |....e.s.h.a.l.a.| +CHECK-NEXT: 0A30: 00008000 66006B00 61006F00 79006100 |....f.k.a.o.y.a.| +CHECK-NEXT: 0A40: 00000000 0000C080 00000000 02000A00 |................| +CHECK-NEXT: 0A50: 0A00C800 2C010000 00005400 65007300 |....,.....T.e.s.| +CHECK-NEXT: 0A60: 74000000 01000250 00000000 0A000A00 |t......P........| +CHECK-NEXT: 0A70: E6000E00 0100FFFF 82004300 6F006E00 |..........C.o.n.| +CHECK-NEXT: 0A80: 74006900 6E007500 65003A00 00000000 |t.i.n.u.e.:.....| +CHECK-NEXT: 0A90: 00000150 00000000 42008600 A1000D00 |...P....B.......| +CHECK-NEXT: 0AA0: 0200FFFF 80002600 4F004B00 00000000 |......&.O.K.....| +CHECK-NEXT: 0AB0: 00000000 11005800 A4000000 0D004800 |......X.......H.| +CHECK-NEXT: 0AC0: 2E160000 82001200 BC010000 00000000 |................| +CHECK-NEXT: 0AD0: 00006400 66006900 73006800 00000000 |..d.f.i.s.h.....| +CHECK-NEXT: 0AE0: 65007300 61006C00 61006400 00008000 |e.s.a.l.a.d.....| +CHECK-NEXT: 0AF0: 66006400 75006300 6B000000 74686973 |f.d.u.c.k...this| +CHECK-NEXT: 0B00: 20697320 61207573 65722064 6566696E | is a user defin| +CHECK-NEXT: 0B10: 65642072 65736F75 72636500 69742063 |ed resource.it c| +CHECK-NEXT: 0B20: 6F6E7461 696E7320 6D616E79 20737472 |ontains many str| +CHECK-NEXT: 0B30: 696E6773 00000000 00000000 74686973 |ings........this| +CHECK-NEXT: 0B40: 20697320 61207261 6E646F6D 20626974 | is a random bit| +CHECK-NEXT: 0B50: 206F6620 64617461 20746861 74206D65 | of data that me| +CHECK-NEXT: 0B60: 616E7320 6E6F7468 696E6700 A9230E14 |ans nothing..#..| +CHECK-NEXT: 0B70: F4F60000 7A686534 20736869 34207969 |....zhe4 shi4 yi| +CHECK-NEXT: 0B80: 31676534 20737569 326A6931 20646520 |1ge4 sui2ji1 de | +CHECK-NEXT: 0B90: 73687534 6A75342C 207A6865 34207969 |shu4ju4, zhe4 yi| +CHECK-NEXT: 0BA0: 34776569 347A6865 20736865 6E326D65 |4wei4zhe shen2me| +CHECK-NEXT: 0BB0: 00A9230E 14F4F600 00000000 44696573 |..#.........Dies| +CHECK-NEXT: 0BC0: 20697374 2065696E 207A7566 C3A46C6C | ist ein zuf..ll| +CHECK-NEXT: 0BD0: 69676573 20426974 20766F6E 20446174 |iges Bit von Dat| +CHECK-NEXT: 0BE0: 656E2C20 64696520 6E696368 74732062 |en, die nichts b| +CHECK-NEXT: 0BF0: 65646575 74657400 A9230E14 F4F60000 |edeutet..#......| +CHECK-NEXT: 0C00: 00000000 11000300 E7030000 0D004400 |..............D.| +CHECK-NEXT: 0C10: 4C040000 82001200 BC010000 |L...........| +CHECK-NEXT: ) Index: llvm/include/llvm/Object/COFF.h =================================================================== --- llvm/include/llvm/Object/COFF.h +++ llvm/include/llvm/Object/COFF.h @@ -698,6 +698,9 @@ uint32_t getNameOffset() const { return maskTrailingOnes(31) & NameOffset; } + // Even though the PE/COFF spec doesn't mention this, the high bit of a name + // offset is set. + void setNameOffset(uint32_t Offset) { NameOffset = Offset | (1 << 31); } } Identifier; union { support::ulittle32_t DataEntryOffset; Index: llvm/lib/Object/WindowsResource.cpp =================================================================== --- llvm/lib/Object/WindowsResource.cpp +++ llvm/lib/Object/WindowsResource.cpp @@ -616,8 +616,8 @@ for (auto const &Child : StringChildren) { auto *Entry = reinterpret_cast(BufferStart + CurrentOffset); - Entry->Identifier.NameOffset = - StringTableOffsets[Child.second->getStringIndex()]; + Entry->Identifier.setNameOffset( + StringTableOffsets[Child.second->getStringIndex()]); if (Child.second->checkIsDataNode()) { Entry->Offset.DataEntryOffset = NextLevelOffset; NextLevelOffset += sizeof(coff_resource_data_entry);