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