Page MenuHomePhabricator

[BPF] use base lvalue type for preserve_{struct,union}_access_index metadata

Authored by yonghong-song on Feb 3 2020, 8:53 AM.



Linux commit

uses "#pragma clang attribute push (attribute((preserve_access_index)),

apply_to = record)"

to apply CO-RE relocations to all records including the following pattern:

#pragma clang attribute push (__attribute__((preserve_access_index)), apply_to = record)
typedef struct {
  int a;
} __t;
#pragma clang attribute pop 
int test(__t *arg) { return arg->a; }

The current approach to use struct type in the relocation record will
result in an anonymous struct, which make later type matching difficult

in bpf loader. In fact, current BPF backend will fail the above program

with assertion:

clang: ../lib/Target/BPF/BPFAbstractMemberAccess.cpp:796: ... 
   Assertion `TypeName.size()' failed.

The patch use the base lvalue type for the "base" value to annotate
preservee_{struct,union}_access_index intrinsics. In the above example,
the type will be "__t" which preserved the type name.

Diff Detail

Event Timeline

yonghong-song created this revision.Feb 3 2020, 8:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 3 2020, 8:53 AM
This revision is now accepted and ready to land.Feb 3 2020, 9:58 AM
ast accepted this revision.Feb 3 2020, 11:00 AM
This revision was automatically updated to reflect the committed changes.