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

Tag ELF files with platform specific section #3969

Merged
merged 1 commit into from
Nov 5, 2024

Conversation

lmb
Copy link
Collaborator

@lmb lmb commented Oct 30, 2024

Compiling against Windows eBPF headers produces object files which are not easily distinguishable from object files compiled against Linux headers. This is a problem for cross-platform tooling which wishes to inspect the contents of an ELF.

Emit a section .ebpf_for_windows with the contents 0x01 into ELFs compiled against the windows headers.

Updates #3956

Compiling against Windows eBPF headers produces object files which are not easily
distinguishable from object files compiled against Linux headers. This is a problem
for cross-platform tooling which wishes to inspect the contents of an ELF.

Emit a section .ebpf_for_windows with the contents 0x01 into ELFs compiled against
the windows headers.

Updates microsoft#3956
@lmb
Copy link
Collaborator Author

lmb commented Oct 30, 2024

This is not a foolproof solution unfortunately because a program might not include the header that contains the section definition. As far as I can tell there is a single file in the repo which has this problem, atomic_instructions_other.o but I can't figure out what the source for that is.

@saxena-anurag saxena-anurag added this pull request to the merge queue Nov 5, 2024
Merged via the queue into microsoft:main with commit 5c2cb9a Nov 5, 2024
90 checks passed
@dthaler
Copy link
Collaborator

dthaler commented Nov 5, 2024

I'll observe that this PR has no tests. https://github.com/microsoft/ebpf-for-windows/blob/main/CONTRIBUTING.md#contributing-code says:

For all new Pull Requests the following rules apply:

  • Existing tests should continue to pass.
  • Tests need to be provided for every bug/feature that is completed.
  • Documentation needs to be provided for every feature that is end-user visible.

I would expect a test that (say) verifies that one or more sample programs have this section with the correct content. Can you add such a test as part of #3956?

@lmb
Copy link
Collaborator Author

lmb commented Nov 5, 2024

Do you have existing tests which run the equivalent of a shell script? I’ll not have much time in the next weeks and will prioritise getting the names map and program changes in

@lmb lmb deleted the elf-platform-tag branch November 5, 2024 15:07
@dthaler
Copy link
Collaborator

dthaler commented Nov 5, 2024

Do you have existing tests which run the equivalent of a shell script?

Yes. tests\bpftool_tests\bpftool_tests.cpp executes commands.

However, another way to do it is to have the test use elfio to check that the section is correct. libfuzzer\verifier_fuzzer\libfuzz_harness.cpp is an example of a test that uses ELFIO::elfio.

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.

4 participants