================
@@ -315,6 +315,14 @@ Address CodeGenFunction::GetAddressOfBaseClass(
     VBase = nullptr; // we no longer have a virtual step
   }
 
+  // A BPF CO-RE relocation is relative to the record that has the field, so
+  // the offset of the base subobject, which may differ in the target, would 
not
+  // be relocated.
+  if (IsInPreservedAIRegion && getTarget().getTriple().isBPF()) {
----------------
tamird wrote:

The rejection needs to track base adjustments on the preserved address path. It 
misses the inverse conversion: for `struct A { int a; }; struct B { int b; }; 
struct D : A, B { int x; };`, `__builtin_preserve_access_index(&static_cast<D 
*>(p)->x)` with `B *p` hardcodes the local `B`-to-`D` adjustment of `-4` in 
`GetAddressOfDerivedClass()`. If the target changes to `D : B, A`, `B` moves to 
offset 0 while `x` stays at offset 8; the `D`-rooted relocation still yields an 
address four bytes short. The same guard also rejects 
`__builtin_preserve_access_index((consume(d), &d->x))` for `D *d` and `void 
consume(A *)`, even though the upcast belongs only to the side-effect call. 
Please reject or relocate base adjustments that contribute to the preserved 
address, while allowing unrelated conversions.

https://github.com/llvm/llvm-project/pull/233715
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to