This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

调用x264中arm汇编文件arm.S文件,编译报错

我想调用x264中的arm.S文件,我创建了一个test.S文件,在改文件中定义如下:

#include "asm.S"

.text

function x264_prefetch_ref_arm

    sub         r2, r2, #1

    add         r0, r0, #64

    and         r2, r2, r1

    add         r0, r0, r2, lsl #3

    add         r2, r1, r1, lsl #1

    pld         [r0]

    pld         [r0, r1]

    pld         [r0, r1, lsl #1]

    add         r3, r0, r1, lsl #2

    pld         [r0, r2]

    pld         [r3]

    pld         [r3, r1]

    pld         [r3, r1, lsl #1]

    pld         [r3, r2]

    bx          lr

endfunc

编译的时候报错:

bad instruction `endfunc'

bad instruction `function x264_prefetch_ref_arm'

这个是跟编译器有关系吗?

我用的是的linaro编译器gcc-linaro-arm-linux-gnueabihf-4.9-2014.09。

另外有个疑问,汇编中直接使用#include<>的对吗?不是应该用.include<>吗?

我吧#改成.后,发现编译错误又变成:

bad instruction `elf .hidden EXTERN_ASMx264_prefetch_ref_arm'

bad instruction `elf .size x264_prefetch_ref_arm,.-x264_prefetch_ref_arm'

bad instruction `elf .type EXTERN_ASMx264_prefetch_ref_arm,%function'

bad instruction `func .endfunc'

bad instruction `func .func EXTERN_ASMx264_prefetch_ref_arm'

麻烦帮我解答下,谢谢。

Parents
  • 因为我这没有config.h文件,为了编译通过,做了如下更改:

    asm.S文件中去掉了#include "config.h" 和 .syntax unified 和.fpu neon这三行,

    用gcc-linaro-4.9-2015.02-x86_64_armeb-linux-gnueabihf 工具链可以编译通过,在test.S中增加main函数,可以生成可执行文件。

    所用的编译命令为:./gcc-linaro-4.9-2015.02-x86_64_armeb-linux-gnueabihf/bin/armeb-linux-gnueabihf-gcc -o test test.S

    readelf -h test

    ELF Header:

      Magic:   7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00

      Class:                             ELF32

      Data:                              2's complement, big endian

      Version:                           1 (current)

      OS/ABI:                            UNIX - System V

      ABI Version:                       0

      Type:                              EXEC (Executable file)

      Machine:                           ARM

      Version:                           0x1

      Entry point address:               0x102c1

      Start of program headers:          52 (bytes into file)

      Start of section headers:          5212 (bytes into file)

      Flags:                             0x5800402, has entry point, Version5 EABI, BE8, <unknown>

      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:         38

      Section header string table index: 35

    是否是编译器版本还是别的原因就不清楚了。

Reply
  • 因为我这没有config.h文件,为了编译通过,做了如下更改:

    asm.S文件中去掉了#include "config.h" 和 .syntax unified 和.fpu neon这三行,

    用gcc-linaro-4.9-2015.02-x86_64_armeb-linux-gnueabihf 工具链可以编译通过,在test.S中增加main函数,可以生成可执行文件。

    所用的编译命令为:./gcc-linaro-4.9-2015.02-x86_64_armeb-linux-gnueabihf/bin/armeb-linux-gnueabihf-gcc -o test test.S

    readelf -h test

    ELF Header:

      Magic:   7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00

      Class:                             ELF32

      Data:                              2's complement, big endian

      Version:                           1 (current)

      OS/ABI:                            UNIX - System V

      ABI Version:                       0

      Type:                              EXEC (Executable file)

      Machine:                           ARM

      Version:                           0x1

      Entry point address:               0x102c1

      Start of program headers:          52 (bytes into file)

      Start of section headers:          5212 (bytes into file)

      Flags:                             0x5800402, has entry point, Version5 EABI, BE8, <unknown>

      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:         38

      Section header string table index: 35

    是否是编译器版本还是别的原因就不清楚了。

Children