[PATCH] D32174: [ELF] - Assign absolute values in linkerscript correctly #2.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 18 09:24:05 PDT 2017


grimar created this revision.

This is PR32664. Current LLD behavior - segfault.

I found 2 ways of solving the issue.
One of them is this patch, second is https://reviews.llvm.org/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.


https://reviews.llvm.org/D32174

Files:
  ELF/LinkerScript.cpp
  ELF/LinkerScript.h
  ELF/OutputSections.h
  ELF/ScriptParser.cpp
  ELF/Writer.cpp
  test/ELF/linkerscript/early-assign-symbol.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32174.95589.patch
Type: text/x-patch
Size: 8466 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170418/500b6261/attachment.bin>


More information about the llvm-commits mailing list