[compiler-rt] Define ElfW() macro if it's not defined
authorSergej Jaskiewicz <jaskiewiczs@icloud.com>
Tue, 10 Mar 2020 15:53:07 +0000 (18:53 +0300)
committerSergej Jaskiewicz <jaskiewiczs@icloud.com>
Tue, 10 Mar 2020 15:54:28 +0000 (18:54 +0300)
Summary:
The `ElfW()` macro is not provided by `<link.h>` on some
systems (e.g., FreeBSD). On these systems the data structures are
just called `Elf_XXX`. Define `ElfW()` locally.

(This fix is taken from [libunwind](https://github.com/llvm/llvm-project/blob/9b05596eff21388ae6f17cdea8df0538dc630441/libunwind/src/AddressSpace.hpp#L144-L157).)

Reviewers: compnerd

Differential revision: https://reviews.llvm.org/D75907

compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp

index edbe840..4d17c96 100644 (file)
 #include <sys/resource.h>
 #include <syslog.h>
 
+#if !defined(ElfW)
+#define ElfW(type) Elf_##type
+#endif
+
 #if SANITIZER_FREEBSD
 #include <pthread_np.h>
 #include <osreldate.h>