From a2f047712e919a279ae833e314e66264b44cae7b Mon Sep 17 00:00:00 2001 From: vasilito Date: Fri, 31 Jul 2026 17:33:38 +0300 Subject: [PATCH] link.h: add glibc-compatible ElfW(type) macro Portable ELF code (Mesa util/build_id.c, unwinders) uses ElfW(Nhdr) etc. and expects to define ElfW -> Elf64_type (LP64) / Elf32_type. Without it those TUs fall back to an undefined Elf_##type and fail to compile. --- include/link.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/link.h b/include/link.h index 4d3ce2c7ef..f2f026f921 100644 --- a/include/link.h +++ b/include/link.h @@ -12,6 +12,20 @@ #include #include +/* + * glibc-compatible `ElfW(type)` macro: expands to the native-word-size ELF type + * (Elf64_type on LP64, Elf32_type otherwise). Portable ELF code (Mesa's + * util/build_id.c, unwinders) uses `ElfW(Nhdr)` etc. and expects to + * provide this. + */ +#ifndef ElfW +# if defined(__LP64__) || defined(_LP64) || (__SIZEOF_POINTER__ == 8) +# define ElfW(type) Elf64_##type +# else +# define ElfW(type) Elf32_##type +# endif +#endif + #ifdef __cplusplus extern "C" { #endif