简体   繁体   中英

Why was exec_elf.h removed from the Android NDK?

Looking in Android NDK r12, I can see that there are differences in the header files under platforms/android-{API level}/{arch}/usr/include/sys. For API levels 19 and below, the file exec_elf.h exists, but appears to have been removed after that. There are a number of other differences where files were added or removed, but I'm interested in exec_elf.h because it defines a particular macro:

#define ELF64_ST_INFO(b,t)      (((b) << 4) + ((t) & 0xf))

This macro is used in the ICU source, and my cross-compiled build of ICU fails if I use a toolchain with the API target set to anything after 19. The build fails with these errors:

   arm-linux-androideabi-clang   ...  icu/source/tools/toolutil/pkg_genc.c
icu/source/tools/toolutil/pkg_genc.c:869:13: warning: implicit declaration of function 'ELF64_ST_INFO' is invalid in C99 [-Wimplicit-function-declaration]
            ELF64_ST_INFO(STB_GLOBAL, STT_OBJECT),
            ^
icu/source/tools/toolutil/pkg_genc.c:869:13: error: initializer element is not a compile-time constant
            ELF64_ST_INFO(STB_GLOBAL, STT_OBJECT),
            ^~~~~~~~~~~~~~~~~~~
icu/source/tools/toolutil/pkg_genc.c:987:13: error: initializer element is not a compile-time constant
            ELF64_ST_INFO(STB_GLOBAL, STT_OBJECT),

The compile line is as follows:

android-toolchain/bin/arm-linux-androideabi-clang -D_REENTRANT -DU_HAVE_ELF_H=1 \
-DU_HAVE_ATOMIC=1 -Iicu/source/common -Iicu/source/i18n \
-DU_BUILD="x86_64-apple-darwin15.2.0" -DU_HOST="arm-unknown-linux-androideabi" \
-DU_CC="android-toolchain/bin/arm-linux-androideabi-clang" \
-DU_CXX="android-toolchain/bin/arm-linux-androideabi-clang++" \
-DUNISTR_FROM_CHAR_EXPLICIT=explicit -DUNISTR_FROM_STRING_EXPLICIT=explicit \
-DU_ATTRIBUTE_DEPRECATED= -DU_TOOLUTIL_IMPLEMENTATION -O3 -O2 -pipe -fsigned-char \
-fPIC -D__ANDROID__ -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -std=c99 \
-Wall -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -c \
-DPIC -fPIC -o pkg_genc.o icu/source/tools/toolutil/pkg_genc.c

I can get the build to succeed by adding the definition of ELF64_ST_INFO at the top of pkg_genc.c, so I'm pretty positive that the lack of the definition of this macro in the Android system headers is the issue. Does anyone know why this changed across API levels? Is this difference intentional, or is this a bug in the NDK?

This was a bug in the NDK. To illustrate the importance of filing bugs, this was filed 8 hours ago and we already have a fix going through presubmit: https://github.com/android-ndk/ndk/issues/377 . The fix should be available in r15 beta 2, due out at I/O (17 May).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM