如何使用gcc禁用ARM协处理器指令?

问题描述 投票:1回答:1

最近的gcc是否有办法禁用协处理器指令的使用:CDP,LDC,STC,MCR和MRC?

它们似乎被分组在名为arm_coproc1_ok的autoconf变量中。

我试图设置选项-march = armv4-mfloat-abi = soft,但没有任何帮助。我的二进制文件始终包含说明。

无论是我的源代码还是libc(newlib),我都会找到copro指令。

此c ++代码源,

double Bbp::S(int j)
{
    double s = 0.0;        // Summation of Total, Left
    double t;              // Each term of right summation
    int    r;              // Denominator
    int    k;              // Loop index
    double EPS = 1.0e-17;  // Loop-exit accuration of the right summation

    // Left Sum (0 ... d)
    for (k = 0; k <= d; k++) {
        r = 8 * k + j;
        t = (double)compModExp(16, d - k, r);
        t /= r;
        s += t - (int)t;
        s -= (int)s;
    }

    // Right sum (d + 1 ...)
    while (1) {
        r = 8 * k + j;
        t = std::pow(16.0, (double)(d - k));
        t /= (double)r;
        if (t < EPS) break;
        s += t;
        s -= (int)s;
        k ++;
    }

    return s;
}

...生成此二进制文件(位于0x44c的stc):

000001c0 <_ZN3Bbp1SEi>:
 1c0:   e52de004        push    {lr}            ; (str lr, [sp, #-4]!)
 1c4:   e24dd034        sub     sp, sp, #52     ; 0x34
 1c8:   e58d0004        str     r0, [sp, #4]
 1cc:   e58d1000        str     r1, [sp]
 1d0:   e3a02000        mov     r2, #0
...
 440:   e49df004        pop     {pc}            ; (ldr pc, [sp], #4)
 444:   e1a00000        nop                     ; (mov r0, r0)
 448:   4646d497                        ; <UNDEFINED> instruction: 0x4646d497
 44c:   3c670ef5        stclcc  14, cr0, [r7], #-980    ; 0xfffffc2c

与newlib的libc.a在0x080(mrc指令)处的相同注释:

00000028 <etens>:
  28:   4a926576        bmi     fe499608 <enan+0xfe49565c>
  2c:   153f804a        ldrne   r8, [pc, #-74]! ; ffffffea <enan+0xffffc03e>
  30:   979ac94c        ldrls   ip, [sl, ip, asr #18]
...
  5c:   75868175        strvc   r8, [r6, #373]  ; 0x175
  60:   4d48c976        vstrmi.16       s25, [r8, #-236]        ; 0xffffff14    ; <UNPREDICTABLE>
  64:   58f89c66        ldmpl   r8!, {r1, r2, r5, r6, sl, fp, ip, pc}^
  68:   5c54bc50        mrrcpl  12, 5, fp, r4, cr0
  6c:   91c6cc65        bicls   ip, r6, r5, ror #24
  70:   a0aea60e        adcge   sl, lr, lr, lsl #12
  74:   46a3e319        ssatmi  lr, #4, r9, lsl #6
  78:   eab7851e        b       fede14f8 <enan+0xfeddd54c>
  7c:   901b98fe                        ; <UNDEFINED> instruction: 0x901b98fe
  80:   de8dddbb        mcrle   13, 4, sp, cr13, cr11, {5}

...尤其明显。

谢谢。

gcc arm bare-metal
1个回答
0
投票

您正在将文字库(数据)作为代码读取。这些“指令”将永远不会执行。

尝试转动您的

double EPS = 1.0e-17;  // Loop-exit accuration of the right summation

恒定为十六进制,您将看到为什么没有大量的GCC选项会从生成的二进制文件中消除这一点的原因!

© www.soinside.com 2019 - 2024. All rights reserved.