首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ARM交叉编译

ARM交叉编译
EN

Stack Overflow用户
提问于 2013-01-10 16:31:35
回答 1查看 3K关注 0票数 3

我已经在我的x86 Ubuntu12.04Linux上安装了ARM交叉编译器工具链。

现在我有了arm-linux-gnueabi-gcc交叉编译器。

我已经编写了简单的hello world程序如下

代码语言:javascript
复制
#include <stdio.h>
int main(){
  printf("hello world\n");
  return 0;
}

我用以下命令交叉编译了这个程序

arm-linux-gnueabi-gcc -o a a.c -static

编译后的二进制文件的结果如下

$ file a: ELF 32位LSB可执行文件,ARM,版本1 (SYSV),静态行,用于GNU/Linux 2.6.31,未剥离

如果我在我的ARM上运行这个二进制文件,在QEMU上运行debian linux,它显示‘非法指令’。

但是如果我在我的ARM debian linux上用gcc编译相同的源代码,它运行得很好。

两个二进制文件上的文件结果是相同的。我的交叉编译的ARM二进制文件有什么问题??

提前谢谢你。

代码语言:javascript
复制
meltdown@meltdown-VirtualBox:/var/www$ arm-linux-gnueabi-readelf --file-header --arch-specific a
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:               0x8881
  Start of program headers:          52 (bytes into file)
  Start of section headers:          368052 (bytes into file)
  Flags:                             0x5000002, has entry point, Version5 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:         30
  Section header string table index: 27
Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "7-A"
  Tag_CPU_arch: v7
  Tag_CPU_arch_profile: Application
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-2
  Tag_FP_arch: VFPv3-D16
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align_needed: 8-byte
  Tag_ABI_align_preserved: 8-byte, except leaf SP
  Tag_ABI_enum_size: int
  Tag_ABI_HardFP_use: SP and DP
  Tag_CPU_unaligned_access: v6
  Tag_DIV_use: Not allowed
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-01-10 17:43:04

您能否运行readelf命令来确定您的交叉编译器针对的是哪个ARM体系结构?我们需要看看Qemu是否支持这个目标。

代码语言:javascript
复制
arm-linux-gnueabi-readelf --file-header --arch-specific a

此外,您可以在仿真系统中检查dmesg的输出。它应该包含对非法指令的描述。

此外,您还可以在调试器中运行程序,以查看哪个指令失败。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14253626

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档