Skip to content

Conversation

@puwun
Copy link

@puwun puwun commented Jan 19, 2026

Adds infrastructure to test loading of ELF objects compiled without BTF information, verifying the fix from #1807

Changes:

  • Added testdata/loader_nobtf.c using legacy map definitions.
  • Updated Makefile to compile this new test data with -g0 (no BTF).
  • Added TestLoadCollectionSpecWithoutBTF to verify successful parsing when spec.Types is nil.

Fixes: #1810

@puwun puwun requested a review from a team as a code owner January 19, 2026 07:55
@ti-mo
Copy link
Collaborator

ti-mo commented Jan 28, 2026

@puwun Thanks for picking this up! After looking at this for a bit, I think it would be preferable to reuse the existing loader.c as much as possible to increase coverage. I suggest the following:

  • move BTF map definitions to a new loader_maps_btf.h
  • create a new loader_maps_bpf.h with equivalent bpf_map_def-based definitions, ignoring {bpf,btf}_decl_map since their purpose is testing decl tags on maps, which doesn't exist pre-BTF
  • #ifndef __NOBTF__, #include "loader_maps_btf.h", #else, #include "loader_maps_bpf.h"
  • build loader.c twice, additionally specifying -D__NOBTF__ along with the -g0 flag
  • Add a subtest to TestLoadCollectionSpec for the no-btf version. You'll want to do a similar thing with the CollectionSpec under test where you populate a part of CollectionSpec.Maps in the BTF-enabled subtest, since some maps will only be present when BTF is enabled.

Try to make only the strictly-necessary changes to keep things straightforward to review. Thank you!

Adds infrastructure to test loading of ELF objects compiled without BTF information.

Fixes: cilium#1810
Signed-off-by: Pavan More <pavansmore05@gmail.com>
@puwun puwun force-pushed the test/elf-reader-nobtf branch from 0c9fc75 to d7485d5 Compare January 28, 2026 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ensure the ELF reader works for objects built without BTF

2 participants