31 #define HANDLE_BTF_KIND(ID, NAME) "BTF_KIND_" #NAME,
47 : DTy(DTy), NeedsFixup(NeedsFixup),
Name(DTy->
getName()) {
49 case dwarf::DW_TAG_pointer_type:
50 Kind = BTF::BTF_KIND_PTR;
52 case dwarf::DW_TAG_const_type:
53 Kind = BTF::BTF_KIND_CONST;
55 case dwarf::DW_TAG_volatile_type:
56 Kind = BTF::BTF_KIND_VOLATILE;
58 case dwarf::DW_TAG_typedef:
59 Kind = BTF::BTF_KIND_TYPEDEF;
61 case dwarf::DW_TAG_restrict_type:
62 Kind = BTF::BTF_KIND_RESTRICT;
74 Kind = BTF::BTF_KIND_PTR;
86 if (NeedsFixup || !DTy)
90 const DIType *ResolvedType = DTy->getBaseType();
92 assert((
Kind == BTF::BTF_KIND_PTR ||
Kind == BTF::BTF_KIND_CONST ||
93 Kind == BTF::BTF_KIND_VOLATILE) &&
94 "Invalid null basetype");
109 Kind = BTF::BTF_KIND_FWD;
130 case dwarf::DW_ATE_boolean:
133 case dwarf::DW_ATE_signed:
134 case dwarf::DW_ATE_signed_char:
137 case dwarf::DW_ATE_unsigned:
138 case dwarf::DW_ATE_unsigned_char:
145 Kind = BTF::BTF_KIND_INT;
148 IntVal = (BTFEncoding << 24) | OffsetInBits << 16 | SizeInBits;
166 bool IsSigned) : ETy(ETy) {
167 Kind = BTF::BTF_KIND_ENUM;
180 for (
const auto Element : Elements) {
181 const auto *Enum = cast<DIEnumerator>(Element);
187 if (Enum->isUnsigned())
188 Value =
static_cast<uint32_t>(Enum->getValue().getZExtValue());
190 Value =
static_cast<uint32_t>(Enum->getValue().getSExtValue());
192 EnumValues.push_back(BTFEnum);
198 for (
const auto &Enum : EnumValues) {
205 bool IsSigned) : ETy(ETy) {
206 Kind = BTF::BTF_KIND_ENUM64;
219 for (
const auto Element : Elements) {
220 const auto *Enum = cast<DIEnumerator>(Element);
225 if (Enum->isUnsigned())
226 Value =
static_cast<uint64_t>(Enum->getValue().getZExtValue());
228 Value =
static_cast<uint64_t>(Enum->getValue().getSExtValue());
231 EnumValues.push_back(BTFEnum);
237 for (
const auto &Enum : EnumValues) {
247 Kind = BTF::BTF_KIND_ARRAY;
253 ArrayInfo.
Nelems = NumElems;
279 : STy(STy), HasBitField(HasBitField) {
280 Kind = IsStruct ? BTF::BTF_KIND_STRUCT : BTF::BTF_KIND_UNION;
294 for (
const auto *Element : Elements) {
296 const auto *DDTy = cast<DIDerivedType>(Element);
300 uint8_t BitFieldSize = DDTy->isBitField() ? DDTy->getSizeInBits() : 0;
301 BTFMember.
Offset = BitFieldSize << 24 | DDTy->getOffsetInBits();
303 BTFMember.
Offset = DDTy->getOffsetInBits();
305 const auto *BaseTy = DDTy->getBaseType();
307 Members.push_back(BTFMember);
313 for (
const auto &Member : Members) {
330 const std::unordered_map<uint32_t, StringRef> &FuncArgNames)
331 : STy(STy), FuncArgNames(FuncArgNames) {
332 Kind = BTF::BTF_KIND_FUNC_PROTO;
342 auto RetType = Elements[0];
348 for (
unsigned I = 1,
N = Elements.
size();
I <
N; ++
I) {
350 auto Element = Elements[
I];
358 Parameters.push_back(
Param);
364 for (
const auto &
Param : Parameters) {
373 Kind = BTF::BTF_KIND_FUNC;
390 Kind = BTF::BTF_KIND_VAR;
407 Kind = BTF::BTF_KIND_DATASEC;
420 for (
const auto &V : Vars) {
422 Asm->emitLabelReference(std::get<1>(V), 4);
429 Kind = BTF::BTF_KIND_FLOAT;
445 Kind = BTF::BTF_KIND_DECL_TAG;
465 : DTy(nullptr),
Tag(
Tag) {
466 Kind = BTF::BTF_KIND_TYPE_TAG;
473 Kind = BTF::BTF_KIND_TYPE_TAG;
483 const DIType *ResolvedType = DTy->getBaseType();
493 for (
auto &OffsetM : OffsetToIdMap) {
494 if (Table[OffsetM.second] ==
S)
495 return OffsetM.first;
499 OffsetToIdMap[
Offset] = Table.size();
500 Table.push_back(std::string(
S));
501 Size +=
S.size() + 1;
507 LineInfoGenerated(
false), SecNameOff(0), ArrayIndexTypeId(0),
508 MapDefNotCollected(
true) {
512 uint32_t BTFDebug::addType(std::unique_ptr<BTFTypeBase> TypeEntry,
514 TypeEntry->setId(TypeEntries.size() + 1);
517 TypeEntries.push_back(
std::move(TypeEntry));
521 uint32_t BTFDebug::addType(std::unique_ptr<BTFTypeBase> TypeEntry) {
522 TypeEntry->setId(TypeEntries.size() + 1);
524 TypeEntries.push_back(
std::move(TypeEntry));
531 std::unique_ptr<BTFTypeBase> TypeEntry;
533 case dwarf::DW_ATE_boolean:
534 case dwarf::DW_ATE_signed:
535 case dwarf::DW_ATE_signed_char:
536 case dwarf::DW_ATE_unsigned:
537 case dwarf::DW_ATE_unsigned_char:
540 TypeEntry = std::make_unique<BTFTypeInt>(
543 case dwarf::DW_ATE_float:
551 TypeId = addType(
std::move(TypeEntry), BTy);
555 void BTFDebug::visitSubroutineType(
557 const std::unordered_map<uint32_t, StringRef> &FuncArgNames,
568 auto TypeEntry = std::make_unique<BTFTypeFuncProto>(STy, VLen, FuncArgNames);
572 TypeId = addType(
std::move(TypeEntry), STy);
575 for (
const auto Element : Elements) {
576 visitTypeEntry(Element);
580 void BTFDebug::processDeclAnnotations(DINodeArray
Annotations,
587 const MDNode *MD = cast<MDNode>(Annotation);
589 if (!
Name->getString().equals(
"btf_decl_tag"))
593 auto TypeEntry = std::make_unique<BTFTypeDeclTag>(BaseTypeId, ComponentIdx,
600 int BTFDebug::genBTFTypeTags(
const DIDerivedType *DTy,
int BaseTypeId) {
602 DINodeArray Annots = DTy->getAnnotations();
609 if (!
Name->getString().equals(
"btf_type_tag"))
611 MDStrs.push_back(cast<MDString>(MD->
getOperand(1)));
615 if (MDStrs.size() == 0)
623 std::unique_ptr<BTFTypeTypeTag> TypeEntry;
626 std::make_unique<BTFTypeTypeTag>(BaseTypeId, MDStrs[0]->getString());
628 TypeEntry = std::make_unique<BTFTypeTypeTag>(DTy, MDStrs[0]->getString());
629 TmpTypeId = addType(
std::move(TypeEntry));
631 for (
unsigned I = 1;
I < MDStrs.size();
I++) {
633 TypeEntry = std::make_unique<BTFTypeTypeTag>(TmpTypeId,
Value->getString());
634 TmpTypeId = addType(
std::move(TypeEntry));
640 void BTFDebug::visitStructType(
const DICompositeType *CTy,
bool IsStruct,
648 bool HasBitField =
false;
649 for (
const auto *Element : Elements) {
650 auto E = cast<DIDerivedType>(Element);
651 if (
E->isBitField()) {
658 std::make_unique<BTFTypeStruct>(CTy, IsStruct, HasBitField, VLen);
659 StructTypes.push_back(TypeEntry.get());
660 TypeId = addType(
std::move(TypeEntry), CTy);
667 for (
const auto *Element : Elements) {
668 const auto Elem = cast<DIDerivedType>(Element);
669 visitTypeEntry(Elem);
670 processDeclAnnotations(Elem->getAnnotations(), TypeId, FieldNo);
679 visitTypeEntry(ElemType, ElemTypeId,
false,
false);
683 for (
int I = Elements.size() - 1;
I >= 0; --
I) {
684 if (
auto *Element = dyn_cast_or_null<DINode>(Elements[
I]))
685 if (Element->getTag() == dwarf::DW_TAG_subrange_type) {
686 const DISubrange *SR = cast<DISubrange>(Element);
693 std::make_unique<BTFTypeArray>(ElemTypeId,
694 Count >= 0 ? Count : 0);
696 ElemTypeId = addType(
std::move(TypeEntry), CTy);
698 ElemTypeId = addType(
std::move(TypeEntry));
707 if (!ArrayIndexTypeId) {
708 auto TypeEntry = std::make_unique<BTFTypeInt>(dwarf::DW_ATE_unsigned, 32,
709 0,
"__ARRAY_SIZE_TYPE__");
710 ArrayIndexTypeId = addType(
std::move(TypeEntry));
720 bool IsSigned =
false;
721 unsigned NumBits = 32;
725 const auto *BTy = cast<DIBasicType>(CTy->
getBaseType());
726 IsSigned = BTy->
getEncoding() == dwarf::DW_ATE_signed ||
732 auto TypeEntry = std::make_unique<BTFTypeEnum>(CTy, VLen, IsSigned);
733 TypeId = addType(
std::move(TypeEntry), CTy);
736 auto TypeEntry = std::make_unique<BTFTypeEnum64>(CTy, VLen, IsSigned);
737 TypeId = addType(
std::move(TypeEntry), CTy);
743 void BTFDebug::visitFwdDeclType(
const DICompositeType *CTy,
bool IsUnion,
745 auto TypeEntry = std::make_unique<BTFTypeFwd>(CTy->
getName(), IsUnion);
746 TypeId = addType(
std::move(TypeEntry), CTy);
753 if (
Tag == dwarf::DW_TAG_structure_type ||
Tag == dwarf::DW_TAG_union_type) {
756 visitFwdDeclType(CTy,
Tag == dwarf::DW_TAG_union_type, TypeId);
758 visitStructType(CTy,
Tag == dwarf::DW_TAG_structure_type, TypeId);
759 }
else if (
Tag == dwarf::DW_TAG_array_type)
760 visitArrayType(CTy, TypeId);
761 else if (
Tag == dwarf::DW_TAG_enumeration_type)
762 visitEnumType(CTy, TypeId);
767 bool CheckPointer,
bool SeenPointer) {
772 if (CheckPointer && !SeenPointer) {
773 SeenPointer =
Tag == dwarf::DW_TAG_pointer_type;
776 if (CheckPointer && SeenPointer) {
779 if (
const auto *CTy = dyn_cast<DICompositeType>(
Base)) {
780 auto CTag = CTy->
getTag();
781 if ((CTag == dwarf::DW_TAG_structure_type ||
782 CTag == dwarf::DW_TAG_union_type) &&
787 auto TypeEntry = std::make_unique<BTFTypeDerived>(DTy,
Tag,
true);
788 auto &
Fixup = FixupDerivedTypes[CTy];
789 Fixup.push_back(std::make_pair(DTy, TypeEntry.get()));
790 TypeId = addType(
std::move(TypeEntry), DTy);
797 if (
Tag == dwarf::DW_TAG_pointer_type) {
798 int TmpTypeId = genBTFTypeTags(DTy, -1);
799 if (TmpTypeId >= 0) {
801 std::make_unique<BTFTypeDerived>(TmpTypeId,
Tag, DTy->
getName());
802 TypeId = addType(
std::move(TypeDEntry), DTy);
804 auto TypeEntry = std::make_unique<BTFTypeDerived>(DTy,
Tag,
false);
805 TypeId = addType(
std::move(TypeEntry), DTy);
807 }
else if (
Tag == dwarf::DW_TAG_typedef ||
Tag == dwarf::DW_TAG_const_type ||
808 Tag == dwarf::DW_TAG_volatile_type ||
809 Tag == dwarf::DW_TAG_restrict_type) {
810 auto TypeEntry = std::make_unique<BTFTypeDerived>(DTy,
Tag,
false);
811 TypeId = addType(
std::move(TypeEntry), DTy);
812 if (
Tag == dwarf::DW_TAG_typedef)
813 processDeclAnnotations(DTy->getAnnotations(), TypeId, -1);
814 }
else if (
Tag != dwarf::DW_TAG_member) {
821 if (
Tag == dwarf::DW_TAG_member)
822 visitTypeEntry(DTy->getBaseType(), TempTypeId,
true,
false);
824 visitTypeEntry(DTy->getBaseType(), TempTypeId, CheckPointer, SeenPointer);
828 bool CheckPointer,
bool SeenPointer) {
829 if (!Ty || DIToIdMap.find(Ty) != DIToIdMap.end()) {
830 TypeId = DIToIdMap[Ty];
861 if (Ty && (!CheckPointer || !SeenPointer)) {
862 if (
const auto *DTy = dyn_cast<DIDerivedType>(Ty)) {
864 const DIType *BaseTy = DTy->getBaseType();
868 if (DIToIdMap.find(BaseTy) != DIToIdMap.end()) {
869 DTy = dyn_cast<DIDerivedType>(BaseTy);
872 visitTypeEntry(BaseTy, TmpTypeId, CheckPointer, SeenPointer);
882 if (
const auto *BTy = dyn_cast<DIBasicType>(Ty))
883 visitBasicType(BTy, TypeId);
884 else if (
const auto *STy = dyn_cast<DISubroutineType>(Ty))
885 visitSubroutineType(STy,
false, std::unordered_map<uint32_t, StringRef>(),
887 else if (
const auto *CTy = dyn_cast<DICompositeType>(Ty))
888 visitCompositeType(CTy, TypeId);
889 else if (
const auto *DTy = dyn_cast<DIDerivedType>(Ty))
890 visitDerivedType(DTy, TypeId, CheckPointer, SeenPointer);
895 void BTFDebug::visitTypeEntry(
const DIType *Ty) {
897 visitTypeEntry(Ty, TypeId,
false,
false);
900 void BTFDebug::visitMapDefType(
const DIType *Ty,
uint32_t &TypeId) {
901 if (!Ty || DIToIdMap.find(Ty) != DIToIdMap.end()) {
902 TypeId = DIToIdMap[Ty];
907 const DIType *OrigTy = Ty;
908 while (
auto *DTy = dyn_cast<DIDerivedType>(Ty)) {
910 if (
Tag != dwarf::DW_TAG_typedef &&
Tag != dwarf::DW_TAG_const_type &&
911 Tag != dwarf::DW_TAG_volatile_type &&
912 Tag != dwarf::DW_TAG_restrict_type)
914 Ty = DTy->getBaseType();
917 const auto *CTy = dyn_cast<DICompositeType>(Ty);
927 for (
const auto *Element : Elements) {
928 const auto *MemberType = cast<DIDerivedType>(Element);
929 visitTypeEntry(MemberType->getBaseType());
933 visitTypeEntry(OrigTy, TypeId,
false,
false);
937 std::string BTFDebug::populateFileContent(
const DISubprogram *SP) {
939 std::string FileName;
941 if (!
File->getFilename().startswith(
"/") &&
File->getDirectory().size())
942 FileName =
File->getDirectory().str() +
"/" +
File->getFilename().str();
944 FileName = std::string(
File->getFilename());
947 if (FileContent.
find(FileName) != FileContent.
end())
950 std::vector<std::string>
Content;
954 std::unique_ptr<MemoryBuffer> Buf;
958 else if (
ErrorOr<std::unique_ptr<MemoryBuffer>> BufOrErr =
965 FileContent[FileName] =
Content;
971 std::string FileName = populateFileContent(SP);
977 if (Line < FileContent[FileName].
size())
983 LineInfoTable[SecNameOff].push_back(LineInfo);
986 void BTFDebug::emitCommonHeader() {
993 void BTFDebug::emitBTFSection() {
995 if (!TypeEntries.size() && StringTable.
getSize() == 1)
1008 for (
const auto &TypeEntry : TypeEntries)
1009 TypeLen += TypeEntry->getSize();
1010 StrLen = StringTable.
getSize();
1018 for (
const auto &TypeEntry : TypeEntries)
1019 TypeEntry->emitType(OS);
1023 for (
const auto &
S : StringTable.
getTable()) {
1027 StringOffset +=
S.size() + 1;
1031 void BTFDebug::emitBTFExtSection() {
1034 if (!FuncInfoTable.size() && !LineInfoTable.size() &&
1035 !FieldRelocTable.size())
1051 for (
const auto &FuncSec : FuncInfoTable) {
1055 for (
const auto &LineSec : LineInfoTable) {
1059 for (
const auto &FieldRelocSec : FieldRelocTable) {
1077 for (
const auto &FuncSec : FuncInfoTable) {
1078 OS.
AddComment(
"FuncInfo section string offset=" +
1082 for (
const auto &FuncInfo : FuncSec.second) {
1091 for (
const auto &LineSec : LineInfoTable) {
1092 OS.
AddComment(
"LineInfo section string offset=" +
1096 for (
const auto &LineInfo : LineSec.second) {
1107 if (FieldRelocLen) {
1110 for (
const auto &FieldRelocSec : FieldRelocTable) {
1111 OS.
AddComment(
"Field reloc section string offset=" +
1114 OS.
emitInt32(FieldRelocSec.second.size());
1115 for (
const auto &FieldRelocInfo : FieldRelocSec.second) {
1118 OS.
emitInt32(FieldRelocInfo.OffsetNameOff);
1127 auto *Unit = SP->getUnit();
1130 SkipInstruction =
true;
1133 SkipInstruction =
false;
1154 if (MapDefNotCollected) {
1155 processGlobals(
true);
1156 MapDefNotCollected =
false;
1162 std::unordered_map<uint32_t, StringRef> FuncArgNames;
1163 for (
const DINode *DN : SP->getRetainedNodes()) {
1164 if (
const auto *DV = dyn_cast<DILocalVariable>(DN)) {
1168 visitTypeEntry(DV->getType());
1169 FuncArgNames[
Arg] = DV->getName();
1176 visitSubroutineType(SP->getType(),
true, FuncArgNames, ProtoTypeId);
1180 auto FuncTypeEntry =
1181 std::make_unique<BTFTypeFunc>(SP->
getName(), ProtoTypeId,
Scope);
1185 for (
const DINode *DN : SP->getRetainedNodes()) {
1186 if (
const auto *DV = dyn_cast<DILocalVariable>(DN)) {
1189 processDeclAnnotations(DV->getAnnotations(), FuncTypeId,
Arg - 1);
1193 processDeclAnnotations(SP->getAnnotations(), FuncTypeId, -1);
1195 for (
const auto &TypeEntry : TypeEntries)
1196 TypeEntry->completeType(*
this);
1201 FuncInfo.
Label = FuncLabel;
1202 FuncInfo.
TypeId = FuncTypeId;
1206 assert(SectionELF &&
"Null section for Function Label");
1211 FuncInfoTable[SecNameOff].push_back(FuncInfo);
1215 SkipInstruction =
false;
1216 LineInfoGenerated =
false;
1222 unsigned BTFDebug::populateType(
const DIType *Ty) {
1224 visitTypeEntry(Ty,
Id,
false,
false);
1225 for (
const auto &TypeEntry : TypeEntries)
1226 TypeEntry->completeType(*
this);
1231 void BTFDebug::generatePatchImmReloc(
const MCSymbol *ORSym,
uint32_t RootId,
1234 FieldReloc.
Label = ORSym;
1235 FieldReloc.
TypeID = RootId;
1241 size_t SecondColon = AccessPattern.
find_first_of(
':', FirstColon + 1);
1244 SecondColon - FirstColon);
1246 FirstDollar - SecondColon);
1249 FieldReloc.
RelocKind = std::stoull(std::string(RelocKindStr));
1250 PatchImms[GVar] = std::make_pair(std::stoll(std::string(PatchImmStr)),
1255 FieldReloc.
RelocKind = std::stoull(std::string(RelocStr));
1256 PatchImms[GVar] = std::make_pair(RootId, FieldReloc.
RelocKind);
1258 FieldRelocTable[SecNameOff].push_back(FieldReloc);
1265 auto *GVar = dyn_cast<GlobalVariable>(GVal);
1268 processFuncPrototypes(dyn_cast<Function>(GVal));
1280 uint32_t RootId = populateType(dyn_cast<DIType>(MDN));
1281 generatePatchImmReloc(ORSym, RootId, GVar,
1289 if (SkipInstruction ||
MI->isMetaInstruction() ||
1293 if (
MI->isInlineAsm()) {
1295 unsigned NumDefs = 0;
1296 for (;
MI->getOperand(NumDefs).
isReg() &&
MI->getOperand(NumDefs).isDef();
1301 const char *AsmStr =
MI->getOperand(NumDefs).getSymbolName();
1306 if (
MI->getOpcode() == BPF::LD_imm64) {
1321 processGlobalValue(
MI->getOperand(1));
1322 }
else if (
MI->getOpcode() == BPF::CORE_MEM ||
1323 MI->getOpcode() == BPF::CORE_ALU32_MEM ||
1324 MI->getOpcode() == BPF::CORE_SHIFT) {
1326 processGlobalValue(
MI->getOperand(3));
1327 }
else if (
MI->getOpcode() == BPF::JAL) {
1331 processFuncPrototypes(dyn_cast<Function>(MO.
getGlobal()));
1344 if (LineInfoGenerated ==
false) {
1345 auto *
S =
MI->getMF()->getFunction().getSubprogram();
1347 constructLineInfo(
S, FuncLabel,
S->getLine(), 0);
1348 LineInfoGenerated =
true;
1359 auto SP =
DL.get()->getScope()->getSubprogram();
1360 constructLineInfo(SP, LineSym,
DL.getLine(),
DL.getCol());
1362 LineInfoGenerated =
true;
1366 void BTFDebug::processGlobals(
bool ProcessingMapDef) {
1372 if (Global.hasSection()) {
1373 SecName = Global.getSection();
1374 }
else if (Global.hasInitializer()) {
1376 if (Global.isConstant())
1377 SecName =
".rodata";
1379 SecName = Global.getInitializer()->isZeroValue() ?
".bss" :
".data";
1382 if (ProcessingMapDef != SecName.
startswith(
".maps"))
1388 if (SecName ==
".rodata" &&
Global.hasPrivateLinkage() &&
1389 DataSecEntries.find(std::string(SecName)) == DataSecEntries.end()) {
1394 DataSecEntries[std::string(SecName)] =
1395 std::make_unique<BTFKindDataSec>(
Asm, std::string(SecName));
1400 Global.getDebugInfo(GVs);
1403 if (GVs.size() == 0)
1408 for (
auto *GVE : GVs) {
1411 visitMapDefType(
DIGlobal->getType(), GVTypeId);
1413 visitTypeEntry(
DIGlobal->getType(), GVTypeId,
false,
false);
1435 }
else if (
Global.hasInitializer()) {
1442 std::make_unique<BTFKindVar>(
Global.getName(), GVTypeId, GVarInfo);
1445 processDeclAnnotations(
DIGlobal->getAnnotations(), VarId, -1);
1448 if (SecName.
empty())
1452 if (DataSecEntries.find(std::string(SecName)) == DataSecEntries.end()) {
1453 DataSecEntries[std::string(SecName)] =
1454 std::make_unique<BTFKindDataSec>(
Asm, std::string(SecName));
1461 DataSecEntries[std::string(SecName)]->addDataSecEntry(VarId,
1468 if (
MI->getOpcode() == BPF::LD_imm64) {
1472 auto *GVar = dyn_cast<GlobalVariable>(GVal);
1479 Imm = PatchImms[GVar].first;
1480 Reloc = PatchImms[GVar].second;
1497 }
else if (
MI->getOpcode() == BPF::CORE_MEM ||
1498 MI->getOpcode() == BPF::CORE_ALU32_MEM ||
1499 MI->getOpcode() == BPF::CORE_SHIFT) {
1503 auto *GVar = dyn_cast<GlobalVariable>(GVal);
1507 if (
MI->getOperand(0).isImm())
1520 void BTFDebug::processFuncPrototypes(
const Function *
F) {
1525 if (!SP || SP->isDefinition())
1529 if (!ProtoFunctions.insert(
F).second)
1533 const std::unordered_map<uint32_t, StringRef> FuncArgNames;
1534 visitSubroutineType(SP->getType(),
false, FuncArgNames, ProtoTypeId);
1537 auto FuncTypeEntry =
1538 std::make_unique<BTFTypeFunc>(SP->
getName(), ProtoTypeId,
Scope);
1541 processDeclAnnotations(SP->getAnnotations(),
FuncId, -1);
1543 if (
F->hasSection()) {
1546 if (DataSecEntries.find(std::string(SecName)) == DataSecEntries.end()) {
1547 DataSecEntries[std::string(SecName)] =
1548 std::make_unique<BTFKindDataSec>(
Asm, std::string(SecName));
1552 DataSecEntries[std::string(SecName)]->addDataSecEntry(
FuncId,
1559 if (MapDefNotCollected) {
1560 processGlobals(
true);
1561 MapDefNotCollected =
false;
1565 processGlobals(
false);
1567 for (
auto &DataSec : DataSecEntries)
1571 for (
auto &
Fixup : FixupDerivedTypes) {
1574 bool IsUnion = CTy->
getTag() == dwarf::DW_TAG_union_type;
1585 if (StructTypeId == 0) {
1586 auto FwdTypeEntry = std::make_unique<BTFTypeFwd>(
TypeName, IsUnion);
1587 StructTypeId = addType(
std::move(FwdTypeEntry));
1590 for (
auto &TypeInfo :
Fixup.second) {
1594 int TmpTypeId = genBTFTypeTags(DTy, StructTypeId);
1603 for (
const auto &TypeEntry : TypeEntries)
1604 TypeEntry->completeType(*
this);
1608 emitBTFExtSection();