1<html lang="en"> 2<head> 3<title>Evaluation - Untitled</title> 4<meta http-equiv="Content-Type" content="text/html"> 5<meta name="description" content="Untitled"> 6<meta name="generator" content="makeinfo 4.13"> 7<link title="Top" rel="start" href="index.html#Top"> 8<link rel="up" href="Expressions.html#Expressions" title="Expressions"> 9<link rel="prev" href="Operators.html#Operators" title="Operators"> 10<link rel="next" href="Expression-Section.html#Expression-Section" title="Expression Section"> 11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 12<!-- 13This file documents the GNU linker LD 14(Sourcery CodeBench Lite 2013.11-24) 15version 2.23.52. 16 17Copyright (C) 1991-2013 Free Software Foundation, Inc. 18 19Permission is granted to copy, distribute and/or modify this document 20under the terms of the GNU Free Documentation License, Version 1.3 21or any later version published by the Free Software Foundation; 22with no Invariant Sections, with no Front-Cover Texts, and with no 23Back-Cover Texts. A copy of the license is included in the 24section entitled ``GNU Free Documentation License''.--> 25<meta http-equiv="Content-Style-Type" content="text/css"> 26<style type="text/css"><!-- 27 pre.display { font-family:inherit } 28 pre.format { font-family:inherit } 29 pre.smalldisplay { font-family:inherit; font-size:smaller } 30 pre.smallformat { font-family:inherit; font-size:smaller } 31 pre.smallexample { font-size:smaller } 32 pre.smalllisp { font-size:smaller } 33 span.sc { font-variant:small-caps } 34 span.roman { font-family:serif; font-weight:normal; } 35 span.sansserif { font-family:sans-serif; font-weight:normal; } 36--></style> 37<link rel="stylesheet" type="text/css" href="../cs.css"> 38</head> 39<body> 40<div class="node"> 41<a name="Evaluation"></a> 42<p> 43Next: <a rel="next" accesskey="n" href="Expression-Section.html#Expression-Section">Expression Section</a>, 44Previous: <a rel="previous" accesskey="p" href="Operators.html#Operators">Operators</a>, 45Up: <a rel="up" accesskey="u" href="Expressions.html#Expressions">Expressions</a> 46<hr> 47</div> 48 49<h4 class="subsection">3.10.7 Evaluation</h4> 50 51<p><a name="index-lazy-evaluation-534"></a><a name="index-expression-evaluation-order-535"></a>The linker evaluates expressions lazily. It only computes the value of 52an expression when absolutely necessary. 53 54 <p>The linker needs some information, such as the value of the start 55address of the first section, and the origins and lengths of memory 56regions, in order to do any linking at all. These values are computed 57as soon as possible when the linker reads in the linker script. 58 59 <p>However, other values (such as symbol values) are not known or needed 60until after storage allocation. Such values are evaluated later, when 61other information (such as the sizes of output sections) is available 62for use in the symbol assignment expression. 63 64 <p>The sizes of sections cannot be known until after allocation, so 65assignments dependent upon these are not performed until after 66allocation. 67 68 <p>Some expressions, such as those depending upon the location counter 69‘<samp><span class="samp">.</span></samp>’, must be evaluated during section allocation. 70 71 <p>If the result of an expression is required, but the value is not 72available, then an error results. For example, a script like the 73following 74<pre class="smallexample"> SECTIONS 75 { 76 .text 9+this_isnt_constant : 77 { *(.text) } 78 } 79</pre> 80 <p class="noindent">will cause the error message ‘<samp><span class="samp">non constant expression for initial 81address</span></samp>’. 82 83 </body></html> 84 85