⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basic-script-concepts.html

📁 gcc手册
💻 HTML
字号:
<html lang="en">

<head>

<title>Untitled</title>

<meta http-equiv="Content-Type" content="text/html">

<meta name="description" content="Untitled">

<meta name="generator" content="makeinfo 4.3">

<link href="http://www.gnu.org/software/texinfo/" rel="generator-home">

</head>

<body>

<div class="node">

<p>

Node:<a name="Basic%20Script%20Concepts">Basic Script Concepts</a>,

Next:<a rel="next" accesskey="n" href="Script-Format.html#Script%20Format">Script Format</a>,

Up:<a rel="up" accesskey="u" href="Scripts.html#Scripts">Scripts</a>

<hr><br>

</div>



<h3 class="section">Basic Linker Script Concepts</h3>



   <p>We need to define some basic concepts and vocabulary in order to

describe the linker script language.



   <p>The linker combines input files into a single output file.  The output

file and each input file are in a special data format known as an

<dfn>object file format</dfn>.  Each file is called an <dfn>object file</dfn>. 

The output file is often called an <dfn>executable</dfn>, but for our

purposes we will also call it an object file.  Each object file has,

among other things, a list of <dfn>sections</dfn>.  We sometimes refer to a

section in an input file as an <dfn>input section</dfn>; similarly, a section

in the output file is an <dfn>output section</dfn>.



   <p>Each section in an object file has a name and a size.  Most sections

also have an associated block of data, known as the <dfn>section

contents</dfn>.  A section may be marked as <dfn>loadable</dfn>, which mean that

the contents should be loaded into memory when the output file is run. 

A section with no contents may be <dfn>allocatable</dfn>, which means that an

area in memory should be set aside, but nothing in particular should be

loaded there (in some cases this memory must be zeroed out).  A section

which is neither loadable nor allocatable typically contains some sort

of debugging information.



   <p>Every loadable or allocatable output section has two addresses.  The

first is the <dfn>VMA</dfn>, or virtual memory address.  This is the address

the section will have when the output file is run.  The second is the

<dfn>LMA</dfn>, or load memory address.  This is the address at which the

section will be loaded.  In most cases the two addresses will be the

same.  An example of when they might be different is when a data section

is loaded into ROM, and then copied into RAM when the program starts up

(this technique is often used to initialize global variables in a ROM

based system).  In this case the ROM address would be the LMA, and the

RAM address would be the VMA.



   <p>You can see the sections in an object file by using the <code>objdump</code>

program with the <code>-h</code> option.



   <p>Every object file also has a list of <dfn>symbols</dfn>, known as the

<dfn>symbol table</dfn>.  A symbol may be defined or undefined.  Each symbol

has a name, and each defined symbol has an address, among other

information.  If you compile a C or C++ program into an object file, you

will get a defined symbol for every defined function and global or

static variable.  Every undefined function or global variable which is

referenced in the input file will become an undefined symbol.



   <p>You can see the symbols in an object file by using the <code>nm</code>

program, or by using the <code>objdump</code> program with the <code>-t</code>

option.



   </body></html>



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -