1.2 Cross tool chain

Source: Internet
Author: User
Tags gcov

What's up? Cross tool chain

Collection of cross Tools

Cross Tool

Create hello.c

#include <stdio.h>

Int Main ()

{

???? Printf ("Hello wworld\n");

???? return 0;

}

[Email protected] ~]# Cd/home/s3-arm/part1/lesson2

[[email protected] lesson2]# ls

Hello hello.c

[Email protected] lesson2]# gcc hello.c-o Hello

[Email protected] lesson2]#./hello

Hello World

On the te6410.

[[Email protected]]# CD Udisk

[Email protected]]# ls

Hello type

[Email protected]]#./hello

./hello:line 1:syntax Error: "(" unexpected

Using cross-compiling

[Email protected] lesson2]# arm-linux-gcc-static hello.c-o hello-arm

[Email protected] lesson2]# arm-linux-gcc-static hello.c-o hello-arm

Running on PC

[Email protected] lesson2]#./hello-arm

-bash:./hello-arm:cannot Execute binary file

Te6410 Run

[[Email protected]]# CD udisk/

[Email protected]]# ls

Hello hello-arm type

[Email protected]]#./hello-arm

Hello World

The substance runs in different environments

[Email protected] lesson2]# mv Hello hello-x86

[[Email protected] lesson2]# file Hello-arm

Hello-arm:elf 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, for Gnu/linux 2.6.14, not stripped

[[Email protected] lesson2]# file hello-x86

Hello-x86:elf 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for Gnu/linux 2.6.18, not stripped

Cross-development

Cross tool chain

[Email protected] lesson2]# Ls/usr/local/arm/4.3.2/bin

Arm-linux-addr2line Arm-linux-objdump Arm-none-linux-gnueabi-gcov

Arm-linux-ar Arm-linux-ranlib Arm-none-linux-gnueabi-gdb

Arm-linux-as arm-linux-readelf Arm-none-linux-gnueabi-gdbtui

Arm-linux-c++ arm-linux-size Arm-none-linux-gnueabi-gprof

Arm-linux-c++filt Arm-linux-sprite Arm-none-linux-gnueabi-ld

Arm-linux-cpp arm-linux-strings arm-none-linux-gnueabi-nm

arm-linux-g++ Arm-linux-strip arm-none-linux-gnueabi-objcopy

ARM-LINUX-GCC Arm-none-linux-gnueabi-addr2line Arm-none-linux-gnueabi-objdump

arm-linux-gcc-4.3.2 Arm-none-linux-gnueabi-ar Arm-none-linux-gnueabi-ranlib

Arm-linux-gcov Arm-none-linux-gnueabi-as arm-none-linux-gnueabi-readelf

Arm-linux-gdb arm-none-linux-gnueabi-c++ Arm-none-linux-gnueabi-size

Arm-linux-gdbtui arm-none-linux-gnueabi-c++filt Arm-none-linux-gnueabi-sprite

Arm-linux-gprof Arm-none-linux-gnueabi-cpp arm-none-linux-gnueabi-strings

Arm-linux-ld arm-none-linux-gnueabi-g++ Arm-none-linux-gnueabi-strip

ARM-LINUX-NM ARM-NONE-LINUX-GNUEABI-GCC

Arm-linux-objcopy arm-none-linux-gnueabi-gcc-4.3.2

Common Cross Tools

1. ARM-LINUX-GCC used in the arm of the device compiler

With GCC looking for header file location not sample

GCC under the/usr/include

[Email protected] lesson2]# ls/usr/include/stdio.h

/usr/include/stdio.h

ARM-LINUX-GCC in

[Email protected] lesson2]# Arm-linux-gcc-print-search-dirs

Install:/usr/local/arm/4.3.2/bin/. /lib/gcc/arm-none-linux-gnueabi/4.3.2/

