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

elf: include data sections without references in CollectionSpec #1614

Merged
merged 1 commit into from
Nov 18, 2024

Commits on Nov 18, 2024

  1. elf: include data sections without references in CollectionSpec

    Before VariableSpec, this was a nice optimization since no symbol references
    means no ProgramSpec could ever refer to the map, effectively making it dead
    code. There was a clear benefit to skipping it, although in practice having
    a datasec without references should be quite rare.
    
    With VariableSpec in the picture, the contents of a data section now affect
    things like code generation through bpf2go. If an object contains variable
    declarations like global `volatile const` and all of its references are
    compiled out using compile-time flags, it won't show up in CollectionSpec.Variables
    if its data section was skipped due to having no references.
    
    While migrating the Cilium agent to using VariableSpec, I noticed some
    permutations of build flags caused all references to a particular datasec to
    drop, omitting it from spec.Variables. This patch removes the datasec pruning,
    making the contents of spec.Variables more deterministic in the face of changing
    build-time environments.
    
    For users of NewCollection(), this can create and populate a .rodata map
    unnecessarily, but if it's not referred to by any programs and the Collection
    is closed, the map will be freed.
    
    For users of LoadAndAssign(), the loading behaviour doesn't change since the
    map won't be pulled in for lazy-loading if there aren't any program references.
    
    Signed-off-by: Timo Beckers <[email protected]>
    ti-mo committed Nov 18, 2024
    Configuration menu
    Copy the full SHA
    33112ec View commit details
    Browse the repository at this point in the history