简体   繁体   English

交叉编译mips:链接器错误:找不到条目符号__start;

[英]cross compiling mips: Linker error: cannot find entry symbol __start;

So Im trying to cross compile simple program written in assembly (using MARS) to mips executable. 因此,我试图交叉编译用汇编编写的简单程序(使用MARS)以欺骗可执行文件。

# 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.

first I use 首先我用

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

then 然后

mips-linux-ld HelloWorld.o -o HelloWorld

and I get an error 我得到一个错误

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

Simply adding _start section does not work I get same error.So I written simple program in C (HelloWorld.c) and generated assembly using gcc with following command 简单地添加_start部分不起作用,我会得到相同的错误。所以我用C(HelloWorld.c)编写了简单的程序,并使用以下命令使用gcc生成了程序集

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

and there is no _start section 而且没有_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"

So what Im missing ? 那我想念什么呢? I would like to run this program on my mips box. 我想在我的mips盒子上运行该程序。

Try adding this to your asm file 尝试将其添加到您的asm文件中

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

However, you will need to use MIPS Linux syscalls , and not MARS syscalls. 但是,您将需要使用MIPS Linux 系统调用 ,而不是MARS系统调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 警告:在编译为.so时找不到条目符号_start- - warning: cannot find entry symbol _start - while compiling to .so 加载警告:找不到入口符号_start - load warning: cannot find entry symbol _start 交叉编译错误“ arm-none-eabi-g ++找不到条目符号” - Cross compile error “arm-none-eabi-g++ cannot find entry symbol” (Java)编译时出现“错误:找不到符号”? - (Java) “error: cannot find symbol” when compiling? arm-eabi-gcc:找不到条目符号_start - arm-eabi-gcc: cannot find entry symbol _start ld:警告:找不到入口符号_start; 默认为 0000000000401000 - ld: warning: cannot find entry symbol _start; defaulting to 0000000000401000 azure-iot-sdk-c 交叉编译链接器问题:ld:找不到 -luuid - azure-iot-sdk-c cross-compiling linker issue: ld: cannot find -luuid NVCC CUDA 交叉编译找不到“-lcudart” - NVCC CUDA cross compiling cannot find “-lcudart” 与CMake交叉编译的软件包:如何设置链接器路径以找到编译器支持库? - Cross-compiling package with CMake: how to set linker path to find compiler support library? 错误:使用cargo从windows交叉编译一个rust项目到linux时“找不到链接器‘cc’” - Error: “linker 'cc' not found” when cross compiling a rust project from windows to linux using cargo
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM