Page MenuHomePhabricator

[BPF] Handling type conversions correctly for CO-RE

Authored by yonghong-song on Aug 1 2019, 4:04 PM.



With newly added debuginfo type
metadata for preserve_array_access_index() intrinsic,
this patch did the following two things:
(1). checking validity before adding a new access index

to the access chain.

(2). calculating access byte offset in IR phase

BPFAbstractMemberAccess instead of when BTF is emitted.

For (1), the metadata provided by all preserve_*_access_index()
intrinsics are used to check whether the to-be-added type
is a proper struct/union member or array element.

For (2), with all available metadata, calculating access byte
offset becomes easier in BPFAbstractMemberAccess IR phase.
This enables us to remove the unnecessary complexity in

New tests are added for

. user explicit casting to array/structure/union
. global variable (or its dereference) as the source of base
. multi demensional arrays
. array access given a base pointer
. cases where we won't generate relocation if we cannot find
  type name.

Diff Detail


Event Timeline

yonghong-song created this revision.Aug 1 2019, 4:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 1 2019, 4:04 PM

use report_fatal_error() to report errors for missing metadata.

ast accepted this revision.Aug 2 2019, 4:04 PM

looks good now. thanks

This revision is now accepted and ready to land.Aug 2 2019, 4:04 PM
This revision was automatically updated to reflect the committed changes.