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

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 2 01:27:13 PST 2017


grimar 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
----------------
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.


https://reviews.llvm.org/D29391





More information about the llvm-commits mailing list