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 <elf.h> (not referenced by relibc's own
exports). Add them as raw C in the header trailer.
This commit is contained in:
2026-07-31 17:57:57 +03:00
parent a2f047712e
commit dcbf391515
+41
View File
@@ -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"