Merge "Fix the size of the NDK .note.android.ident ELF note."

This commit is contained in:
Elliott Hughes
2017-01-29 16:19:10 +00:00
committed by Gerrit Code Review

View File

@@ -23,6 +23,8 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// TODO: this file should just be a .S file like bionic's crtbrand.
/* The following trick defines int32_t w/o including <stdint.h>
We want "int" to be 4-byte. But just in case it isn't, the following
line turns into "typedef int int32_t[0]" and later fails with error messages
@@ -36,42 +38,20 @@ typedef int int32_t[sizeof(int) == 4];
#define ABI_SECTION ".note.android.ident"
#define ABI_NOTETYPE 1
#define ABI_ANDROID_API PLATFORM_SDK_VERSION
#define ABI_NDK_VERSION "%NDK_VERSION%"
#define ABI_NDK_BUILD_NUMBER "%NDK_BUILD_NUMBER%"
#define NDK_RESERVED_SIZE 64
#define L 9999
/*
* Special ".note" entry to tag an Android binary and specify the ABI version.
*
* For all arches except sparc, gcc emits the section directive for the
* following struct with a PROGBITS type. However, the section should be
* of NOTE type, according to the Generic SysV ABI spec.
*
* Unfortunately, there is no clean way to tell gcc to use another section type,
* so this C file (or the C file that includes it) must be compiled in multiple
* steps:
*
* - Compile the .c file to a .s file.
* - Edit the .s file to change the 'progbits' type to 'note', for the section
* directive that defines the .note.ABI-tag section.
* - Compile the .s file to an object file.
*
* These steps are done in the invididual Makefiles for each applicable arch.
*/
static const struct {
int32_t namesz;
int32_t descsz;
int32_t type;
char name[sizeof ABI_VENDOR];
char name[sizeof(ABI_VENDOR)];
int32_t android_api;
char ndk_version[NDK_RESERVED_SIZE];
char ndk_build_number[NDK_RESERVED_SIZE];
} abitag __attribute__ ((section (ABI_SECTION), aligned(4), used)) = {
sizeof ABI_VENDOR,
sizeof(int32_t),
sizeof(ABI_VENDOR),
sizeof(int32_t) + NDK_RESERVED_SIZE + NDK_RESERVED_SIZE,
ABI_NOTETYPE,
ABI_VENDOR,
ABI_ANDROID_API,