From 2df33a8de217f54330397a9101c51f2a9956ad18 Mon Sep 17 00:00:00 2001 From: Geunsik Lim Date: Sat, 26 Mar 2016 21:39:14 +0900 Subject: [PATCH] objcopy: Support cross-build for stripping symbols Currently, the 'objcopy' does only support native-build since the commit number 4efef62f0ead16b4f8ca2c6ccf0a77ce112f73b9 Let's add cross-build as well as native-build to strip symbols. v3: - support if statement for arm64 v2: - Replace 'EQUAL' with 'DEFINED' for handling Other Linux distributions as well as Ubuntu 14.04 and for handling in case of native-build. v2: - support cross-build to strip debug symbols of native arm binaries Signed-off-by: Geunsik Lim geunsik.lim@samsung.com Signed-off-by: MyungJoo Ham myungjoo.ham@samsung.com Signed-off-by: Prajwal A N an.prajwal@samsung.com --- CMakeLists.txt | 20 ++++++++++++++------ cross/arm/toolchain.cmake | 6 +++--- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c9da367..d0f3f54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -166,15 +166,23 @@ else() if (STRIP STREQUAL "STRIP-NOTFOUND") message(FATAL_ERROR "strip not found") endif() - - else (CMAKE_SYSTEM_NAME STREQUAL Darwin) - + elseif (CMAKE_SYSTEM_NAME STREQUAL Linux) # Ensure that objcopy is present - find_program(OBJCOPY objcopy) + if(DEFINED ENV{CROSSCOMPILE}) + if(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l) + find_program(OBJCOPY arm-linux-gnueabihf-objcopy) + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) + find_program(OBJCOPY aarch64-linux-gnu-objcopy) + else() + clr_unknown_arch() + endif() + else() + find_program(OBJCOPY objcopy) + endif() if (OBJCOPY STREQUAL "OBJCOPY-NOTFOUND") message(FATAL_ERROR "objcopy not found") endif() - endif (CMAKE_SYSTEM_NAME STREQUAL Darwin) + endif () endif(WIN32) # Build a list of compiler definitions by putting -D in front of each define. @@ -287,7 +295,7 @@ function(strip_symbols targetName outputFilename) COMMAND ${STRIP} -u -r ${strip_source_file} COMMENT Stripping symbols from ${strip_source_file} into file ${strip_destination_file} ) - else(CMAKE_SYSTEM_NAME STREQUAL Darwin) + elseif(CMAKE_SYSTEM_NAME STREQUAL Linux) set(strip_destination_file ${strip_source_file}.dbg) add_custom_command( diff --git a/cross/arm/toolchain.cmake b/cross/arm/toolchain.cmake index c7fea19..9cc9279 100644 --- a/cross/arm/toolchain.cmake +++ b/cross/arm/toolchain.cmake @@ -7,9 +7,9 @@ set(CMAKE_SYSTEM_PROCESSOR armv7l) ## Specify the toolchain set(TOOLCHAIN "arm-linux-gnueabihf") set(TOOLCHAIN_PREFIX ${TOOLCHAIN}-) -# set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc) -# set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++) -# set(CMAKE_ASM_COMPILER ${TOOLCHAIN_PREFIX}as) +#set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc) +#set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++) +#set(CMAKE_ASM_COMPILER ${TOOLCHAIN_PREFIX}as) #set(CMAKE_AR ${TOOLCHAIN_PREFIX}ar) #set(CMAKE_OBJCOPY ${TOOLCHAIN_PREFIX}objcopy) #set(CMAKE_OBJDUMP ${TOOLCHAIN_PREFIX}objdump) -- 2.7.4