Skip to content

Commit 440d971

Browse files
committed
Work around non-existence of ElfW(type) macro on FreeBSD
Fixes PR51331. On FreeBSD, the elf headers don't (yet) provide the ElfW(type) macro. However, there is a similar set of macros in the <sys/elf-generic.h> header, of which `__ElfN(type)` exactly matches the indended purpose. Reviewed By: gulfem Differential Revision: https://reviews.llvm.org/D107388
1 parent dce35ef commit 440d971

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

compiler-rt/lib/profile/InstrProfilingPlatformLinux.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@
1717
#include "InstrProfiling.h"
1818
#include "InstrProfilingInternal.h"
1919

20+
#if defined(__FreeBSD__) && !defined(ElfW)
21+
/*
22+
* FreeBSD's elf.h and link.h headers do not define the ElfW(type) macro yet.
23+
* If this is added to all supported FreeBSD versions in the future, this
24+
* compatibility macro can be removed.
25+
*/
26+
#define ElfW(type) __ElfN(type)
27+
#endif
28+
2029
#define PROF_DATA_START INSTR_PROF_SECT_START(INSTR_PROF_DATA_COMMON)
2130
#define PROF_DATA_STOP INSTR_PROF_SECT_STOP(INSTR_PROF_DATA_COMMON)
2231
#define PROF_NAME_START INSTR_PROF_SECT_START(INSTR_PROF_NAME_COMMON)

0 commit comments

Comments
 (0)