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]

Re: Relative expressions and ASSERT


Alan Modra <amodra@gmail.com> writes:

> I started down the path to treating all constants as absolute, and
> fairly rapidly found that was unworkable, as we need to distinguish
> between a plain numerical value and an absolute address.  So I made
> constants have a NULL section.  This allows some nice simplification
> when setting up result section in fold_binary;  No special case for
> '+' or '-' is needed, I think.
>
> Most of the patch is fairly obvious, but I had to make a few hacks for
> ORIGIN, to get ld-scripts/memaddr.t to pass.  ORIGIN was returning an
> absolute value (correctly, it really is an address) but this was being
> turned into a plain constant by exp_nameop.  exp_nameop can be made to
> behave by simply saying the result is invalid during the initial pass
> through script expressions.  Then it's possible to return a relative
> value for ORIGIN, like the test suite expects.  I originally just
> fixed the test suite but I'll leave that to a followup patch.
>
> I don't intend to commit this patch immediately.  I'm sure it will
> break some scripts, but if breakage is not too common then this chance
> to improve ld sanity may be worthwhile.

gold currently treats all constants used in expressions as absolute.  Of
course it's quite possible that this breaks some scripts.  gold
represents an evaluated expression as a number, a pointer to an output
section, and an alignment (used for the builtin ALIGN function).

For the '+' operator, if only one of the values has a section that
section is retained.  If both values have a section, gold warns on a
relocatable link, and otherwise just does the operation.

Ian


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