------- Additional Comments From amodra at gmail dot com 2010-07-28 02:34 ------- There is no problem with the MAX operator as far as I can tell. Your source of confusion is twofold.
1) A constant like 0x1000 inside an ouput section statement is not an absolute constant, but rather a section relative offset. So 0x1000 really means <output section vma>+0x1000. To evaluate MAX(0x1000,ABSOLUTE(.)) ld first converts the 0x1000 to an absolute value, adding the output section vma. The result of MAX() is then an absolute address, so the net effect of your expression is to make the size of your output section at least 0x1000. I imagine this isn't what you require. The comparison in your alternative conditional expression is evaluated the same way, so also doesn't do exactly what you want. 2) ld muddies the waters even more in the way the result section of expressions is calculated. As I said above, the result of your MAX() is absolute, so unsurprisingly, the rhs of your expression involving MAX() is absolute. However, in the conditional expression the result of 0x1000 - ABSOLUTE(.) is a section relative offset. This offset is then added to '.' without first being converted to absolute. That oddity is why your second expression almost works. I don't know what to do about these problems. Any change in ld script behaviour will likely annoy more people than it pleases.. You can work around this using something like the following. SECTIONS { . = 0x500; ABS1K = 0x1000; .text : { *(.text) . += MAX(ABS1K, ABSOLUTE(.)) - ABSOLUTE(.); } } -- What |Removed |Added ---------------------------------------------------------------------------- Summary|MAX operator looks buggy, |relative constant confusion |returning always the lhs | |value | http://sourceware.org/bugzilla/show_bug.cgi?id=11845 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils