[PATCH] D29391: [ELF] - Postpone the evaluation of DefinedSynthetic value

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 2 10:03:11 PST 2017


ruiu added inline comments.


================
Comment at: ELF/LinkerScript.cpp:388
+  // It can happen when non-absolute value is assigned before processing
+  // first section. Example: Sym = . + 0x1; .sec : { ... };
+  // In that case Sym contains offset depending on VA of the .sec, but VA value
----------------
grimar wrote:
> ruiu wrote:
> > I don't think I understand this comment. Why `Sym` value is affected by the following `.sec`?
> > 
> > I do understand that `Sym` is affected if it is `.sec : { ... }; Sym = .`, but this is `Sym = .; .sec { ... };`. Can a following expression affects the results of preceding expressions?
> > 
> > By the way, why ` + 0x1`?
> >but this is Sym = .; .sec { ... };. Can a following expression affects the results of preceding expressions?
> 
> Yes. Please take a look on non-absolute.s:
> 
> ```
> { A = . - 0x10; B = A + 0x1; . += 0x1000; }
> ```
> 
> B is non-absolute expression, because depends on A which uses location counter for evaluation.
> That way B is non absolute symbol and belongs to next section, which is .text in testcase.
> 
> That is a different behavior in compare with gold/bfd. As you can see in description BFD makes vvar_start to belong to .text,
> but other symbols are ABS, gold makes all symbols as ABS. It was discussed with Rafael in D29332 thread that it looks as a bug of gnu linkers.
> 
> >By the way, why  + 0x1?
> Just shows the common case. Some expression that has location counter and operation. I think it is pretty common case in scripts. I can replace with "Sym = .;" if you want, though my way probably a bit more readable and common to see.
I think that doesn't answer my question. My question is how a following expression can affect a preceding expression. Your expression,

  A = . - 0x10; B = A + 0x1; . += 0x1000;

can be computed from left to right, so it doesn't seems to be a counter example.


https://reviews.llvm.org/D29391





More information about the llvm-commits mailing list