From f60a287a64d509ae60c2ce1190effe9e8bdb0f4e Mon Sep 17 00:00:00 2001 From: Yi-Hong Lyu Date: Wed, 8 Dec 2021 20:50:41 +0800 Subject: [PATCH] Add __x86.get_pc_thunk.bx to avoid dependency (#9955) --- cmake/onnxruntime_mlas.cmake | 10 ++++++ .../core/mlas/lib/x86/x86.get_pc_thunk.S | 34 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 onnxruntime/core/mlas/lib/x86/x86.get_pc_thunk.S diff --git a/cmake/onnxruntime_mlas.cmake b/cmake/onnxruntime_mlas.cmake index b13f13de8d..12d1e271a9 100644 --- a/cmake/onnxruntime_mlas.cmake +++ b/cmake/onnxruntime_mlas.cmake @@ -355,6 +355,16 @@ else() ${mlas_platform_srcs_sse2} ${mlas_platform_srcs_avx} ) + + # In r23, NDK remove __x86.get_pc_thunk.* from libatomic. Add our own + # implementation to avoid external dependency. + if(ANDROID) + set(mlas_platform_srcs + ${mlas_platform_srcs} + ${MLAS_SRC_DIR}/x86/x86.get_pc_thunk.S + ) + endif() + if(NOT ONNXRUNTIME_MLAS_MULTI_ARCH) set(MLAS_SOURCE_IS_NOT_SET 0) endif() diff --git a/onnxruntime/core/mlas/lib/x86/x86.get_pc_thunk.S b/onnxruntime/core/mlas/lib/x86/x86.get_pc_thunk.S new file mode 100644 index 0000000000..b3c4f6ac8b --- /dev/null +++ b/onnxruntime/core/mlas/lib/x86/x86.get_pc_thunk.S @@ -0,0 +1,34 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + +Licensed under the MIT License. + +Module Name: + + x86.get_pc_thunk.S + +Abstract: + + This module implements __x86.get_pc_thunk.* to avoid external dependency. + +--*/ + + +#include "asmmacro.h" + + .intel_syntax noprefix + +/*++ + +Routine Description: + + The routine loads its return address -- which is the address of the + instruction that immediately follows -- into the ebx register. + +--*/ + + FUNCTION_ENTRY __x86.get_pc_thunk.bx + + mov ebx, [esp] + ret