Programs: =/usr/local/arm/4.3.2/bin/. /libexec/gcc/arm-none-linux-gnueabi/4.3.2/:/usr/local/arm/4.3.2/bin/. /libexec/gcc/:/usr/local/arm/4.3.2/bin/. /lib/gcc/arm-none-linux-gnueabi/4.3.2/. /.. /.. /.. /arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi/4.3.2/:/usr/local/arm/4.3.2/bin/. /lib/gcc/arm-none-linux-gnueabi/4.3.2/. /.. /.. /.. /arm-none-linux-gnueabi/bin/

Libraries: =/usr/local/arm/4.3.2/bin/. /lib/gcc/arm-none-linux-gnueabi/4.3.2/armv4t/:/usr/local/arm/4.3.2/bin/. /lib/gcc/armv4t/:/usr/local/arm/4.3.2/bin/. /lib/gcc/arm-none-linux-gnueabi/4.3.2/. /.. /.. /.. /arm-none-linux-gnueabi/lib/arm-none-linux-gnueabi/4.3.2/armv4t/:/usr/local/arm/4.3.2/bin/. /lib/gcc/arm-none-linux-gnueabi/4.3.2/. /.. /.. /.. /arm-none-linux-gnueabi/lib/armv4t/:/usr/local/arm/4.3.2/bin/. /arm-none-linux-gnueabi/libc/armv4t/lib/arm-none-linux-gnueabi/4.3.2/armv4t/:/usr/local/arm/4.3.2/bin/. /arm-none-linux-gnueabi/libc/armv4t/lib/armv4t/:/usr/local/arm/4.3.2/bin/. /arm-none-linux-gnueabi/libc/armv4t/usr/lib/arm-none-linux-gnueabi/4.3.2/armv4t/:/usr/local/arm/4.3.2/bin/. /arm-none-linux-gnueabi/libc/armv4t/usr/lib/armv4t/:/usr/local/arm/4.3.2/bin/. /lib/gcc/arm-none-linux-gnueabi/4.3.2/:/usr/local/arm/4.3.2/bin/. /lib/gcc/:/usr/local/arm/4.3.2/bin/. /lib/gcc/arm-none-linux-gnueabi/4.3.2/. /.. /.. /.. /arm-none-linux-gnueabi/lib/arm-none-linux-gnueabi/4.3.2/:/usr/local/arm/4.3.2/bin/. /lib/gcc/arm-none-linux-gnueabi/4.3.2/. /.. /.. /.. /arm-none-linux-gnueabi/lib/:/usr/local/arm/4.3.2/bin/. /arm-none-linux-gnueabi/libc/armv4t/lib/arm-none-linux-gnueabi/4.3.2/:/usr/local/arm/4.3.2/bin/. /arm-none-linux-gnueabi/libc/armv4t/lib/:/usr/local/arm/4.3.2/bin/. /arm-none-linux-gnueabi/libc/armv4t/usr/lib/arm-none-linux-gnueabi/4.3.2/:/usr/local/arm/4.3.2/bin/. /arm-none-linux-gnueabi/libc/armv4t/usr/lib/

2. ARM-LINUX-LD Connector

Arm-tools Hello Led.bin led.lds led. S

arm-tools.tar.gz hello.c led.elf LED.O Makefile

[[email protected] lesson1]# arm-linux-gcc-g-C LED. S

[[email protected] lesson1]# ls

Arm-tools Hello Led.bin led.lds led. S

arm-tools.tar.gz hello.c led.elf LED.O Makefile

[Email protected] lesson1]# Arm-linux-ld-tled.lds-o led.elf LED.O

[[email protected] lesson1]# ls

Arm-tools Hello Led.bin led.lds led. S

arm-tools.tar.gz hello.c led.elf LED.O Makefile

3. am-linux-readelf reading elf format files

-A file header

[Email protected] lesson1]# arm-linux-readelf-a led.elf

ELF Header:

magic:7f 4c 46 01 01 01 00 00 00 00 00 00 00 00 00

Class:elf32

Data:2 ' s complement, little endian

Version:1 (current)

Os/abi:unix-system V

ABI version:0

Type:exec (executable file)

Machine: ARM

version:0x1

