-
Notifications
You must be signed in to change notification settings - Fork 50
Add support for resolving helper functions by name instead of by id #939
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughAdds platform support for resolving helper functions by name, implements Linux name→index lookup, updates ELF loader to rewrite external-call relocations to static helper calls when resolvable, and extends tests to exercise the new path. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used📓 Path-based instructions (3)**/*.{c,cc,cpp,cxx,h,hpp,hxx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{c,cc,cpp,cxx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
src/test/**/*.{cc,cpp,cxx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧬 Code graph analysis (1)src/test/ebpf_yaml.cpp (1)
🪛 Clang (14.0.6)src/elf_loader.cpp[warning] 957-957: variable 'helper_index' is not initialized (cppcoreguidelines-init-variables) src/test/ebpf_yaml.cpp[warning] 43-43: use a trailing return type for this function (modernize-use-trailing-return-type) ⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
🔇 Additional comments (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/linux/linux_platform.hpp (1)
5-12: Avoid transitive includes for std::stringInclude in this header to make it self-contained.
#pragma once +#include <string> #include "spec/function_prototypes.hpp"
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (10)
ebpf-samples(1 hunks)src/elf_loader.cpp(3 hunks)src/ir/unmarshal.cpp(4 hunks)src/linux/gpl/spec_prototypes.cpp(1 hunks)src/linux/linux_platform.cpp(1 hunks)src/linux/linux_platform.hpp(1 hunks)src/platform.hpp(2 hunks)src/spec/type_descriptors.hpp(1 hunks)src/test/test_marshal.cpp(1 hunks)src/test/test_verify.cpp(1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{c,cc,cpp,cxx,h,hpp,hxx}
📄 CodeRabbit inference engine (AGENTS.md)
Run ./scripts/format-code --staged (clang-format) before committing; ensure formatting matches project baseline
Files:
src/spec/type_descriptors.hppsrc/linux/linux_platform.hppsrc/linux/linux_platform.cppsrc/platform.hppsrc/test/test_verify.cppsrc/test/test_marshal.cppsrc/ir/unmarshal.cppsrc/linux/gpl/spec_prototypes.cppsrc/elf_loader.cpp
**/*.{h,hpp,hxx}
📄 CodeRabbit inference engine (AGENTS.md)
Prefer #pragma once in header files; follow existing patterns within each subdirectory
Files:
src/spec/type_descriptors.hppsrc/linux/linux_platform.hppsrc/platform.hpp
src/{cfg,crab,linux,arith,asm_*}/**/*
📄 CodeRabbit inference engine (AGENTS.md)
Add new verifier logic under the matching subsystem directory (cfg/, crab/, linux/, arith/, asm_*) to keep separation of concerns
Files:
src/linux/linux_platform.hppsrc/linux/linux_platform.cppsrc/linux/gpl/spec_prototypes.cpp
**/*.{c,cc,cpp,cxx}
📄 CodeRabbit inference engine (AGENTS.md)
Ensure new C/C++ source files include the standard SPDX license header; validate with ./scripts/check-license.sh
Files:
src/linux/linux_platform.cppsrc/test/test_verify.cppsrc/test/test_marshal.cppsrc/ir/unmarshal.cppsrc/linux/gpl/spec_prototypes.cppsrc/elf_loader.cpp
src/test/**/*.{cc,cpp,cxx}
📄 CodeRabbit inference engine (AGENTS.md)
src/test/**/*.{cc,cpp,cxx}: Place Catch2 unit/integration tests under src/test and add focused tests when modifying verifier behaviour
When introducing or relying on a new invariant, add a targeted regression test covering the invariant
Files:
src/test/test_verify.cppsrc/test/test_marshal.cpp
🧠 Learnings (2)
📚 Learning: 2025-10-15T13:34:52.142Z
Learnt from: CR
Repo: vbpf/prevail PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-15T13:34:52.142Z
Learning: Applies to src/test/**/*.{cc,cpp,cxx} : Place Catch2 unit/integration tests under src/test and add focused tests when modifying verifier behaviour
Applied to files:
src/test/test_verify.cpp
📚 Learning: 2025-10-15T13:34:52.142Z
Learnt from: CR
Repo: vbpf/prevail PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-15T13:34:52.142Z
Learning: Applies to src/test/**/*.{cc,cpp,cxx} : When introducing or relying on a new invariant, add a targeted regression test covering the invariant
Applied to files:
src/test/test_verify.cpp
🧬 Code graph analysis (6)
src/linux/linux_platform.hpp (1)
src/platform.hpp (4)
name(21-21)name(24-24)n(20-20)n(23-23)
src/linux/linux_platform.cpp (2)
src/linux/gpl/spec_prototypes.cpp (6)
get_helper_prototype_by_name_linux(2779-2794)get_helper_prototype_by_name_linux(2779-2779)is_helper_usable_linux(2740-2757)is_helper_usable_linux(2740-2740)is_helper_usable_by_name_linux(2759-2770)is_helper_usable_by_name_linux(2759-2759)src/linux/linux_platform.hpp (3)
get_helper_prototype_by_name_linux(9-9)is_helper_usable_linux(10-10)is_helper_usable_by_name_linux(11-11)
src/test/test_marshal.cpp (2)
src/ir/unmarshal.cpp (4)
unmarshal(836-845)unmarshal(836-836)unmarshal(847-850)unmarshal(847-847)src/ir/unmarshal.hpp (2)
unmarshal(22-23)unmarshal(24-24)
src/ir/unmarshal.cpp (2)
src/elf_loader.cpp (3)
name(663-663)name(665-665)name(692-692)src/platform.hpp (2)
name(21-21)name(24-24)
src/linux/gpl/spec_prototypes.cpp (2)
src/platform.hpp (4)
name(21-21)name(24-24)n(20-20)n(23-23)src/linux/linux_platform.hpp (3)
is_helper_usable_by_name_linux(11-11)is_helper_usable_linux(10-10)get_helper_prototype_by_name_linux(9-9)
src/elf_loader.cpp (1)
src/platform.hpp (2)
name(21-21)name(24-24)
🪛 Clang (14.0.6)
src/linux/linux_platform.hpp
[warning] 9-9: use a trailing return type for this function
(modernize-use-trailing-return-type)
[warning] 10-10: use a trailing return type for this function
(modernize-use-trailing-return-type)
[warning] 11-11: use a trailing return type for this function
(modernize-use-trailing-return-type)
src/platform.hpp
[warning] 21-21: use 'using' instead of 'typedef'
(modernize-use-using)
[warning] 23-23: use 'using' instead of 'typedef'
(modernize-use-using)
[warning] 24-24: use 'using' instead of 'typedef'
(modernize-use-using)
[warning] 43-43: member variable 'get_helper_prototype_by_name' has public visibility
(misc-non-private-member-variables-in-classes)
[warning] 44-44: member variable 'is_helper_usable' has public visibility
(misc-non-private-member-variables-in-classes)
[warning] 45-45: member variable 'is_helper_usable_by_name' has public visibility
(misc-non-private-member-variables-in-classes)
src/test/test_verify.cpp
[warning] 544-544: variable 'TEST_CASE' is non-const and globally accessible, consider making it const
(cppcoreguidelines-avoid-non-const-global-variables)
src/ir/unmarshal.cpp
[warning] 86-86: member variable 'relocations' has public visibility
(misc-non-private-member-variables-in-classes)
[warning] 91-91: member variable '' has public visibility
(misc-non-private-member-variables-in-classes)
src/linux/gpl/spec_prototypes.cpp
[warning] 2759-2759: use a trailing return type for this function
(modernize-use-trailing-return-type)
[warning] 2759-2759: parameter 'name' is unused
(misc-unused-parameters)
[warning] 2772-2772: use a trailing return type for this function
(modernize-use-trailing-return-type)
[warning] 2772-2772: parameter 'n' is unused
(misc-unused-parameters)
[warning] 2779-2779: use a trailing return type for this function
(modernize-use-trailing-return-type)
[warning] 2779-2779: parameter 'name' is unused
(misc-unused-parameters)
[warning] 2779-2779: parameter 'out_id' is unused
(misc-unused-parameters)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: build_ubuntu (Debug)
- GitHub Check: build_ubuntu (Release)
- GitHub Check: build_ubuntu (Release, library)
- GitHub Check: build_windows (Release, library)
- GitHub Check: build_ubuntu (Debug, library)
- GitHub Check: build_windows (Debug, tests)
- GitHub Check: build_windows (Debug, library)
- GitHub Check: build_ubuntu (Release, tests)
- GitHub Check: build_windows (Release, tests)
- GitHub Check: build_ubuntu (Debug, tests)
- GitHub Check: Analyze (cpp)
🔇 Additional comments (11)
ebpf-samples (1)
1-1: Submodule update verified.The new commit
c5759d90e24d4241a488b4ac6a3904ccec87e0e2exists in vbpf/ebpf-samples and includes the commit "Add test with an external helper function (test for resolve by name)", which directly supports the feature being implemented in this PR.src/linux/linux_platform.cpp (1)
241-253: Wire-in by-name helper hooksInitializer ordering matches ebpf_platform_t; no functional issues spotted.
src/test/test_marshal.cpp (1)
835-878: Unmarshal external helper by-name: coverage is correctExercises success and two failure paths; aligns with relocation-driven resolution.
src/linux/gpl/spec_prototypes.cpp (2)
2759-2770: Name-based usability check is consistent with numeric pathPrefix trim + linear lookup + existing context guard; OK.
2779-2794: By-name prototype lookup with out_id: OKReturns prototype, sets id, and errors clearly on not-found/unusable.
src/elf_loader.cpp (1)
1069-1079: Per-program relocation capture and clearAttaching relocations to RawProgram and clearing per iteration is correct.
src/platform.hpp (1)
21-25: By-name hook typedefs addedAPI surface looks fine.
src/ir/unmarshal.cpp (4)
86-86: LGTM!The relocations map is properly declared and initialized. The public visibility flagged by static analysis is intentional for this design, enabling external function name resolution during unmarshalling.
Also applies to: 91-93
492-503: LGTM!The variant approach cleanly supports both ID-based and name-based helper resolution. The implementation correctly captures the resolved func_id from the name-based path and uses it to populate the Call struct.
839-839: LGTM!Correctly propagates relocations from RawProgram to enable name-based helper resolution during unmarshalling.
505-508: LGTM!Error handling is comprehensive with clear messages for all failure paths: unresolved relocations, invalid helper names, invalid helper IDs, and unsupported functions.
Also applies to: 648-654, 657-659
|
@Alan-Jowett merging ebpf-samples caused conflicts. Sorry! |
|
No worries. I think I have a simpler solution anyway. Will revise and resubmit |
|
I think I can actually constraint the change to the ELF parsing code and have it patch the instructions with the correct helper id and leave the unmarshalling unchanged. |
Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
df3a655 to
e202a9d
Compare
Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
e202a9d to
a3da20b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (6)
src/elf_loader.cpp(1 hunks)src/linux/gpl/spec_prototypes.cpp(1 hunks)src/linux/linux_platform.cpp(1 hunks)src/linux/linux_platform.hpp(1 hunks)src/platform.hpp(2 hunks)src/test/test_verify.cpp(1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{c,cc,cpp,cxx,h,hpp,hxx}
📄 CodeRabbit inference engine (AGENTS.md)
Run ./scripts/format-code --staged (clang-format) before committing; ensure formatting matches project baseline
Files:
src/platform.hppsrc/elf_loader.cppsrc/linux/linux_platform.hppsrc/linux/linux_platform.cppsrc/linux/gpl/spec_prototypes.cppsrc/test/test_verify.cpp
**/*.{h,hpp,hxx}
📄 CodeRabbit inference engine (AGENTS.md)
Prefer #pragma once in header files; follow existing patterns within each subdirectory
Files:
src/platform.hppsrc/linux/linux_platform.hpp
**/*.{c,cc,cpp,cxx}
📄 CodeRabbit inference engine (AGENTS.md)
Ensure new C/C++ source files include the standard SPDX license header; validate with ./scripts/check-license.sh
Files:
src/elf_loader.cppsrc/linux/linux_platform.cppsrc/linux/gpl/spec_prototypes.cppsrc/test/test_verify.cpp
src/{cfg,crab,linux,arith,asm_*}/**/*
📄 CodeRabbit inference engine (AGENTS.md)
Add new verifier logic under the matching subsystem directory (cfg/, crab/, linux/, arith/, asm_*) to keep separation of concerns
Files:
src/linux/linux_platform.hppsrc/linux/linux_platform.cppsrc/linux/gpl/spec_prototypes.cpp
src/test/**/*.{cc,cpp,cxx}
📄 CodeRabbit inference engine (AGENTS.md)
src/test/**/*.{cc,cpp,cxx}: Place Catch2 unit/integration tests under src/test and add focused tests when modifying verifier behaviour
When introducing or relying on a new invariant, add a targeted regression test covering the invariant
Files:
src/test/test_verify.cpp
🧠 Learnings (4)
📚 Learning: 2025-10-15T13:34:52.142Z
Learnt from: CR
Repo: vbpf/prevail PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-15T13:34:52.142Z
Learning: Before finishing a change, manually review modified control-flow and data-flow to ensure no UB or unchecked user input paths were introduced
Applied to files:
src/elf_loader.cpp
📚 Learning: 2025-10-15T13:34:52.142Z
Learnt from: CR
Repo: vbpf/prevail PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-15T13:34:52.142Z
Learning: Applies to src/test/**/*.{cc,cpp,cxx} : Place Catch2 unit/integration tests under src/test and add focused tests when modifying verifier behaviour
Applied to files:
src/test/test_verify.cpp
📚 Learning: 2025-10-15T13:34:52.142Z
Learnt from: CR
Repo: vbpf/prevail PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-15T13:34:52.142Z
Learning: Applies to src/test/**/*.{cc,cpp,cxx} : When introducing or relying on a new invariant, add a targeted regression test covering the invariant
Applied to files:
src/test/test_verify.cpp
📚 Learning: 2025-10-15T13:34:52.142Z
Learnt from: CR
Repo: vbpf/prevail PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-15T13:34:52.142Z
Learning: Applies to src/{cfg,crab,linux,arith,asm_*}/**/* : Add new verifier logic under the matching subsystem directory (cfg/, crab/, linux/, arith/, asm_*) to keep separation of concerns
Applied to files:
src/test/test_verify.cpp
🧬 Code graph analysis (3)
src/linux/linux_platform.hpp (1)
src/platform.hpp (1)
name(24-24)
src/linux/linux_platform.cpp (2)
src/linux/gpl/spec_prototypes.cpp (2)
get_helper_index_linux(2759-2768)get_helper_index_linux(2759-2759)src/linux/linux_platform.hpp (1)
get_helper_index_linux(10-10)
src/linux/gpl/spec_prototypes.cpp (1)
src/platform.hpp (1)
name(24-24)
🪛 Clang (14.0.6)
src/platform.hpp
[warning] 24-24: use 'using' instead of 'typedef'
(modernize-use-using)
[warning] 44-44: member variable 'get_helper_index' has public visibility
(misc-non-private-member-variables-in-classes)
src/linux/linux_platform.hpp
[warning] 10-10: use a trailing return type for this function
(modernize-use-trailing-return-type)
src/linux/gpl/spec_prototypes.cpp
[warning] 2759-2759: use a trailing return type for this function
(modernize-use-trailing-return-type)
src/test/test_verify.cpp
[warning] 544-544: variable 'TEST_CASE' is non-const and globally accessible, consider making it const
(cppcoreguidelines-avoid-non-const-global-variables)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
- GitHub Check: build_windows (Release, library)
- GitHub Check: build_ubuntu (Debug, tests)
- GitHub Check: build_windows (Debug, tests)
- GitHub Check: build_ubuntu (Release, tests)
- GitHub Check: build_windows (Release, tests)
- GitHub Check: build_windows (Debug, library)
- GitHub Check: build_ubuntu (Release, library)
- GitHub Check: build_ubuntu (Release)
- GitHub Check: build_ubuntu (Debug)
- GitHub Check: Analyze (cpp)
🔇 Additional comments (6)
src/linux/linux_platform.hpp (1)
10-10: LGTM!Declaration is consistent with the platform interface typedef.
src/linux/linux_platform.cpp (1)
245-245: Callback wired correctly.The platform initializer now includes the helper index lookup function in the proper position.
src/platform.hpp (1)
24-24: Typedef added for helper index callback.Follows the existing pattern for other platform callbacks.
src/linux/gpl/spec_prototypes.cpp (1)
2759-2768: Helper index lookup implemented correctly.Linear search prepends "bpf_" prefix to each prototype name and returns the matching index. Error message is clear when helper is not found.
src/elf_loader.cpp (1)
954-960: External helper resolution implemented correctly.The code identifies undefined-symbol local calls (section_index == 0), resolves the helper index via the platform callback, and directly patches the instruction. This approach resolves helpers during ELF load, avoiding the need for deferred resolution during unmarshal.
Note: Past review suggested setting
imm = -1as a sentinel, but that pattern applies to deferred resolution. The current implementation resolves immediately, so the helper index is directly written toimm. This aligns with the PR comment's stated approach: "patch instructions with the correct helper ID during ELF load."src/test/test_verify.cpp (1)
544-544: Artifact not found in current environment.The test at line 544 references
externalfunction.o, but the ebpf-samples directory is empty and the artifact is missing. The artifact is only referenced in this single test location with no other references in the codebase.Verify manually that:
- The ebpf-samples submodule is properly checked out with all artifacts
externalfunction.oexists in the ebpf-samples directory after pulling the PR branch
Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
src/elf_loader.cpp(1 hunks)src/linux/gpl/spec_prototypes.cpp(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{c,cc,cpp,cxx,h,hpp,hxx}
📄 CodeRabbit inference engine (AGENTS.md)
Run ./scripts/format-code --staged (clang-format) before committing; ensure formatting matches project baseline
Files:
src/linux/gpl/spec_prototypes.cppsrc/elf_loader.cpp
**/*.{c,cc,cpp,cxx}
📄 CodeRabbit inference engine (AGENTS.md)
Ensure new C/C++ source files include the standard SPDX license header; validate with ./scripts/check-license.sh
Files:
src/linux/gpl/spec_prototypes.cppsrc/elf_loader.cpp
src/{cfg,crab,linux,arith,asm_*}/**/*
📄 CodeRabbit inference engine (AGENTS.md)
Add new verifier logic under the matching subsystem directory (cfg/, crab/, linux/, arith/, asm_*) to keep separation of concerns
Files:
src/linux/gpl/spec_prototypes.cpp
🧠 Learnings (1)
📚 Learning: 2025-10-15T13:34:52.142Z
Learnt from: CR
Repo: vbpf/prevail PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-10-15T13:34:52.142Z
Learning: Before finishing a change, manually review modified control-flow and data-flow to ensure no UB or unchecked user input paths were introduced
Applied to files:
src/elf_loader.cpp
🧬 Code graph analysis (1)
src/linux/gpl/spec_prototypes.cpp (1)
src/platform.hpp (1)
name(24-24)
🪛 Clang (14.0.6)
src/linux/gpl/spec_prototypes.cpp
[warning] 2759-2759: use a trailing return type for this function
(modernize-use-trailing-return-type)
[warning] 2759-2759: parameter 'name' is unused
(misc-unused-parameters)
src/elf_loader.cpp
[warning] 957-957: variable 'helper_index' is not initialized
(cppcoreguidelines-init-variables)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: build_ubuntu (Release)
- GitHub Check: build_ubuntu (Debug)
- GitHub Check: build_ubuntu (Release, library)
- GitHub Check: build_windows (Release, tests)
- GitHub Check: build_ubuntu (Debug, tests)
- GitHub Check: build_windows (Release, library)
- GitHub Check: build_ubuntu (Debug, library)
- GitHub Check: build_ubuntu (Release, tests)
- GitHub Check: build_windows (Debug, tests)
- GitHub Check: build_windows (Debug, library)
- GitHub Check: Analyze (cpp)
🔇 Additional comments (1)
src/linux/gpl/spec_prototypes.cpp (1)
2759-2768: Implementation is correct.The linear search with prefix matching correctly resolves helper names to indices. The -1 sentinel for "not found" aligns with the platform interface contract.
Pull Request Test Coverage Report for Build 19040038659Details
💛 - Coveralls |
Signed-off-by: Alan Jowett <alan.jowett@microsoft.com>
|
@dthaler should this be rethought and instead be BTF based? |
I haven't reviewed this PR yet and I'm in IETF meetings now, but based on the PR title: yes :) |
No rush, this can wait until after IETF. This is indeed part of the implementation of microsoft/ebpf-for-windows#4795 My only concern with taking a dependency on BTF is that this is currently a tool chain specific feature. We would need to figure out how to generate BTF data for helper functions when the provider is compiled using MSVC tool chains. |
|
@elazarg should we hold off merging this in light of @dthaler feedback? Given that call by helper ID is deprecated, should we revise this change to do the following:
|
My opinion: I think that would be the best approach. |
|
Maybe better merge this as a quick fix and then do it the right way? |
I'd ask Alan whether a "quick fix" is actually needed. It sounds like he's saying this can wait. After reviewing microsoft/ebpf-for-windows#4795 more, I question whether this actually meets the requirements (the requirements listed in that PR are self-contradictory I now believe, and my proposed resolution would mean this PR would likely not meet the requirements). |
Resolves: #938
This pull request introduces support for external helper function calls in eBPF programs on Linux. The main changes involve adding logic to resolve external helper functions by name, updating platform interfaces to expose helper function lookup, and extending tests to cover this functionality.
Support for external helper function calls
ProgramReader::try_reloc(src/elf_loader.cpp) to detect calls to external helper functions (flagged as local calls with section index 0), resolve their index using the platform, and update the instruction accordingly.get_helper_index_linuxinsrc/linux/gpl/spec_prototypes.cppto look up helper function indices by name, throwing an error if the helper is not found.Platform interface updates
get_helper_indexfunction pointer to theebpf_platform_tstruct insrc/platform.hpp, and updated the Linux platform implementation to provide this function. [1] [2] [3] [4]Test coverage
src/test/test_verify.cppto verify the new functionality.Submodule update
ebpf-samplessubmodule to a newer commit, likely to pick up changes needed for external helper function testing.Summary by CodeRabbit
New Features
Tests