This is the mail archive of the binutils@sources.redhat.com 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: binutils-doc 2.15-5: glitches in ld.info


(ld) Overlay Description

> However, this example is correct, and your suggested change
> won't work like you think it will..

OK, so I infer that I've mis-understood the accompanying text; which
hints that perhaps some clarification would be prudent, though it
might not belong in this page.  Two paragraphs earlier:

    For each section within the `OVERLAY', the linker automatically
  defines two symbols.  The symbol `__load_start_SECNAME' is defined
  as the starting load address of the section.  The symbol
  `__load_stop_SECNAME' is defined as the final load address of the
  section.

shortly after the example:

       .text0 0x1000 : AT (0x4000) { o1/*.o(.text) }
       __load_start_text0 = LOADADDR (.text0);
       __load_stop_text0 = LOADADDR (.text0) + SIZEOF (.text0);
       .text1 0x1000 : AT (0x4000 + SIZEOF (.text0)) { o2/*.o(.text) }
       __load_start_text1 = LOADADDR (.text1);
       __load_stop_text1 = LOADADDR (.text1) + SIZEOF (.text1);
       . = 0x1000 + MAX (SIZEOF (.text0), SIZEOF (.text1));

and I've been interpreting (ld) Assignments and (ld) Simple
Assignments as saying that assignments work like they do in C - that
is, if the linker script says
	 SYMBOL = EXPRESSION
then C code compiled into one of the objects being linked (c.f. the
example you assure me is correct) can use SYMBOL as an lvalue and
thereby get the value of EXPRESSION; while &SYMBOL will get a memory
address at which this value is being held.  I conclude that this is
not how it works.

If I have understood what you are saying correctly, then a linker
script assignment actually creates an alias - an assignment
	 SYMBOL = EXPRESSION
causes my C code to be able to reference &SYMBOL to get the value of
EXPRESSION, and my C code won't be able to reference the place where
that value is stored.

If such is really the case, either (ld) Assignments or possibly "Basic
Linker Script Concepts" should explain it - since the naive C/C++
programmer will be apt to make the same mistake as I did in
understanding the meaning of assignment.  Alternatively, if in fact my
initial reading of how assignments work is correct, then there are
problems with the (ld) Overlay Description text quoted above.

	Eddy.


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