Define symbol for source assembly file (.s) in Android.mk?

Is there an easy way to define a character for an Android NDK binding assembler from a file Android.mk?

My goal is to create a built-in library from several .C and .s files (assembler) compiled and configured for ARMV6 or ARMV7A EABIS, with all the necessary conditional compilation, controlled by simply changing the APP_ABI value in the Application.mk file.

First, I successfully used the directives ifeq()available in Android.mkto request the value of APP_ABI and then conditionally execute the different parts of the script assembly.

Then I tried to use this function to conditionally enter a character (via -D), for example:

# Compilation Flags
ifeq ($(TARGET_ARCH_ABI),armeabi)
   LOCAL_CFLAGS += -DTARGET_ARMEABI -marm  -mtune='arm1136jf-s' -ffast-math -O3 -march=armv6 -fvisibility=hidden 
else
   #armeabi-v7a
   LOCAL_CFLAGS += -marm -ffast-math -O3 -march=armv7-a -fvisibility=hidden
endif

C source files find the correct TARGET_ARMEABI character, however assembly files do not work. (I need this to determine the proper EABI attributes according to the architecture). This is an example of how I am trying to conditionally define EABI attributes in assembly language files:

.ifdef TARGET_ARMEABI
    .arch armv6
    .fpu softvfp
    .eabi_attribute 23, 1
    .eabi_attribute 24, 1
    .eabi_attribute 25, 1
    .eabi_attribute 26, 2
    .eabi_attribute 30, 2
    .eabi_attribute 18, 4
.else
    .arch armv7-a
    .eabi_attribute 27, 3
    .fpu vfp
    .eabi_attribute 23, 1
    .eabi_attribute 24, 1
    .eabi_attribute 25, 1
    .eabi_attribute 26, 2
    .eabi_attribute 30, 2
    .eabi_attribute 18, 4
.endif

Any pointers or suggestions are welcome.

+1
source share
2 answers

Assembly files must end with capital S ( .Sor .sx), which must be pre-processed gcc. See GCC doc, 3.2 Options controlling the release type for this.

, Bionic , libc/arch-arm/bionic/memcpy.S.

+1

TARGET_ARMEABI , "-x --cpp" #ifdef C .

+1

Source: https://habr.com/ru/post/1530931/


All Articles