objcopy: Support cross-build for stripping symbols
authorGeunsik Lim <geunsik.lim@samsung.com>
Sat, 26 Mar 2016 12:39:14 +0000 (21:39 +0900)
committerGeunsik Lim <geunsik.lim@samsung.com>
Mon, 28 Mar 2016 07:18:40 +0000 (16:18 +0900)
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
cross/arm/toolchain.cmake

index c9da367..d0f3f54 100644 (file)
@@ -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(
index c7fea19..9cc9279 100644 (file)
@@ -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)