This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Don't segfault when assigning non-calculatable absolute symbol value.
ClosedPublic

Authored by grimar on May 3 2017, 4:07 AM.

Details

Summary

This is PR32664.

Issue was revealed by linux kernel script which was:

SECTIONS {
 . = (0xffffffff80000000 + ALIGN(0x1000000, 0x200000));
 phys_startup_64 = ABSOLUTE(startup_64 - 0xffffffff80000000);

 .text : AT(ADDR(.text) - 0xffffffff80000000) {
.....
  *(.head.text)

Where startup_64 is in .head.text.

At the place of assignment to phys_startup_64 we can not calculate absolute value for startup_64
because .text section has no VA assigned. Two patches were prepared earlier to address this: D32173 and D32174.

And in comments for D32173 was suggested not try to support this case, but error out.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar created this revision.May 3 2017, 4:07 AM
ruiu added inline comments.May 5 2017, 2:18 PM
ELF/LinkerScript.h
45 ↗(On Diff #97591)

It failed with a segfault because OutSec is null if no address is assigned. So why do you need a new member variable? It seems you can check if OutSec is null.

grimar updated this revision to Diff 98425.May 10 2017, 4:25 AM
  • Addressed review comment.
grimar added inline comments.May 10 2017, 4:25 AM
ELF/LinkerScript.h
45 ↗(On Diff #97591)

Yes, you right.

Do we want to add Location member to ExprValue ? ExprValue::getValue() may use it for producing better error reporting.

ruiu accepted this revision.May 10 2017, 7:16 AM

LGTM

This revision is now accepted and ready to land.May 10 2017, 7:16 AM
grimar edited the summary of this revision. (Show Details)May 10 2017, 7:35 AM
This revision was automatically updated to reflect the committed changes.