casaroli opened a new pull request, #20594: URL: https://github.com/apache/nuttx/pull/20594
## Summary `<elf.h>` included only the header of the target's ELF class (`elf32.h` or `elf64.h`), so a program that reads ELF files of the other class, for example a tool that handles both, did not compile. Some standard constants were also missing: `SELFMAG`, `SHN_LORESERVE`, `SHN_HIRESERVE`, `SHN_XINDEX`, `SHT_GROUP` and `SHT_SYMTAB_SHNDX`. This PR adds the missing constants (first commit) and makes `<elf.h>` include both `elf32.h` and `elf64.h`, like the C library of other systems (second commit). The `Elf_*` types and the `ELF_CLASS`, `ELF_ST_*` and `ELF_R_*` macros of the target move from those two headers to `<elf.h>` and do not change, so code that uses them is not affected. ## Impact `Elf32_*` and `Elf64_*` are available on all targets. No change for existing users of `Elf_*` and `ELF_*`. ## Testing A test program that uses `Elf32_Ehdr`, `Elf64_Ehdr`, `Elf_Ehdr`, `ELF32_ST_TYPE`, `ELF64_ST_TYPE`, `ELF_ST_TYPE` and the new constants, with static assertions on the sizes and on `ELF_CLASS`, compiles with `-Wall -Werror` against the headers of this branch for a 64-bit target and for a 32-bit target (`CONFIG_ARCH_64BIT` unset). Against master it fails: `unknown type name 'Elf32_Ehdr'`. Builds with `-Wno-cpp -Werror` (the ELF loader, libelf, modlib and coredump use these headers): `qemu-armv8a:knsh`, `qemu-armv8a:nsh`, `rv-virt:knsh64`, `rv-virt:nsh64`, `qemu-armv7a:knsh`, `sabre-6quad:coredump`, `lm3s6965-ek:qemu-protected`, `mps2-an500:nsh`, `esp32-devkitc:nsh`. `tools/checkpatch.sh -c -u -m -g` passes. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
