Use connector LD to generate binary target files of different formats

Source: Internet
Author: User

 

From the GNU Website: (http://sourceware.org/binutils/docs/ld/Options.html#Options)

 

-- Oformat Output-format
LD May be configured to support more than one kind of object
File. If your LD Is configured this way, you can use
' -- Oformat 'Option to specify the binary format for the output
Object File. Even when LD Is configured to support alternative
Object formats, you don't usually need to specify this, LD
Shocould be configured to produce as a default output format the most
Usual format on each machine. Output-format Is a text string,
Name of a particle format supported by the BFD libraries. (You can
List the available binary formats' Objdump-I '.) The Script
Command Output_format Can also specify the output format,
This option overrides it. See BFD.

 

I try to translate it poorly:

-- Oformat Output-format
LDYou can configure more than one target file. If your LDYou can use' -- Oformat'Specifies the binary format of the output target file. Even if LDDifferent target formats are supported. You do not need to specify this option because LDThe default output format is configured as the most common format on each machine. Output-formatIs a string, a format name supported by the BFD library. (You can use the command' Objdump-I'List all available binary formats .) Script command Output_formatYou can also specify the output format, but this option will overwrite it. See BFD.

 

Below is my machine'Objdump-I'Output:

 

$ Objdump-I
BFD header file version (GNU binutils for Debian) 2.19.91.20090910
Elf32-i386
(Header little endian, data little endian)
I386
A. out-i386-linux
(Header little endian, data little endian)
I386
Pei-i386
(Header little endian, data little endian)
I386
Elf32-little
(Header little endian, data little endian)
I386
L1om
Elf32-big
(Header big endian, data big endian)
I386
L1om
Elf64-x86-64
(Header little endian, data little endian)
I386
Pei-x86-64
(Header little endian, data little endian)
I386
Elf64-l1om
(Header little endian, data little endian)
L1om
Elf64-little
(Header little endian, data little endian)
I386
L1om
Elf64-big
(Header big endian, data big endian)
I386
L1om
SREC
(Header endianness unknown, data endianness unknown)
I386
L1om
Symbolsrec
(Header endianness unknown, data endianness unknown)
I386
L1om
OpenGL
(Header endianness unknown, data endianness unknown)
I386
L1om
Tekhex
(Header endianness unknown, data endianness unknown)
I386
L1om
Binary
(Header endianness unknown, data endianness unknown)
I386
L1om
Ihex
(Header endianness unknown, data endianness unknown)
I386
L1om
Trad-core
(Header endianness unknown, data endianness unknown)

Elf32-i386 A. out-i386-linux pei-i386 elf32-little elf32-big
I386 elf32-i386 A. out-i386-linux pei-i386 elf32-little elf32-big
L1om ---------- ------------------ elf32-little elf32-big

Elf64-x86-64 pei-x86-64 elf64-l1om elf64-little SREC
I386 elf64-x86-64 pei-x86-64 ---------- elf64-little elf64-big SREC
L1om ------------ ---------- elf64-l1om elf64-little elf64-big SREC

Symbolsrec maid binary ihex Trad-core
I386 symbolsrec OpenGL tekhex binary ihex ---------
L1om symbolsrec OpenGL tekhex binary ihex ---------

 

Then you can use the following command to compile and connect yourSource codeTo generate the. binfile:

$ Ls

Boot. s

$ As-O boot. O boot. s
$ LD-O boot. Bin -- oformat binary boot. o

$ Ls

Boot. Bin Boot. O boot. s

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.