Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

In the linker-- link script

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Link script

The linker completes the specific work according to the specified principles.

The answer is: link script.

1 the meaning of the linked script

The link script is used to describe how the linker handles target and library files

1. Merge segments in various target files

two。 Relocate the starting address of each segment

3. Relocate the final address of each symbol

The SECTIONS / / keyword, which describes the layout of each segment in memory {.text 0x08048400: / / the starting address of the code snippet {* (.text) / / merges the code fragments of all files into the executable program}. = 0x01000000; / / set the current address S1 =.; / the storage address of identifier S. + = 4; S2 =.; .data 0x0804a800: {* (.data)} .bss: {* (.bss)}}

Note:

1. The link address of each segment must conform to the specific platform specification.

two。 The identifier can be directly defined and the storage address specified in the link script

3. The storage address of the identifier in the source code can be specified in the linked specimen

4. In Linux, the legal starting address of the process code snippet (.text) is [0x08048000j0x08049000]

2 use of MEMORY

By default: the linker believes that the program should be loaded into the same storage space.

In an embedded system, if there are multiple storage spaces, MEMORY must be used to define the storage area.

The attribute definition of MEMORY:

MEMORY {RAM0 (WX): ORIGIN = 0X20000000, LENGTH = 1024KRAM1 (! X): ORIGIN = 0X04000000, LENGTH = 256K} SECTION {.text: {* (.text)} > RAM0 .data: {* (.data)} > RAM0 .bss: {* (.bss)} > RAM1} 3 ENTRY command specifies the entry point ENTRY (program) SECTIONS {.text 0x08048400: {* (.text)}

It is important to note that when the entry function is not specified, the default entry function is the _ start function, because the linker uses the default link script, and the _ start function is clearly specified internally as the entry function.

You can use ld-- verbose to view the contents of the default link script.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report