This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

ld relative confusion


Hello, this is a followup to
http://sourceware.org/bugzilla/show_bug.cgi?id=11845 .

Thanks to Alan for clearing up the confusion. However, there are still
some issues that require some clearing up since the docs don't help
much either.
Lets start with the example:
SECTIONS
     {
       . = 1000
       output :
         {
           file1(.text)
           . += 1100 - ABSOLUTE(.);
           file2(.text)
         };
     }

Where will file2 be, assuming size of file1 is 75? Is the 1100
relative to output or absolute?
If relative, then file2 will be in 1025 absolute (25 relative) and ld
will fail cause the counter cannot go backwards.
If absolute, then file2 will be in 1100 absolute (100 relative) and
this expression will always ensure file2 always starts at 1100
assuming file1 is not bigger than 100.

Which one is it? Moreover, I cannot find any reference to how
constants are evaluated (as relative or absolute) in the manual.

Another issue, whose evaluation rules I cannot find in the manual have
to do with the evaluation of MAX and :?.
Consider the above example slightly changed:
SECTIONS
     {
       . = 1000
       output :
         {
           file1(.text)
           . += MAX(1100, ABSOLUTE(.)) - ABSOLUTE(.);
           file2(.text)
         };
     }

When I wrote this I thought this was going to ensure that ld was not
going to fail in case file1 is bigger than 100. I thought that if
file1 size is less than 100, then file2 starts at 1100. Otherwise, it
would start right after file1. From what Alan explains in the bug
report this is in fact making sure that there is a gap of at least
1100 between file1 and file2. Now, if I rewrite it with :?, the
results are again different and it looks like it works so it seems
that somehow the evaluation rules for these operators are different in
what concerns which expression results  are treated as absolute values
or offsets.

This is not documented in the docs, is there any general rule?

Cheers,

-- 
PMatos


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]