[PATCH] D73902: [BPF] handle typedef of struct/union for CO-RE relocations

Yonghong Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 3 09:47:26 PST 2020


yonghong-song marked 2 inline comments as done.
yonghong-song added inline comments.


================
Comment at: llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp:715
   // Get type name and calculate the first index.
   // We only want to get type name from structure or union.
   // If user wants a relocation like
----------------
anakryiko wrote:
> this comment won't be accurate anymore? should it be updated to include typedef?
Yes, this needs to updated.


================
Comment at: llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp:732
 
-    DIType *Ty = stripQualifiers(cast<DIType>(CInfo.Metadata));
+    DIType *PossibleTypeDef = stripQualifiers(cast<DIType>(CInfo.Metadata),
+                                              false);
----------------
anakryiko wrote:
> I wonder if capturing typedef always is a better approach, even if underlying struct/union is named? If that causes problems due to typedef name not being found, we can always teach libbpf to treat typedef as an alias and try to find candidate types first using typedef name, if that fails - using underlying struct name? WDYT?
Yes, we can do this. This probably will give libbpf more information about what is going on, i.e., user actually use type with typedef to access variable instead of the structure (even with explicit names). Not sure how useful this information will be used. But it should not hurt.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73902/new/

https://reviews.llvm.org/D73902





More information about the llvm-commits mailing list