Entry Point address:0x50008000

Start of Program headers:52 (bytes to file)

Start of section headers:33352 (bytes to file)

FLAGS:0X5000002, had entry point, Version5 EABI

Size of this header:52 (bytes)

Size of Program headers:32 (bytes)

Number of program Headers:1

Size of section headers:40 (bytes)

Number of section Headers:10

Section header string Table Index:7

?

Section Headers:

[Nr] Name Type Addr Off Size ES Flg Lk Inf Al

[0] NULL 00000000 000000 000000 00 0 0 0

[1]. Text progbits 50008000 008000 0000e0 xx AX 0 0 4

[2]. Arm.attributes Arm_attributes 00000000 0080e0 000018 00 0 0 1

[3]. debug_line Progbits 00000000 0080f8 000064 00 0 0 1

[4]. Debug_info Progbits 00000000 00815c 00004a 00 0 0 1

[5]. Debug_abbrev Progbits 00000000 0081a6 000014 00 0 0 1

[6]. debug_aranges Progbits 00000000 0081c0 000020 00 0 0 8

[7]. Shstrtab Strtab 00000000 0081e0 000066 00 0 0 1

[8]. Symtab Symtab 00000000 0083d8 0001a0 10 9 23 4

[9]. strtab Strtab 00000000 008578 0000c3 00 0 0 1

Key to Flags:

W (Write), A (Alloc), X (execute), M (merge), S (strings)

I (info), L (link order), G (group), X (unknown)

O (extra OS processing required) O (OS specific), p (processor specific)

?

There is no section groups in this file.

?

Program Headers:

Type Offset virtaddr physaddr filesiz memsiz Flg Align

LOAD 0x008000 0x50008000 0x50008000 0x000e0 0x000e0 R E 0x8000

?

Section to Segment Mapping:

Segment Sections ...

xx. Text

?

There is the no dynamic section in this file.

?

There is no relocations in the this file.

?

There is no unwind sections in this file.

?

Symbol table '. Symtab ' contains-entries:

Num:value Size Type Bind Vis Ndx Name

0:00000000 0 notype LOCAL DEFAULT UND

1:50008000 0 Section LOCAL DEFAULT 1

2:00000000 0 Section LOCAL DEFAULT 2

3:00000000 0 Section LOCAL DEFAULT 3

4:00000000 0 Section LOCAL DEFAULT 4

5:00000000 0 Section LOCAL DEFAULT 5

6:00000000 0 Section LOCAL DEFAULT 6

7:50008000 0 Notype LOCAL DEFAULT 1 $a

8:5000803c 0 notype LOCAL DEFAULT 1 Reset

9:50008020 0 notype LOCAL DEFAULT 1 _undefined_instruction

10:50008024 0 notype LOCAL DEFAULT 1 _software_interrupt

11:50008028 0 notype LOCAL DEFAULT 1 _prefetch_abort

12:5000802c 0 notype LOCAL DEFAULT 1 _data_abort

13:50008030 0 notype LOCAL DEFAULT 1 _not_used

14:50008034 0 notype LOCAL DEFAULT 1 _IRQ

15:50008038 0 notype LOCAL DEFAULT 1 _fiq

16:50008064 0 notype LOCAL DEFAULT 1 set_peri_port

17:50008074 0 notype LOCAL DEFAULT 1 Disable_watchdog

18:50008084 0 notype LOCAL DEFAULT 1 DISABLE_IRQ

19:500080a0 0 notype LOCAL DEFAULT 1 init_led

20:500080b0 0 notype LOCAL DEFAULT 1 light_led

21:50008060 0 Notype LOCAL DEFAULT 1 halt

22:500080c8 0 notype LOCAL DEFAULT 1 $d

23:50008000 0 notype GLOBAL DEFAULT 1 _start

24:500080E0 0 notype GLOBAL DEFAULT ABS __bss_start

25:500080E0 0 notype GLOBAL DEFAULT ABS _end

?

No version information found in the this file.

Attribute Section:aeabi

File Attributes

