Link file An example of LDS parsing

Source: Internet
Author: User

began to construct the section. Since the syntax used is fixed, we just need to know one example and the rest can be extrapolate. Take the first section as an example:

. Text.head:AT (ADDR (. text.head)-Load_offset) {

_text =.; /* Text and read-only data * /

* (. text.head)

}: Text = 0x9090

. Text.head:AT (ADDR (. text.head)-Load_offset) {

_text =.; /* Text and read-only data * /

* (. text.head)

}: Text = 0x9090

. text.head specifies the name of the generated section, followed by a fixed syntax for the colon. The AT keyword is described earlier, specifying the load address of the section (LMA), and its complete expression is

at (expression)

expression expressions in parentheses specify the value of the LMA. In this example, the expression is represented by the

ADDR (. Text.head)-Load_offset

Calculations are obtained. Over here

ADDR (section)

Calculates the virtual address of a section, so the. Text.head's load address (LMA) is its physical address. Inside the curly braces, _text =.;

Defines a global variable whose value is "." The current value of the entire text segment, which is recorded in the start address: Here, because no section is created before the _text variable, _text has the following equivalence relationship:

_text = ADDR (. Text.head) =. = Load_offset + load_physical_addr;

* (. text.head) completed the specific section creation work, "*" on behalf of all input. o files, in parentheses. Text.head Specifies the section name that the linker is interested in.

* (Text.head)

Represents a section that is named. text.head from all input files and populated into the. Text.head sections of the destination file.

: Text

Specifies the segment of the newly generated section, where the text after the colon is the segment name, and the first section of the visible kernel is placed in the text segment.

= 0x9090

Specifies the fill of the section. The section extracted from the input file because of the code alignment, the second binary storage may be discontinuous, where the gap is specified in the section is filled with 0x9090. 0X90 is the machine code that assembles the instruction NOP, so it is equivalent to filling an empty operation between discontinuous code. At this point, the first section of the kernel is created, named. Text.head, consisting of the. Text.head section of the input file (not all files have. text.head section, The linker extracts content only from the file that has the section, and the virtual address (VMA) of the part is represented by "." The value of the load address (LMA) is its physical address, and the gap generated by the discontinuous area in the section is populated by 0x9090, and finally the section is placed in the kernel's text segment.

With the Objdump kernel, we can see the final content about the section:

Sections:

Idx Name Size VMA LMA File off ALGN

0. text.head 00000375 c1000000 01000000 00001000 2**2

CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE

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.