试图编译第三方 bootstrap ,其中包括一些汇编.S代码,他们为Cortex A5 mpu提供了工具(使用arm-linux-gnueabihf-使用gcc-linaro-arm-linux-gnueabihf-4.7-2013.03),但是我遇到以下不良指示:

rfe lr

似乎支持rfe,所以我想知道这是否是编译器问题?
他们声称可以使用相同的工具进行编译,但更新已过时。他们的指南包括以下需求:
1. sudo apt-get install build-essential git-core libncurses5-dev
2. sudo apt-get install flex bison texinfo zip unzip zlib1g-dev gettext
3. sudo apt-get install gperf libsdl-dev libesd0-dev libwxgtk2.6-dev
4. sudo apt-get install uboot-mkimage
5. sudo apt-get install g++ xz-utils

但是,我可以找到的最终结果是:
  • “libwxgtk2.6-dev”替换为“libwxgtk3.0-dev”
  • “uboot-mkimage”替换为“u-boot-tools”
  • 必须添加“lib32z1”

  • 其他一切都安装良好。 (使用Ubuntu 16.04)

    输出:
    ~/at91bootstrap$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- mrproper
      CLEAN        obj and misc files!
      CLEAN        configuration files!
      CLEAN        binary files!
    
    
    ~/at91bootstrap$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sama5d4eksd_uboot_defconfig
    #
    # configuration written to .config
    #
    #
    # make dependencies written to .auto.deps
    # See top of this file before playing with this auto-preprequisites!
    #
    
    ~/at91bootstrap$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
    CC
    ========
    arm-linux-gnueabihf-gcc 4.7.3
    
    as FLAGS
    ========
    ...
    .
    .
    .
    AS        ~/at91bootstrap/driver/svc_handler.S
    CC        ~/at91bootstrap/driver/svc_mgr.c
    AS        ~/at91bootstrap/driver/monitor/mon_init.S
    AS        ~/at91bootstrap/driver/monitor/mon_switch.S
    ~/at91bootstrap/driver/monitor/mon_switch.S
    ~/at91bootstrap/driver/monitor/mon_switch.S: Assembler messages:
    ~/at91bootstrap/driver/monitor/mon_switch.S:94: Error: bad instruction `rfe lr'
    ~/at91bootstrap/driver/monitor/mon_switch.S:170: Error: bad instruction `rfe lr'
    Makefile:297: recipe for target ~/at91bootstrap/driver/monitor/mon_switch.o' failed
    make: *** [~/at91bootstrap/driver/monitor/mon_switch.o] Error 1
    

    最佳答案

    我能够重现您的问题。过程:创建一个名为rfe.S的文件

    .text
    .thumb
     rfe lr
    .end
    

    gcc 4.7.3:
    /opt/linaro/4.7.3/bin/arm-linux-gnueabihf-gcc -dumpversion
    4.7.3
    /opt/linaro/4.7.3/bin/arm-linux-gnueabihf-gcc -march=armv7-a -mtune=cortex-a5 -c -o rfe.o rfe.S
    rfe.S: Assembler messages:
    rfe.S:3: Error: bad instruction `rfe lr'
    

    好消息是,7.2.1可以正常工作,也就是说,在最坏的情况下,您可以修改构建过程以使用7.2.1编译有问题的.S文件:
    /opt/linaro/gcc-linaro-7.2.1-2017.11-x86_64_arm-eabi/bin/arm-eabi-gcc -dumpversion
    7.2.1
    /opt/linaro/gcc-linaro-7.2.1-2017.11-x86_64_arm-eabi/bin/arm-eabi-gcc -march=armv7-a -mtune=cortex-a5 -c -o rfe.o rfe.S
    /opt/linaro/gcc-linaro-7.2.1-2017.11-x86_64_arm-eabi/bin/arm-eabi-objdump -d rfe.o
    
    rfe.o:     file format elf32-littlearm
    
    
    Disassembly of section .text:
    
    00000000 <.text>:
       0:   e99e c000       rfeia   lr
    

    使用32位指令集时,rfe.S也会进行汇编:
    .text
    .arm
     rfe lr
    .end
    
    
    /opt/linaro/gcc-linaro-7.2.1-2017.11-x86_64_arm-eabi/bin/arm-eabi-objdump -d rfe.o
    
    rfe.o:     file format elf32-littlearm
    
    
    Disassembly of section .text:
    
    00000000 <.text>:
       0:   f89e0a00        rfeia   lr
    

    这可能是一种现象,即您尝试编译的代码确实需要与您认为需要的代码不同的链。
    我建议尝试使用7.2.1 Linaro toolchain,如果幸运的话,您的代码将按原样编译。如果不是,请尝试使用7.2.1组装有问题的文件。

    希望这个答案对您有所帮助。

    关于linux - 错误: bad instruction 'rfe lr' arm cross compiler,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49260892/

    10-09 07:05