Tag_cpu_name: "4T"

tag_cpu_arch:v4t

Tag_arm_isa_use:yes

Add: If the program does not run

    1. The referencing program is not running on the arm platform
    2. Size End
    3. Library is not used

[Email protected] lesson1]# arm-linux-readelf-d hello-d

?

Dynamic section at offset 0x448 contains entries:

Tag Type Name/value

0x00000001 (NEEDED) Shared Library: [libc.so.6]

0x0000000c (INIT) 0x8274

0x0000000d (FINI) 0x8414

0x00000019 (Init_array) 0x1043c

0X0000001B (Init_arraysz) 4 (bytes)

0X0000001A (Fini_array) 0x10440

0X0000001C (Fini_arraysz) 4 (bytes)

0x00000004 (HASH) 0x8168

0x00000005 (Strtab) 0x81e0

0x00000006 (Symtab) 0x8190

0x0000000a (Strsz) (bytes)

0X0000000B (syment) (bytes)

0x00000015 (DEBUG) 0x0

0x00000003 (Pltgot) 0x10530

0x00000002 (PLTRELSZ) (bytes)

0x00000014 (Pltrel) REL

0x00000017 (Jmprel) 0x8254

0x00000011 (REL) 0x824c

0x00000012 (relsz) 8 (bytes)

0x00000013 (relent) 8 (bytes)

0x6ffffffe (verneed) 0x822c

0X6FFFFFFF (verneednum) 1

0X6FFFFFF0 (Versym) 0x8222

0x00000000 (NULL) 0x0

3. Arm-linux-objdump Disassembler

[[Email protected] lesson1]# file hello-d

Hello-d: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for Gnu/linux 2.6.14, no T stripped

[[email protected] lesson1]# arm-linux-objdump-d-S hello-d > Dump

[[email protected] lesson1]# VIM dump

?

?

Hello-d: File Format elf32-littlearm

?

Disassembly of section. Interp:

?

00008134 <.interp>:

8134:62696c2f rsbvs R6, R9, #12032; 0x2f00

8138:2d646c2f Stclcs, CR6, [R4, #-188]!

813c:756e696c STRBVC R6, [LR, #-2412]!

8140:6f732e78 Svcvs 0x00732e78

8144:address 0x00008144 is out of bounds.

?

Disassembly of section. Note. Abi-tag:

?

00008148 <.note. Abi-tag>:

8148:00000004. Word 0x00000004

814c:00000010. Word 0x00000010

8150:00000001. Word 0x00000001

8154:00554e47. Word 0x00554e47

8158:00000000. Word 0x00000000

815c:00000002. Word 0x00000002

8160:00000006. Word 0x00000006

8164:0000000e. Word 0x0000000e

Disassembly of section. Hash:

00008168 <.hash>:

"Dump" 384L, 13119C

[Email protected] lesson1]# ARM-LINUX-GCC hello.c-g-o hello-d

hello.c:in function ' main ':

Hello.c:4: Warning:return type of ' main ' is not ' int '

[[email protected] lesson1]# arm-linux-objdump-d-S hello-d > Dump

[[email protected] lesson1]# VIM dump

0000837c <main>:

#include <stdio.h>

?

void Main ()

{

837c:e92d4800 Push {FP, LR}

8380:e28db004 add FP, SP, #4; 0x4

printf ("Hello world\n");

8384:e59f000c Ldr r0, [pc, #12]; 8398 <main+0x1c>

8388:EBFFFFCB BL 82BC <_init+0x48>

}

838c:e24bd004 Sub sp, FP, #4; 0x4

8390:e8bd4800 Pop {fp, LR}

8394:E12FFF1E BX LR

8398:00008424. Word 0x00008424

5. arm-linux-objcopy file Format Converter

Elfà2 in-process file

[Email protected] lesson1]# arm-linux-objcopy-o binary led.elf led.bin

Led.bin Bare Metal to run

Summarize

The last is the function of the tool

Arm-linux-xxx-help

1.2 Cross tool chain

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.