Skip to content

Commit

Permalink
Work around non-existence of ElfW(type) macro on FreeBSD
Browse files Browse the repository at this point in the history
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
  • Loading branch information
DimitryAndric committed Aug 4, 2021
1 parent dce35ef commit 440d971
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
Expand Up @@ -17,6 +17,15 @@
#include "InstrProfiling.h"
#include "InstrProfilingInternal.h"

#if defined(__FreeBSD__) && !defined(ElfW)
/*
* FreeBSD's elf.h and link.h headers do not define the ElfW(type) macro yet.
* If this is added to all supported FreeBSD versions in the future, this
* compatibility macro can be removed.
*/
#define ElfW(type) __ElfN(type)
#endif

#define PROF_DATA_START INSTR_PROF_SECT_START(INSTR_PROF_DATA_COMMON)
#define PROF_DATA_STOP INSTR_PROF_SECT_STOP(INSTR_PROF_DATA_COMMON)
#define PROF_NAME_START INSTR_PROF_SECT_START(INSTR_PROF_NAME_COMMON)
Expand Down

0 comments on commit 440d971

Please sign in to comment.