Skip to content

Commit

Permalink
build: Fix build errors due to low kernel version
Browse files Browse the repository at this point in the history
EM_RISCV, TRACEFS_MAGIC, MAP_FIXED_NOREPLACE macros are added to
fix build errors since they are not declared in the low kernel version.

The error messages are below:
uftrace/cmds/record.c:1592:75: error: ‘EM_RISCV’ undeclared
(first use in this function)
  uint16_t supported_machines[] = { EM_X86_64, EM_ARM, EM_AARCH64, EM_386, EM_RISCV };
                                                                           ^
uftrace/utils/tracefs.c:26:53: error: ‘TRACEFS_MAGIC’ undeclared
(first use in this function)
  if (!statfs(TRACEFS_DIR_PATH, &fs) && fs.f_type == TRACEFS_MAGIC) {
                                                     ^
uftrace/arch/x86_64/mcount-dynamic.c:46:6: error: ‘MAP_FIXED_NOREPLACE’
undeclared (first use in this function)
      MAP_FIXED_NOREPLACE | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
      ^

Fixed: #1834

Signed-off-by: Michelle Jin <shjy180909@gmail.com>
  • Loading branch information
MichelleJin12 committed Oct 28, 2023
1 parent f962a2c commit 4ecb6c0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions arch/x86_64/mcount-dynamic.c
Expand Up @@ -12,6 +12,10 @@
#include "utils/symbol.h"
#include "utils/utils.h"

#ifndef MAP_FIXED_NOREPLACE
#define MAP_FIXED_NOREPLACE 0x100000
#endif

static const unsigned char fentry_nop_patt1[] = { 0x67, 0x0f, 0x1f, 0x04, 0x00 };
static const unsigned char fentry_nop_patt2[] = { 0x0f, 0x1f, 0x44, 0x00, 0x00 };
static const unsigned char patchable_gcc_nop[] = { 0x90, 0x90, 0x90, 0x90, 0x90 };
Expand Down
4 changes: 4 additions & 0 deletions cmds/record.c
Expand Up @@ -29,6 +29,10 @@
#include "utils/symbol.h"
#include "utils/utils.h"

#ifndef EM_RISCV
#define EM_RISCV 243
#endif

#ifndef EFD_SEMAPHORE
#define EFD_SEMAPHORE (1 << 0)
#endif
Expand Down
4 changes: 4 additions & 0 deletions utils/tracefs.c
Expand Up @@ -8,6 +8,10 @@
#include "utils/tracefs.h"
#include "utils/utils.h"

#ifndef TRACEFS_MAGIC
#define TRACEFS_MAGIC 0x74726163
#endif

#define PROC_MOUNTS_DIR_PATH "/proc/mounts"
#define TRACEFS_DIR_PATH "/sys/kernel/tracing"
#define OLD_TRACEFS_DIR_PATH "/sys/kernel/debug/tracing"
Expand Down

0 comments on commit 4ecb6c0

Please sign in to comment.