[llvm] f47a4c0 - [lld] Fixed CodeView GuidAdapter::format to handle GUID bytes in the right order.
Alex Orlov via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 8 18:29:26 PDT 2021
Author: Alex Orlov
Date: 2021-04-09T05:29:14+04:00
New Revision: f47a4c071376c32d970bb26fbfca5a2fb08c164e
URL: https://github.com/llvm/llvm-project/commit/f47a4c071376c32d970bb26fbfca5a2fb08c164e
DIFF: https://github.com/llvm/llvm-project/commit/f47a4c071376c32d970bb26fbfca5a2fb08c164e.diff
LOG: [lld] Fixed CodeView GuidAdapter::format to handle GUID bytes in the right order.
This fixes https://bugs.llvm.org/show_bug.cgi?id=41712 bug.
Reviewed By: aganea
Differential Revision: https://reviews.llvm.org/D99978
Added:
Modified:
lld/test/COFF/Inputs/pdb-type-server-invalid-path.yaml
lld/test/COFF/Inputs/pdb-type-server-missing-2.yaml
lld/test/COFF/Inputs/pdb-type-server-valid-signature.yaml
lld/test/COFF/pdb-type-server-invalid-signature.yaml
lld/test/COFF/pdb-type-server-missing.yaml
lld/test/COFF/pdb-type-server-native-errors.yaml
llvm/lib/DebugInfo/CodeView/Formatters.cpp
llvm/lib/ObjectYAML/CodeViewYAMLTypes.cpp
llvm/test/DebugInfo/PDB/DIA/pdbdump-flags.test
llvm/test/DebugInfo/PDB/Native/pdb-native-summary.test
llvm/test/DebugInfo/PDB/pdbdump-headers.test
llvm/test/DebugInfo/PDB/pdbdump-readwrite.test
llvm/test/DebugInfo/PDB/pdbdump-yaml.test
llvm/test/ObjectYAML/CodeView/sections.yaml
llvm/test/tools/llvm-pdbutil/explain-pdb-stream.test
llvm/test/tools/llvm-pdbutil/stripped.test
Removed:
################################################################################
diff --git a/lld/test/COFF/Inputs/pdb-type-server-invalid-path.yaml b/lld/test/COFF/Inputs/pdb-type-server-invalid-path.yaml
index 9e485ffcecee8..5bcc71e730473 100644
--- a/lld/test/COFF/Inputs/pdb-type-server-invalid-path.yaml
+++ b/lld/test/COFF/Inputs/pdb-type-server-invalid-path.yaml
@@ -68,7 +68,7 @@ sections:
Types:
- Kind: LF_TYPESERVER2
TypeServer2:
- Guid: '{8DABD2A0-28FF-CB43-9BAF-175B77B76414}'
+ Guid: '{A0D2AB8D-FF28-43CB-9BAF-175B77B76414}'
Age: 1
Name: 'c:\some_invalid_path_AABB98765\pdb-
diff -cl.pdb'
- Name: '.text$mn'
diff --git a/lld/test/COFF/Inputs/pdb-type-server-missing-2.yaml b/lld/test/COFF/Inputs/pdb-type-server-missing-2.yaml
index e71bcec22448b..8d9bb81e9ac91 100644
--- a/lld/test/COFF/Inputs/pdb-type-server-missing-2.yaml
+++ b/lld/test/COFF/Inputs/pdb-type-server-missing-2.yaml
@@ -9,7 +9,7 @@ sections:
Types:
- Kind: LF_TYPESERVER2
TypeServer2:
- Guid: '{01DF191B-22BF-6B42-96CE-5258B8329FE5}'
+ Guid: '{1B19DF01-BF22-426B-96CE-5258B8329FE5}'
Age: 18
Name: 'C:\src\llvm-project\build\definitely_not_found_for_sure.pdb'
- Name: '.text$mn'
diff --git a/lld/test/COFF/Inputs/pdb-type-server-valid-signature.yaml b/lld/test/COFF/Inputs/pdb-type-server-valid-signature.yaml
index dd95a3df8893c..c13e27030119f 100644
--- a/lld/test/COFF/Inputs/pdb-type-server-valid-signature.yaml
+++ b/lld/test/COFF/Inputs/pdb-type-server-valid-signature.yaml
@@ -68,7 +68,7 @@ sections:
Types:
- Kind: LF_TYPESERVER2
TypeServer2:
- Guid: '{8DABD2A0-28FF-CB43-9BAF-175B77B76414}'
+ Guid: '{A0D2AB8D-FF28-43CB-9BAF-175B77B76414}'
Age: 18
Name: 'pdb-
diff -cl.pdb'
- Name: '.text$mn'
diff --git a/lld/test/COFF/pdb-type-server-invalid-signature.yaml b/lld/test/COFF/pdb-type-server-invalid-signature.yaml
index de8cb46b2ddc5..45713292cd2b7 100644
--- a/lld/test/COFF/pdb-type-server-invalid-signature.yaml
+++ b/lld/test/COFF/pdb-type-server-invalid-signature.yaml
@@ -95,7 +95,7 @@ sections:
Types:
- Kind: LF_TYPESERVER2
TypeServer2:
- Guid: '{01DF191B-22BF-6B42-96CE-5258B8329FE5}'
+ Guid: '{1B19DF01-BF22-426B-96CE-5258B8329FE5}'
Age: 18
Name: 'pdb-
diff -cl.pdb'
- Name: '.text$mn'
diff --git a/lld/test/COFF/pdb-type-server-missing.yaml b/lld/test/COFF/pdb-type-server-missing.yaml
index 70e638b28b51b..5f7020565ade5 100644
--- a/lld/test/COFF/pdb-type-server-missing.yaml
+++ b/lld/test/COFF/pdb-type-server-missing.yaml
@@ -92,7 +92,7 @@ sections:
Types:
- Kind: LF_TYPESERVER2
TypeServer2:
- Guid: '{01DF191B-22BF-6B42-96CE-5258B8329FE5}'
+ Guid: '{1B19DF01-BF22-426B-96CE-5258B8329FE5}'
Age: 18
Name: 'C:\src\llvm-project\build\definitely_not_found_for_sure.pdb'
- Name: '.text$mn'
diff --git a/lld/test/COFF/pdb-type-server-native-errors.yaml b/lld/test/COFF/pdb-type-server-native-errors.yaml
index bc865411b3ad9..7b5e3938183ab 100644
--- a/lld/test/COFF/pdb-type-server-native-errors.yaml
+++ b/lld/test/COFF/pdb-type-server-native-errors.yaml
@@ -77,7 +77,7 @@ sections:
Types:
- Kind: LF_TYPESERVER2
TypeServer2:
- Guid: '{01DF191B-22BF-6B42-96CE-5258B8329FE5}'
+ Guid: '{1B19DF01-BF22-426B-96CE-5258B8329FE5}'
Age: 18
Name: 'bad-block-size.pdb'
- Name: '.text$mn'
diff --git a/llvm/lib/DebugInfo/CodeView/Formatters.cpp b/llvm/lib/DebugInfo/CodeView/Formatters.cpp
index a7a8c7ff82bf3..3a67f313d3372 100644
--- a/llvm/lib/DebugInfo/CodeView/Formatters.cpp
+++ b/llvm/lib/DebugInfo/CodeView/Formatters.cpp
@@ -24,20 +24,21 @@ GuidAdapter::GuidAdapter(ArrayRef<uint8_t> Guid)
: FormatAdapter(std::move(Guid)) {}
void GuidAdapter::format(raw_ostream &Stream, StringRef Style) {
- static const char *Lookup = "0123456789ABCDEF";
-
assert(Item.size() == 16 && "Expected 16-byte GUID");
- Stream << "{";
- for (int i = 0; i < 16;) {
- uint8_t Byte = Item[i];
- uint8_t HighNibble = (Byte >> 4) & 0xF;
- uint8_t LowNibble = Byte & 0xF;
- Stream << Lookup[HighNibble] << Lookup[LowNibble];
- ++i;
- if (i >= 4 && i <= 10 && i % 2 == 0)
- Stream << "-";
- }
- Stream << "}";
+ struct MSGuid {
+ support::ulittle32_t Data1;
+ support::ulittle16_t Data2;
+ support::ulittle16_t Data3;
+ support::ubig64_t Data4;
+ };
+ const MSGuid *G = reinterpret_cast<const MSGuid *>(Item.data());
+ Stream
+ << '{' << format_hex_no_prefix(G->Data1, sizeof(G->Data1), /*Upper=*/true)
+ << '-' << format_hex_no_prefix(G->Data2, sizeof(G->Data2), /*Upper=*/true)
+ << '-' << format_hex_no_prefix(G->Data3, sizeof(G->Data3), /*Upper=*/true)
+ << '-' << format_hex_no_prefix(G->Data4 >> 48, 2, /*Upper=*/true) << '-'
+ << format_hex_no_prefix(G->Data4 & ((1ULL << 48) - 1), 6, /*Upper=*/true)
+ << '}';
}
raw_ostream &llvm::codeview::operator<<(raw_ostream &OS, const GUID &Guid) {
diff --git a/llvm/lib/ObjectYAML/CodeViewYAMLTypes.cpp b/llvm/lib/ObjectYAML/CodeViewYAMLTypes.cpp
index a5e3ce1e71e88..49b24e21cf60c 100644
--- a/llvm/lib/ObjectYAML/CodeViewYAMLTypes.cpp
+++ b/llvm/lib/ObjectYAML/CodeViewYAMLTypes.cpp
@@ -148,23 +148,28 @@ void ScalarTraits<GUID>::output(const GUID &G, void *, llvm::raw_ostream &OS) {
StringRef ScalarTraits<GUID>::input(StringRef Scalar, void *Ctx, GUID &S) {
if (Scalar.size() != 38)
return "GUID strings are 38 characters long";
- if (Scalar[0] != '{' || Scalar[37] != '}')
+ if (Scalar.front() != '{' || Scalar.back() != '}')
return "GUID is not enclosed in {}";
- if (Scalar[9] != '-' || Scalar[14] != '-' || Scalar[19] != '-' ||
- Scalar[24] != '-')
+ Scalar = Scalar.substr(1, Scalar.size() - 2);
+ SmallVector<StringRef, 6> A;
+ Scalar.split(A, '-', 5);
+ if (A.size() != 5 || Scalar[8] != '-' || Scalar[13] != '-' ||
+ Scalar[18] != '-' || Scalar[23] != '-')
return "GUID sections are not properly delineated with dashes";
-
- uint8_t *OutBuffer = S.Guid;
- for (auto Iter = Scalar.begin(); Iter != Scalar.end();) {
- if (*Iter == '-' || *Iter == '{' || *Iter == '}') {
- ++Iter;
- continue;
- }
- uint8_t Value = (llvm::hexDigitValue(*Iter++) << 4);
- Value |= llvm::hexDigitValue(*Iter++);
- *OutBuffer++ = Value;
- }
-
+ struct MSGuid {
+ support::ulittle32_t Data1;
+ support::ulittle16_t Data2;
+ support::ulittle16_t Data3;
+ support::ubig64_t Data4;
+ };
+ MSGuid G = {};
+ uint64_t D41{}, D42{};
+ if (!to_integer(A[0], G.Data1, 16) || !to_integer(A[1], G.Data2, 16) ||
+ !to_integer(A[2], G.Data3, 16) || !to_integer(A[3], D41, 16) ||
+ !to_integer(A[4], D42, 16))
+ return "GUID contains non hex digits";
+ G.Data4 = (D41 << 48) | D42;
+ ::memcpy(&S, &G, sizeof(GUID));
return "";
}
diff --git a/llvm/test/DebugInfo/PDB/DIA/pdbdump-flags.test b/llvm/test/DebugInfo/PDB/DIA/pdbdump-flags.test
index 02291c9afa9c7..de7f4b24e58c4 100644
--- a/llvm/test/DebugInfo/PDB/DIA/pdbdump-flags.test
+++ b/llvm/test/DebugInfo/PDB/DIA/pdbdump-flags.test
@@ -5,7 +5,7 @@
; Check that neither symbols nor compilands are dumped when neither argument specified.
; NO_ARGS: empty.pdb
-; NO_ARGS: Guid: {0B355641-86A0-A249-896F-9988FAE52FF0}
+; NO_ARGS: Guid: {4156350B-A086-49A2-896F-9988FAE52FF0}
; NO_ARGS: Attributes: HasPrivateSymbols
; NO_ARGS-NOT: ---TYPES---
; NO_ARGS-NOT: ---COMPILANDS---
@@ -14,7 +14,7 @@
; Check that only types are dumped when only -types is specified.
; TYPES: empty.pdb
-; TYPES: Guid: {0B355641-86A0-A249-896F-9988FAE52FF0}
+; TYPES: Guid: {4156350B-A086-49A2-896F-9988FAE52FF0}
; TYPES: Attributes: HasPrivateSymbols
; TYPES: ---TYPES---
; TYPES-NOT: ---COMPILANDS---
@@ -23,7 +23,7 @@
; Check that only compilands are dumped when only -compilands is specified.
; COMPILANDS: empty.pdb
-; COMPILANDS: Guid: {0B355641-86A0-A249-896F-9988FAE52FF0}
+; COMPILANDS: Guid: {4156350B-A086-49A2-896F-9988FAE52FF0}
; COMPILANDS: Attributes: HasPrivateSymbols
; COMPILANDS: ---COMPILANDS---
; COMPILANDS-NOT: ---TYPES---
@@ -32,7 +32,7 @@
; Check that types and compilands are dumped when both arguments are specified.
; MULTIPLE: empty.pdb
-; MULTIPLE: Guid: {0B355641-86A0-A249-896F-9988FAE52FF0}
+; MULTIPLE: Guid: {4156350B-A086-49A2-896F-9988FAE52FF0}
; MULTIPLE: Attributes: HasPrivateSymbols
; MULTIPLE: ---COMPILANDS---
; MULTIPLE: ---TYPES---
diff --git a/llvm/test/DebugInfo/PDB/Native/pdb-native-summary.test b/llvm/test/DebugInfo/PDB/Native/pdb-native-summary.test
index 116d2564fda37..fc7b9235b3e48 100644
--- a/llvm/test/DebugInfo/PDB/Native/pdb-native-summary.test
+++ b/llvm/test/DebugInfo/PDB/Native/pdb-native-summary.test
@@ -6,6 +6,6 @@
; `-native` option produces identical output.
; EMPTY: Size: 102400 bytes
-; EMPTY: Guid: {0B355641-86A0-A249-896F-9988FAE52FF0}
+; EMPTY: Guid: {4156350B-A086-49A2-896F-9988FAE52FF0}
; EMPTY: Age: 1
; EMPTY: Attributes: HasPrivateSymbols
diff --git a/llvm/test/DebugInfo/PDB/pdbdump-headers.test b/llvm/test/DebugInfo/PDB/pdbdump-headers.test
index 2a6c862ac2a42..feef88d33e5cd 100644
--- a/llvm/test/DebugInfo/PDB/pdbdump-headers.test
+++ b/llvm/test/DebugInfo/PDB/pdbdump-headers.test
@@ -12,7 +12,7 @@ ALL-NEXT: Number of blocks: 25
ALL-NEXT: Number of streams: 17
ALL-NEXT: Signature: 1424295906
ALL-NEXT: Age: 1
-ALL-NEXT: GUID: {0B355641-86A0-A249-896F-9988FAE52FF0}
+ALL-NEXT: GUID: {4156350B-A086-49A2-896F-9988FAE52FF0}
ALL-NEXT: Features: 0x1
ALL-NEXT: Has Debug Info: true
ALL-NEXT: Has Types: true
@@ -601,7 +601,7 @@ BIG-NEXT: Number of blocks: 99
BIG-NEXT: Number of streams: 64
BIG-NEXT: Signature: 1461714535
BIG-NEXT: Age: 1
-BIG-NEXT: GUID: {880ECC89-DF81-0B4F-839C-58CBD052E937}
+BIG-NEXT: GUID: {89CC0E88-81DF-4F0B-839C-58CBD052E937}
BIG-NEXT: Features: 0x1
BIG-NEXT: Has Debug Info: true
BIG-NEXT: Has Types: true
diff --git a/llvm/test/DebugInfo/PDB/pdbdump-readwrite.test b/llvm/test/DebugInfo/PDB/pdbdump-readwrite.test
index b3ec3ce4ee6a1..3b7f9b2980dc3 100644
--- a/llvm/test/DebugInfo/PDB/pdbdump-readwrite.test
+++ b/llvm/test/DebugInfo/PDB/pdbdump-readwrite.test
@@ -14,7 +14,7 @@ CHECK-NEXT: Number of blocks:
CHECK-NEXT: Number of streams:
CHECK-NEXT: Signature: 1424295906
CHECK-NEXT: Age: 1
-CHECK-NEXT: GUID: {0B355641-86A0-A249-896F-9988FAE52FF0}
+CHECK-NEXT: GUID: {4156350B-A086-49A2-896F-9988FAE52FF0}
CHECK-NEXT: Features: 0x1
CHECK-NEXT: Has Debug Info: true
CHECK-NEXT: Has Types: true
diff --git a/llvm/test/DebugInfo/PDB/pdbdump-yaml.test b/llvm/test/DebugInfo/PDB/pdbdump-yaml.test
index 0563230cf47c6..3439349db09a3 100644
--- a/llvm/test/DebugInfo/PDB/pdbdump-yaml.test
+++ b/llvm/test/DebugInfo/PDB/pdbdump-yaml.test
@@ -42,7 +42,7 @@
; YAML-NEXT: - '$T0 $ebp = $eip $T0 4 + ^ = $ebp $T0 ^ = $esp $T0 8 + = '
; YAML-NEXT: PdbStream:
; YAML-NEXT: Age: 1
-; YAML-NEXT: Guid: '{0B355641-86A0-A249-896F-9988FAE52FF0}'
+; YAML-NEXT: Guid: '{4156350B-A086-49A2-896F-9988FAE52FF0}'
; YAML-NEXT: Signature: 1424295906
; YAML-NEXT: Features: [ VC110 ]
; YAML-NEXT: Version: VC70
diff --git a/llvm/test/ObjectYAML/CodeView/sections.yaml b/llvm/test/ObjectYAML/CodeView/sections.yaml
index fbdf9bf8625f9..adfe675edd222 100644
--- a/llvm/test/ObjectYAML/CodeView/sections.yaml
+++ b/llvm/test/ObjectYAML/CodeView/sections.yaml
@@ -13,7 +13,7 @@ sections:
Types:
- Kind: LF_TYPESERVER2
TypeServer2:
- Guid: '{01DF191B-22BF-6B42-96CE-5258B8329FE5}'
+ Guid: '{1B19DF01-BF22-426B-96CE-5258B8329FE5}'
Age: 24
Name: 'C:\src\llvm-project\build\vc140.pdb'
- Name: '.debug$H'
@@ -66,7 +66,7 @@ symbols:
# CHECK: Types:
# CHECK: - Kind: LF_TYPESERVER2
# CHECK: TypeServer2:
-# CHECK: Guid: '{01DF191B-22BF-6B42-96CE-5258B8329FE5}'
+# CHECK: Guid: '{1B19DF01-BF22-426B-96CE-5258B8329FE5}'
# CHECK: Age: 24
# CHECK: Name: 'C:\src\llvm-project\build\vc140.pdb'
# CHECK: - Name: '.debug$H'
diff --git a/llvm/test/tools/llvm-pdbutil/explain-pdb-stream.test b/llvm/test/tools/llvm-pdbutil/explain-pdb-stream.test
index 32ec800f8cafb..a55382105a737 100644
--- a/llvm/test/tools/llvm-pdbutil/explain-pdb-stream.test
+++ b/llvm/test/tools/llvm-pdbutil/explain-pdb-stream.test
@@ -39,7 +39,7 @@ CHECK-NEXT: Address is at offset 12/202 of Stream 1 (PDB Stream).
CHECK-NEXT: Within the PDB stream:
CHECK-NEXT: address is at offset 12/28 of the PDB Stream Header.
CHECK-NEXT: which contains the guid of the PDB.
-CHECK-NEXT: The current value is {826BE46E-02ED-7043-9C27-20CCC07E92A7}.
+CHECK-NEXT: The current value is {6EE46B82-ED02-4370-9C27-20CCC07E92A7}.
CHECK: Block:Offset = 11:001C.
CHECK-NEXT: Address is in block 17 (allocated).
diff --git a/llvm/test/tools/llvm-pdbutil/stripped.test b/llvm/test/tools/llvm-pdbutil/stripped.test
index 1d12c9ecfa2d3..d321a098d19de 100644
--- a/llvm/test/tools/llvm-pdbutil/stripped.test
+++ b/llvm/test/tools/llvm-pdbutil/stripped.test
@@ -8,7 +8,7 @@
; CHECK-NEXT: Number of streams: 12
; CHECK-NEXT: Signature: 1541179274
; CHECK-NEXT: Age: 2
-; CHECK-NEXT: GUID: {FF4F9B62-D99A-4647-97A7-22C702B1E053}
+; CHECK-NEXT: GUID: {629B4FFF-9AD9-4746-97A7-22C702B1E053}
; CHECK-NEXT: Features: 0x1
; CHECK-NEXT: Has Debug Info: true
; CHECK-NEXT: Has Types: true
More information about the llvm-commits
mailing list