diff --git a/lisp/elf.c b/lisp/elf.c
index 823acdacd99210dcfa5654ad9a78f88e3d376df0..21aa64c79d7174f7cd6095659a6b703a7cc58257 100644
--- a/lisp/elf.c
+++ b/lisp/elf.c
@@ -25,7 +25,7 @@ static char elf_magic_string[] = {ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3};
 /* Note: FreeBSD has nice macros that let you use Elf_Ehdr
    etc. declarations; unfortunately Linux doesn't have this so you
    have to do Elf32_Ehdr etc.  Bad for moving to 64 bits.... */
-#ifdef __linux__
+#if defined(__linux__) || defined(sparc)
 typedef Elf32_Ehdr Elf_Ehdr;
 typedef Elf32_Shdr Elf_Shdr;
 #endif