请问如何才能用NDK编译Android程序顺利执行不出现not executable: magic 7F451错误

lengx7 lengx7 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
编译环境:32位android-ndk-r10e-windows-x86/android-ndk-r14b-windows-x86 + ctgwin + jdk1.8.0_131

Application.mk文件:
APP_ABI := armeabi-v7a
#APP_ABI := armeabi
APP_PLATFORM = android-19

Android.mk文件:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := poison
LOCAL_SRC_FILES := poison.c
LOCAL_LDLIBS += -L$(SYSROOT)/usr/lib -llog
include $(BUILD_EXECUTABLE)

使用ndk-build编译后,输出文件为poison,把程序push到虚拟机,chmod 0777执行,提示"not executable: magic 7F451"
IDA自带的android_server在虚拟机中可以执行,用readelf查看文件信息发现android_server和poison文件的Type类型一个是"EXEC (Executable file)"一个是"DYN (Shared object file)",不知道是否由于这个问题导致poison无法执行,如果是的话,请问该如何修改才能让程序可执行呢?

android_server:
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: EXEC (Executable file)
Machine: ARM
Version: 0x1
Entry point address: 0xd8b0
Start of program headers: 52 (bytes into file)
Start of section headers: 569984 (bytes into file)
Flags: 0x4000002, has entry point, Version4 EABI
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 7
Size of section headers: 40 (bytes)
Number of section headers: 23
Section header string table index: 22

poison:
ELF Header:
Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: UNIX - System V
ABI Version: 0
Type: DYN (Shared object file)
Machine: ARM
Version: 0x1
Entry point address: 0xb38
Start of program headers: 52 (bytes into file)
Start of section headers: 62048 (bytes into file)
Flags: 0x5000000, Version5 EABI
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 8
Size of section headers: 40 (bytes)
Number of section headers: 34
Section header string table index: 33


cygwin信息:
$ gcc --version
gcc (GCC) 6.3.0
Copyright 2016 Free Software Foundation, Inc.
本程序是自由软件;请参看源代码的版权声明。本软件没有任何担保;
包括没有适销性和某一专用目的下的适用性担保。


$ g++ --version
g++ (GCC) 6.3.0
Copyright 2016 Free Software Foundation, Inc.
本程序是自由软件;请参看源代码的版权声明。本软件没有任何担保;
包括没有适销性和某一专用目的下的适用性担保。


$ make -version
GNU Make 4.2.1
为 i686-pc-cygwin 编译
Copyright (C) 1988-2016 Free Software Foundation, Inc.
许可证:GPLv3+:GNU 通用公共许可证第 3 版或更新版本<http://gnu.org/licenses/gpl. html>。
本软件是自由软件:您可以自由修改和重新发布它。
在法律允许的范围内没有其他保证。


$ gdb --version
GNU gdb (GDB) (Cygwin 7.11.1-2) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-cygwin".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".

...全文

相关推荐

评论 7
收藏 已收藏
分享
返回顶部
lengx7
Android 80,490 成员 91,371 内容