From dcbf391515d4bcc409fbb6dec362d421e209b1ed Mon Sep 17 00:00:00 2001 From: vasilito Date: Fri, 31 Jul 2026 17:57:57 +0300 Subject: [PATCH] elf.h: add Elf64/32_Sword, Versym, Relr, Lib, Chdr types libelf/elfutils (consumed by Mesa radeonsi/ANV) use these standard ELF types which cbindgen elides from the generated (not referenced by relibc's own exports). Add them as raw C in the header trailer. --- src/header/elf/cbindgen.toml | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/header/elf/cbindgen.toml b/src/header/elf/cbindgen.toml index 710d99558c..4066d758c2 100644 --- a/src/header/elf/cbindgen.toml +++ b/src/header/elf/cbindgen.toml @@ -38,6 +38,47 @@ after_includes = """ #define ELF64_M_SYM(info) ELF32_M_SYM (info) #define ELF64_M_SIZE(info) ELF32_M_SIZE (info) #define ELF64_M_INFO(sym, size) ELF32_M_INFO (sym, size) + +/* + * ELF types required by portable ELF tooling (libelf/elfutils, consumed by + * Mesa's radeonsi/ANV) that cbindgen does not emit from the Rust module (they + * are not referenced by relibc's own exported items). Defined here as raw C in + * the header trailer. stdint types are used directly to avoid depending on + * which Elf*_ scalar typedefs cbindgen chose to emit. + */ +typedef int32_t Elf32_Sword; +typedef int32_t Elf64_Sword; +typedef uint16_t Elf32_Versym; +typedef uint16_t Elf64_Versym; +typedef uint32_t Elf32_Relr; +typedef uint64_t Elf64_Relr; + +typedef struct { + uint32_t l_name; + uint32_t l_time_stamp; + uint32_t l_checksum; + uint32_t l_version; + uint32_t l_flags; +} Elf32_Lib; +typedef struct { + uint32_t l_name; + uint32_t l_time_stamp; + uint32_t l_checksum; + uint32_t l_version; + uint32_t l_flags; +} Elf64_Lib; + +typedef struct { + uint32_t ch_type; + uint32_t ch_size; + uint32_t ch_addralign; +} Elf32_Chdr; +typedef struct { + uint32_t ch_type; + uint32_t ch_reserved; + uint64_t ch_size; + uint64_t ch_addralign; +} Elf64_Chdr; """ include_guard = "_ELF_H" language = "C"