Merge remote-tracking branch

'origin/GP-4822_ghizard_PDB_U_add_char8_t_primitive_types' (#6744)
This commit is contained in:
Ryan Kurtz 2024-08-12 06:35:17 -04:00
commit 4ac6cf5206
3 changed files with 110 additions and 6 deletions

View File

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -483,6 +483,51 @@ public class PrimitiveMsType extends AbstractMsType {
typeSize = 16;
break;
//=======================================
// 8-bit char8_t type from C++20 standard
// Note that std::is_same_v<unsigned char, char8_t> is suppose to return false
//=======================================
// char8_t
case 0x007c:
typeString = "T_CHAR8";
typeSize = 1;
break;
// 16-bit pointer to a char8_t
case 0x017c:
typeString = "T_PCHAR8";
typeSize = 2;
break;
// 16:16 far pointer to a char8_t
case 0x027c:
typeString = "T_PFCHAR8";
typeSize = 4;
break;
// 16:16 huge pointer to a char8_t
case 0x037c:
typeString = "T_PHCHAR8";
typeSize = 4;
break;
// 32-bit pointer to a char8_t
case 0x047c:
typeString = "T_32PCHAR8";
typeSize = 4;
break;
// 16:32 pointer to a char8_t
case 0x057c:
typeString = "T_32PFCHAR8";
typeSize = 6;
break;
// 64-bit pointer to a char8_t
case 0x067c:
typeString = "T_64PCHAR8";
typeSize = 8;
break;
// 128-bit near pointer to a char8_t (LLVM doc on 0x0700)
case 0x077c:
typeString = "T_128PCHAR8";
typeSize = 16;
break;
//=======================================
// 8-bit int types
//=======================================

View File

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -39,7 +39,9 @@ public class PdbPrimitiveTypeApplicator {
private DataType voidGhidraPrimitive = null;
private DataType charGhidraPrimitive = null;
private DataType signedCharGhidraPrimitive = null;
// Note that std::is_same_v<unsigned char, char8_t> is suppose to return false
private DataType unsignedCharGhidraPrimitive = null;
private DataType char8GhidraPrimitive = null;
//private Map<Integer, DataType> booleanGhidraPrimitives = new HashMap<>();
private Map<Integer, DataType> integralGhidraPrimitives = new HashMap<>();
@ -108,6 +110,19 @@ public class PdbPrimitiveTypeApplicator {
return unsignedCharGhidraPrimitive;
}
// 8-bit char8_t type from C++20 standard
// Note that std::is_same_v<unsigned char, char8_t> is suppose to return false
// So we are creating and storing off a separate type here. Whether ghidra thinks they are
// the same or not is up to the type system or up to our changing what we do in these two
// methods (the one above and this one). If we care to make them different, then do it here.
DataType getChar8Type() {
if (char8GhidraPrimitive == null) {
DataType dataType = new UnsignedCharDataType(getDataTypeManager());
char8GhidraPrimitive = resolve(dataType);
}
return char8GhidraPrimitive;
}
DataType getUnicode16Type() {
// For now, we are returning WideChar16 for Unicode16.
return new WideChar16DataType(getDataTypeManager());

View File

@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -426,6 +426,50 @@ public class PrimitiveTypeApplier extends MsDataTypeApplier {
primitiveApplicator.getUnicode32Type());
break;
//=======================================
// 8-bit char8_t type from C++20 standard
// Note that std::is_same_v<unsigned char, char8_t> is suppose to return false
//=======================================
// char8_t
case 0x007c:
primitiveDataType = primitiveApplicator.getChar8Type();
break;
// 16-bit pointer to a char8_t
case 0x017c:
primitiveDataType = primitiveApplicator.get16NearPointerType(type,
primitiveApplicator.getChar8Type());
break;
// 16:16 far pointer to a char8_t
case 0x027c:
primitiveDataType = primitiveApplicator.get1616FarPointerType(type,
primitiveApplicator.getChar8Type());
break;
// 16:16 huge pointer to a char8_t
case 0x037c:
primitiveDataType = primitiveApplicator.get1616HugePointerType(type,
primitiveApplicator.getChar8Type());
break;
// 32-bit pointer to a char8_t
case 0x047c:
primitiveDataType = primitiveApplicator.get32PointerType(type,
primitiveApplicator.getChar8Type());
break;
// 16:32 pointer to a char8_t
case 0x057c:
primitiveDataType = primitiveApplicator.get1632PointerType(type,
primitiveApplicator.getChar8Type());
break;
// 64-bit pointer to a char8_t
case 0x067c:
primitiveDataType = primitiveApplicator.get64PointerType(type,
primitiveApplicator.getChar8Type());
break;
// 128-bit near pointer to a char8_t (LLVM doc on 0x0700)
case 0x077c:
primitiveDataType = primitiveApplicator.get128PointerType(type,
primitiveApplicator.getChar8Type());
break;
//=======================================
// 8-bit int types
//=======================================