microsoft / microsoft/ebpf-for-windows
Discern ELF targeting eBPF for Windows from ones targeting Linux
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 3.6k
- Forks
- 311
- Avg merge
- 6d 10h
- Merged PRs (30d)
- 21
Description
### Describe the feature you'd like supported
Right now it is not possible to determine the target platform from the contents of an ELF. A program compiled against Linux headers looks the same as a programs compiled against Windows ones. This is a problem for projects which need to support loading ELF from both platforms because while the ELF are superficially similar the contents aren't compatible:
* Constants like map type differ
* Section names are distinct
* Even where section names match, programs are not necessary compatible (see https://github.com/microsoft/ebpf-for-windows/issues/3212)
There should be a way for toolchains to figure out the platform of an ELF.
### Proposed solution
1. Add a new ELF section similar to `.license` which contains a string that indicates the platform, e.g. `windows` or `linux`.
2. Somehow set the ELF OS/ABI field to something meaningful.
```
$ readelf -h testdata/loader-clang-el.elf
ELF Header:
Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
```
It would be best if this was coordinated with upstream libbpf somehow.
### Additional context
_No response_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.