This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
NEXT command problems
- From: "Galit Heller" <Galit dot Heller at nsc dot com>
- To: binutils at sources dot redhat dot com
- Date: Wed, 18 Feb 2004 11:34:47 +0200
- Subject: NEXT command problems
The ld manual says the following regarding NEXT vs. ALIGN:
"unless you use the MEMORY command to define discontinuous memory for the
output file, the two functions are equivalent".
But:
1. It seems that NEXT's value is not affected by the MEMORY allocation.
2. NEXT behaves differently from ALIGN (whether or not MEMORY command is
used).
3. It seems that NEXT values are not as expected/documented:
a. When the expression ". = NEXT(exp)" is used inside an output section
statement, it gives the same result as would be expected by
. += NEXT(exp) (although, as a side note, += gives the same affect as
= inside output section statements) so the fill space is much greater
then expected.
This is probably not the intended behavior.
b. When the expression ". = NEXT(exp)" is used in between output section
statements to set the location counter, then error "invalid assignment
to location counter" results, while with ALIGN it is legal.
c. (Minor) If NEXT is used to define a variable e.g. "var = NEXT(exp);"
then the variable is marked *undef* in the map file, although the
variable itself is defined correctly, to the same value as with
"var = ALIGN(exp);".
Points seen from browsing the ld code:
-------------------------------------
1. NEXT's value is absolute, while ALIGN's value is relocatable.
2. NEXT is not valid in final allocation phase.
3. NEXT doesn't take into account the memory allocation.
I notice that NEXT is rarely used (it appears only in one script template) -
but perhaps the documentation needs to be modified to reflect the current
behavior.
Galit.