This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Assign absolute values in linkerscript correctly #2.
AbandonedPublic

Authored by grimar on Apr 18 2017, 9:24 AM.

Details

Reviewers
ruiu
rafael
Summary

This is PR32664. Current LLD behavior - segfault.

I found 2 ways of solving the issue.
One of them is this patch, second is D32173.

Problem itself is next. Imagine next script and code:
SECTIONS { . = 0x1000; aaa = ABSOLUTE(foo - 1); .text : { *(.text*) } };

.section .text
.globl foo
foo:
nop

At the moment of assignment to aaa we do not know the address of output section .text.
We are unable to evaluate the absolute value aaa properly therefore.

This patch suggests to add CanCalculateAbs field to expression class and AddrSet flag
to OutputSection. Then when expression evaluated we find if it can be evaluated or not.
When not (section address was not yet assigned), symbol assignment operation is delayed
and pushed to queue. Each time script produces new output section, delayed operations are proccessed.

Diff Detail