如何解决交叉编译的crt0.o中的问题? [英] How to solve the crt0.o issue in cross compiling?
问题描述
如何添加 ctr0.o
?
我得到这个错误:
yagarto-4.7.2 /斌/ ARM-NONE-EABI-LD:找不到的crt0.o:没有这样的文件或目录
collect2:错误:LD返回1退出status`
/ * - * first.s /
/ *这是一个注释* /
。全球主要/ *'主'是我们的切入点,而且必须是全球性的* /
.FUNC主/ *'主'是一个函数* /主:/ *这是主* /
MOV R0,#2 / *把2寄存器R0 *内部/
BX LR / *从主*返回/
我已经看到了这些2个线程,并没有得到任何全面和直截了当的回答:
我有这些文件,是我不能用它和信息crt0 CRTN区别?
./ yagarto-4.7.2 / lib中/ GCC /臂无 - EABI / 4.7.2 / crtbegin.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/crtend.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/crti.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/crtn.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/thumb/crtbegin.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/thumb/crtend.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/thumb/crti.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/thumb/crtn.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/thumb/v6m/crtbegin.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/thumb/v6m/crtend.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/thumb/v6m/crti.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/thumb/v6m/crtn.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/thumb/v7m/crtbegin.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/thumb/v7m/crtend.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/thumb/v7m/crti.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/thumb/v7m/crtn.o
在做方案给周围的工作不工作过:
臂无 - EABI - 海合会-o第一assembler_tutorial / CHAPTER01 / first.o -nostartfiles
./yagarto-4.7.2/bin/arm-none-eabi-ld:警告:无法找到入口符号_start;默认为0000000000008000
vectors.s
.globl _start
_开始:
MOV SP,#为0x8000
BL主
挂:乙杭
main.s
.globl主
主要:
MOV R0,#2
BX LR
MEMMAP(链接脚本)
MEMORY
{
RAM:ORIGIN = 0x8000的,长度=为0x10000
}
截面
{
的.text:{*(。*文)}>随机存取存储器
.bss中:{*(。* BSS)}>随机存取存储器
}
命令
臂无 - EABI - 作为vectors.s -o vectors.o中
臂无 - EABI - 作为main.s -o main.o中
臂无 - EABI-LD vectors.o中main.o中-T MEMMAP -o main.elf
臂无 - EABI-objdump的-D main.elf> main.list
臂无 - EABI-objcopy把main.elf -O二进制main.bin
结果
main.elf:文件格式ELF32-littlearm
.text段拆卸:00008000< _start计算值:
8000:e3a0d902 MOV SP,#32768;为0x8000
8004:eb000000 BL 800C<主>00008008<恒生计算值:
8008:eafffffe b&8008 LT;挂>0000800c<主计算值:
800C:e3a00002 MOV R0,#2
8010:e12fff1e BX LR
如果你想用C代替ASM主然后
的main.c
INT主要(无效)
{
返回(2);
}
命令
臂无 - EABI - 作为vectors.s -o vectors.o中
臂无 - EABI - 海合会-Wall -O2 -Werror -nostdlib -nostartfiles -ffreestanding -c main.c中-o main.o中
臂无 - EABI-LD vectors.o中main.o中-T MEMMAP -o main.elf
臂无 - EABI-objdump的-D main.elf> main.list
臂无 - EABI-objcopy把main.elf -O二进制main.bin
结果
main.elf:文件格式ELF32-littlearm
.text段拆卸:00008000< _start计算值:
8000:e3a0d902 MOV SP,#32768;为0x8000
8004:eb000000 BL 800C<主>00008008<恒生计算值:
8008:eafffffe b&8008 LT;挂>0000800c<主计算值:
800C:e3a00002 MOV R0,#2
8010:e12fff1e BX LR
我preFER使用比其他主函数的名字,因为一些编译器添加额外的行李,当他们看到函数名。
vectors.s
.globl _start
_开始:
MOV SP,#为0x8000
BL notmain
挂:乙杭
的main.c
INT notmain(无效)
{
返回(2);
}
结果
main.elf:文件格式ELF32-littlearm
.text段拆卸:00008000< _start计算值:
8000:e3a0d902 MOV SP,#32768;为0x8000
8004:eb000000 BL 800C< notmain>00008008<恒生计算值:
8008:eafffffe b&8008 LT;挂>0000800c&所述; notmain计算值:
800C:e3a00002 MOV R0,#2
8010:e12fff1e BX LR
How to add ctr0.o
?
I get this error:
yagarto-4.7.2/bin/arm-none-eabi-ld: cannot find crt0.o: No such file or directory
collect2: error: ld returned 1 exit status`
while compiling very simple program from here:
/* -- first.s */
/* This is a comment */
.global main /* 'main' is our entry point and must be global */
.func main /* 'main' is a function */
main: /* This is main */
mov r0, #2 /* Put a 2 inside the register r0 */
bx lr /* Return from main */
I have seen these 2 threads and didn't get any full and straight forward answer:
- http://www.raspberrypi.org/phpBB3/viewtopic.php?t=50046
- What is the rationale behind removing crt0.o from gcc4.7.x?
I have these files, what is the difference between crt0 and crtn can't I use it?
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/crtbegin.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/crtend.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/crti.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/crtn.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/thumb/crtbegin.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/thumb/crtend.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/thumb/crti.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/thumb/crtn.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/thumb/v6m/crtbegin.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/thumb/v6m/crtend.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/thumb/v6m/crti.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/thumb/v6m/crtn.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/thumb/v7m/crtbegin.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/thumb/v7m/crtend.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/thumb/v7m/crti.o
./yagarto-4.7.2/lib/gcc/arm-none-eabi/4.7.2/thumb/v7m/crtn.o
The SO solution give a work around which doesn't work too:
arm-none-eabi-gcc -o first assembler_tutorial/chapter01/first.o -nostartfiles
./yagarto-4.7.2/bin/arm-none-eabi-ld: warning: cannot find entry symbol _start; defaulting to 0000000000008000
vectors.s
.globl _start
_start:
mov sp,#0x8000
bl main
hang: b hang
main.s
.globl main
main:
mov r0,#2
bx lr
memmap (linker script)
MEMORY
{
ram : ORIGIN = 0x8000, LENGTH = 0x10000
}
SECTIONS
{
.text : { *(.text*) } > ram
.bss : { *(.bss*) } > ram
}
commands
arm-none-eabi-as vectors.s -o vectors.o
arm-none-eabi-as main.s -o main.o
arm-none-eabi-ld vectors.o main.o -T memmap -o main.elf
arm-none-eabi-objdump -D main.elf > main.list
arm-none-eabi-objcopy main.elf -O binary main.bin
result
main.elf: file format elf32-littlearm
Disassembly of section .text:
00008000 <_start>:
8000: e3a0d902 mov sp, #32768 ; 0x8000
8004: eb000000 bl 800c <main>
00008008 <hang>:
8008: eafffffe b 8008 <hang>
0000800c <main>:
800c: e3a00002 mov r0, #2
8010: e12fff1e bx lr
If you want to use C instead of asm for main then
main.c
int main ( void )
{
return(2);
}
commands
arm-none-eabi-as vectors.s -o vectors.o
arm-none-eabi-gcc -Wall -Werror -O2 -nostdlib -nostartfiles -ffreestanding -c main.c -o main.o
arm-none-eabi-ld vectors.o main.o -T memmap -o main.elf
arm-none-eabi-objdump -D main.elf > main.list
arm-none-eabi-objcopy main.elf -O binary main.bin
result
main.elf: file format elf32-littlearm
Disassembly of section .text:
00008000 <_start>:
8000: e3a0d902 mov sp, #32768 ; 0x8000
8004: eb000000 bl 800c <main>
00008008 <hang>:
8008: eafffffe b 8008 <hang>
0000800c <main>:
800c: e3a00002 mov r0, #2
8010: e12fff1e bx lr
I prefer to use a function name other than main because some compilers add extra baggage when they see that function name.
vectors.s
.globl _start
_start:
mov sp,#0x8000
bl notmain
hang: b hang
main.c
int notmain ( void )
{
return(2);
}
result
main.elf: file format elf32-littlearm
Disassembly of section .text:
00008000 <_start>:
8000: e3a0d902 mov sp, #32768 ; 0x8000
8004: eb000000 bl 800c <notmain>
00008008 <hang>:
8008: eafffffe b 8008 <hang>
0000800c <notmain>:
800c: e3a00002 mov r0, #2
8010: e12fff1e bx lr
这篇关于如何解决交叉编译的crt0.o中的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!