在 Android.mk 中为程序集 (.s) 源文件定义符号? [英] Define a symbol for an assembly (.s) source file in Android.mk?

查看:20
本文介绍了在 Android.mk 中为程序集 (.s) 源文件定义符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种简单的方法可以从 Android.mk 文件中为 Android NDK 工具链的汇编器定义符号?

Is there a simple way to define a symbol for the Android NDK toolchain's assembler from the Android.mk file?

我的目标是能够构建一个由几个 .C 和 .s(汇编程序)文件组成的本机库,这些文件为 ARMV6 或 ARMV7A EABIS 编译和调整,通过简单地修改 APP_ABI 值来驱动所有必需的条件编译在 Application.mk 文件上.

My objective is to be able to build a native library made up from several .C and .s (assembler) files compiled and tuned for either ARMV6 or ARMV7A EABIS, with all the required conditional compilation driven by simply modifying the APP_ABI value on the Application.mk file.

首先,我成功地使用了 Android.mk 中可用的 ifeq() 指令来查询 APP_ABI 值的值,然后有条件地执行构建脚本的不同部分.

First I have succesfully used the ifeq() directives available in Android.mk to query the value of the APP_ABI value and then conditionaly execute different parts of the build script.

然后我尝试使用此功能来有条件地注入一个符号(通过 -D),如下所示:

Then I tried to use this functionality in order to conditionally inject a symbol (via -D), like this:

# 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 源代码文件找到正确定义的 TARGET_ARMEABI 符号,但是汇编程序文件没有.(我需要这样做是为了根据体系结构定义正确的 EABI 属性).这是我如何尝试在汇编语言文件中有条件地定义 EABI 属性的示例:

The C source code files find the TARGET_ARMEABI symbol properly defined, however the assembler files don't. (I require this in order to define proper EABI attributes according the architecture). This is an example of how I attempt to conditionally define EABI attributes in the 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 greatly appreciated.

推荐答案

程序集文件需要以大写 S 结尾(.S.sx)以进行预处理gcc.请参阅 GCC 文档,3.2 控制输出类型的选项.

Assembly files needs to end with capital S (.S or .sx) to be preprocessed by gcc. See GCC doc, 3.2 Options Controlling the Kind of Output about that.

我相信你可以从 Bionic 来源,例如来自 libc/arch-arm/bionic/memcpy.S.

I believe you can cheat from Bionic sources, for example from libc/arch-arm/bionic/memcpy.S.

这篇关于在 Android.mk 中为程序集 (.s) 源文件定义符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