Skip to content

Commit 7abe63a

Browse files
committed
bpf: fix a couple of issues related to arm64
The linux arm64 header linux:arch/arm64/include/asm/sysreg.h contains asm statement outside the function, ======== asm( " .irp num,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30\n" " .equ .L__reg_num_x\\num, \\num\n" " .endr\n" " .equ .L__reg_num_xzr, 31\n" "\n" " .macro mrs_s, rt, sreg\n" __emit_inst(0xd5200000|(\\sreg)|(.L__reg_num_\\rt)) " .endm\n" "\n" " .macro msr_s, sreg, rt\n" __emit_inst(0xd5000000|(\\sreg)|(.L__reg_num_\\rt)) " .endm\n" ); ======== The compiler cannot remove them since they are file scope. This patch adds bpf asm parser to handle this, otherwise, llvm will complain with compilation failure. Since none of macros/defines are used in bpf program, there is no impact in compilation result. Another change is to add AARCH64 value to ld_cache processing. The value is taken from glibc:sysdeps/generic/ldconfig.h. Signed-off-by: Yonghong Song <yhs@fb.com>
1 parent 3d51c0f commit 7abe63a

3 files changed

Lines changed: 4 additions & 0 deletions

File tree

cmake/clang_libs.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ if (${_llvm_coroutines} GREATER -1)
99
list(APPEND llvm_raw_libs coroutines)
1010
endif()
1111
if (${LLVM_PACKAGE_VERSION} VERSION_GREATER "5")
12+
list(APPEND llvm_raw_libs bpfasmparser)
1213
list(APPEND llvm_raw_libs bpfdisassembler)
1314
endif()
1415
llvm_map_components_to_libnames(_llvm_libs ${llvm_raw_libs})

src/cc/bcc_proc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ static int load_ld_cache(const char *cache_path) {
311311
#define ABI_X8664_LIB64 0x0300
312312
#define ABI_S390_LIB64 0x0400
313313
#define ABI_POWERPC_LIB64 0x0500
314+
#define ABI_AARCH64_LIB64 0x0a00
314315

315316
static bool match_so_flags(int flags) {
316317
if ((flags & FLAG_TYPE_MASK) != TYPE_ELF_LIBC6)
@@ -322,6 +323,7 @@ static bool match_so_flags(int flags) {
322323
case ABI_X8664_LIB64:
323324
case ABI_S390_LIB64:
324325
case ABI_POWERPC_LIB64:
326+
case ABI_AARCH64_LIB64:
325327
return (sizeof(void *) == 8);
326328
}
327329

src/cc/bpf_module.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ BPFModule::BPFModule(unsigned flags, TableStorage *ts)
111111
LLVMInitializeBPFTargetInfo();
112112
LLVMInitializeBPFAsmPrinter();
113113
#if LLVM_MAJOR_VERSION >= 6
114+
LLVMInitializeBPFAsmParser();
114115
if (flags & DEBUG_SOURCE)
115116
LLVMInitializeBPFDisassembler();
116117
#endif

0 commit comments

Comments
 (0)