From ba01560b869bd213159bdaaaf22239372d94827f Mon Sep 17 00:00:00 2001 From: vasko-110 Date: Tue, 8 Sep 2026 13:06:54 +0300 Subject: [PATCH] debugging: define ElfW when the target has no ABSL_HAVE_ELF_MEM_IMAGE is enabled for every __ELF__ target except an explicit deny-list, and the header then includes unconditionally. __ELF__ describes the object format, not the presence of a dynamic loader: bare-metal ELF toolchains produce ELF objects and ship no . On arm-none-eabi with newlib the include is reached and the build fails with a fatal error. newlib does provide , so include that when is missing and define ElfW from the target's pointer size. This generalizes the existing FreeBSD case, which already defines ElfW itself. Platforms that do have are unaffected: it defines ElfW, so the fallback block is skipped. --- absl/debugging/internal/elf_mem_image.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/absl/debugging/internal/elf_mem_image.h b/absl/debugging/internal/elf_mem_image.h index 4d31a474cfd..f24aa26f2ac 100644 --- a/absl/debugging/internal/elf_mem_image.h +++ b/absl/debugging/internal/elf_mem_image.h @@ -42,10 +42,20 @@ #ifdef ABSL_HAVE_ELF_MEM_IMAGE +#if __has_include() #include // for ElfW +#else +#include +#endif -#if defined(__FreeBSD__) && !defined(ElfW) -#define ElfW(x) __ElfN(x) +#ifndef ElfW +#if defined(__FreeBSD__) +#define ElfW(type) __ElfN(type) +#elif __SIZEOF_POINTER__ == 8 +#define ElfW(type) Elf64_##type +#else +#define ElfW(type) Elf32_##type +#endif #endif namespace absl {