编译MIPS使用分支,而不是跳跃

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

具有以下非常简单的C程序:

#include <stdio.h>
#include <stdlib.h>

int main()
{
        char *buffer = (char*)malloc(20);
}

并与mips-linux-gnu-gcc编译它,它看起来像调用编译以下说明:

.text:004007EC 24 04 00 14             li      $a0, 0x14
.text:004007F0 8F 82 80 50             la      $v0, malloc      # Load Address
.text:004007F4 00 40 C8 25             move    $t9, $v0
.text:004007F8 03 20 F8 09             jalr    $t9 ; malloc     # Jump And Link Register
.text:004007FC 00 00 00 00             nop

编译的完整命令行是:

mips-linux-gnu-gcc my_malloc.c -o my_malloc.so

不过,我想函数调用来编译,以平常心分支指令:

jal     malloc
li      $a0, 0x14

是否有人知道如何实现这样的结果?

gcc compilation mips code-generation addressing
1个回答
1
投票

你需要告诉编译器使用的PLT呼叫,使用the -mplt option。这需要在其它工具的PLT的支持。

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