2017-03-18 7 views
0

これで、mips実行可能ファイルにアセンブリで書かれた簡単なプログラム(MARSを使用して)をクロスコンパイルしようとしています。クロスコンパイルmips:リンカエラー:エントリシンボル__startが見つかりません。

# Purpose: First program, Hello World 
.text   # Define the program instructions. 
main:   # Label to define the main program. 
li $v0,4   #Load 4into $v0 to indicate a print string. 
la $a0, greeting #Load the address of the greeting into $a0. 
syscall   #Print greeting. The print is indicated by 
       # $v0 having a value of 4, and the string to  
       # print is stored at the address in $a0. 
li $v0,10   #Load a 10 (halt) into $v0. 
syscall   # The program ends. 
.data   # Define the program data. 
greeting: .asciiz "Hello World" #The string to print. 

最初私は

mips-linux-ld HelloWorld.o -o HelloWorld 

その後、

mips-linux-as ./HelloWorld.asm -o HelloWorld.o 

を使用して、私はエラー

mips-linux-xld: warning: cannot find entry symbol __start; defaulting to 00000000004000b0 

は、単に_startセクションを追加すると私は同じerror.Soを取得する動作しません取得C(HelloWorld.c)で簡単なプログラムを書いたそして、アセンブリ次のコマンド

mips-linux-gcc -O2 -S -c HelloWorld.c 

でのgccを使用して何の_startセクション

.file 1 "HelloWorld.c" 
    .section .mdebug.abi32 
    .previous 
    .gnu_attribute 4, 3 
    .abicalls 
    .section .rodata.str1.4,"aMS",@progbits,1 
    .align 2 
$LC0: 
    .ascii "Hello Worldn\000" 
    .text 
    .align 2 
    .globl main 
    .set nomips16 
    .ent main 
    .type main, @function 
main: 
    .frame $sp,32,$31  # vars= 0, regs= 1/0, args= 16, gp= 8 
    .mask 0x80000000,-4 
    .fmask 0x00000000,0 
    .set noreorder 
    .set nomacro 

    addiu $sp,$sp,-32 
    sw $31,28($sp) 
    lui $28,%hi(__gnu_local_gp) 
    addiu $28,$28,%lo(__gnu_local_gp) 
    .cprestore 16 
    lui $4,%hi($LC0) 
    lw $25,%call16(printf)($28) 
    jalr $25 
    addiu $4,$4,%lo($LC0) 

    move $2,$0 
    lw $31,28($sp) 
    j $31 
    addiu $sp,$sp,32 

    .set macro 
    .set reorder 
    .end main 
    .size main, .-main 
    .ident "GCC: (GNU) 4.4.5-1.5.5p4" 

だから何イムが欠落はありません?生成私はこのプログラムを私のmipsボックスで実行したいと思います。

.globl main 
.ent main 
.type main, @function 

しかし、あなたのasmファイルにこれを追加すること

答えて

0

てみてください、あなたはMIPSのLinux syscallsはなく、MARSのシステムコールを使用する必要があります。

+0

同じ取引でエントリシンボル__startを見つけることができません。デフォルトは00000000004000b0 – Vido

関連する問題