Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unprivileged objNameAllowsDot, return *btf.Var from Variable{Spec}.Type() #1612

Merged
merged 3 commits into from
Nov 14, 2024

Commits on Nov 14, 2024

  1. features: tolerate EPERM in haveObjName and objNameAllowsDot

    When loading ELFs using unprivileged tools or tests, EPERM causes dots and
    underscores to be stripped from MapSpec.Name, causing strange results for
    maps like .rodata.foo.
    
    Also, only consider ErrNotSupported as conclusive and bubble up any other
    errors to the caller. Most callers just check err != nil, but in case
    someone indirectly relies on the sentinel, this should result in more
    accurate output.
    
    Signed-off-by: Timo Beckers <[email protected]>
    ti-mo committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    e9c7104 View commit details
    Browse the repository at this point in the history
  2. variable: return *btf.Var from Variable{Spec}.Type()

    In the initial design, we decided to return the inner type from .Type(), but
    I forgot the outer btf.Var was needed to access decl tags set on the variable.
    
    Returning a *Var here is the most convenient way of accessing the tags, otherwise
    the caller would need to find the underlying map and parse the datasec manually,
    which goes against what this API aims to solve.
    
    Instead of the initial idea of returning a btf.Var as btf.Type, this now returns
    btf.Var directly.
    
    Signed-off-by: Timo Beckers <[email protected]>
    ti-mo committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    f9b9207 View commit details
    Browse the repository at this point in the history
  3. variable: add VariableSpec.MapName() and .Offset() methods

    Cilium's variable inliner needs this information to look up variable contents
    based on the offset specified in the instruction stream, and wants to validate
    that it's pulling data from the right data section.
    
    It makes for a slightly leaky abstraction, but at least something meaningful
    can be accomplished by combining the two, e.g. by accessing the given offset
    in the map.
    
    Signed-off-by: Timo Beckers <[email protected]>
    ti-mo committed Nov 14, 2024
    Configuration menu
    Copy the full SHA
    54a040d View commit details
    Browse the repository at this point in the history