This is an archive of the discontinued LLVM Phabricator instance.

[LLD] Only increase LMARegion if different from MemRegion
ClosedPublic

Authored by kschwarz on Jul 31 2018, 7:27 AM.

Details

Summary

If both the MemRegion and LMARegion are set for an output section in a linker script, we should only increase the LMARegion if it is different from the MemRegion. Otherwise, we reserve the memory twice.

Diff Detail

Repository
rL LLVM

Event Timeline

kschwarz created this revision.Jul 31 2018, 7:27 AM

Overall looks good to me. Comments are below.
(I would rename the test from at8.s to at6.s though, since we do not have at6.s yet.)

test/ELF/linkerscript/at8.test
10 ↗(On Diff #158258)

We usually try to reduce the test cases.
This alias seems to be excessive here, so I would remove.
Otherwise, it looks like having an alias is important, though it is not.

17 ↗(On Diff #158258)

Please add a brief comment describing what are you checking in this test case.

I would also add a header to show what is 0000000020000000 and 001000.
(like you have for program headers below).

21 ↗(On Diff #158258)

I think this line does not make sense. All LOADs are always listed after the header:
Type Offset VirtAddr PhysAddr
and you have CHECK-NEXT after it.

kschwarz updated this revision to Diff 158276.Jul 31 2018, 8:21 AM

Address review comments.

This patch was split from https://reviews.llvm.org/D50052, which adds at6.test and at7.test

ruiu added inline comments.Jul 31 2018, 2:42 PM
test/ELF/linkerscript/at8.test
11 ↗(On Diff #158276)

This seems to be equivalent to .text : { *(.text) } > RAM. What is the point of appending AT> RAM?

kschwarz added inline comments.Jul 31 2018, 11:35 PM
test/ELF/linkerscript/at8.test
11 ↗(On Diff #158276)

If used together with the REGION_ALIAS feature, this becomes more clear.
Often, the MEMORY commands and SECTIONS commands are kept in different linker scripts and the REGION_ALIAS feature is used to keep them independent.
This way, we can use the same linker script containing the SECTIONS commands and just switch the linker script containing the MEMORY commands for different targets.
Then, one target might map RAM2 to some flash region, while the other target simply maps to the same ram region.

grimar accepted this revision.Aug 1 2018, 12:11 AM

LGTM with test case renamed to at6.s (since D50052 is not yet landed).

test/ELF/linkerscript/at8.test
25 ↗(On Diff #158276)

Excessive empty line.

29 ↗(On Diff #158276)

Excessive empty line.

This revision is now accepted and ready to land.Aug 1 2018, 12:11 AM
kschwarz updated this revision to Diff 158474.Aug 1 2018, 12:57 AM
kschwarz edited the summary of this revision. (Show Details)

Rename at8.test to at6.test

This revision was automatically updated to reflect the committed changes.