This is an archive of the discontinued LLVM Phabricator instance.

[lld][LinkerScript] Add matching of output sections to segments
ClosedPublic

Authored by denis-protivensky on Jun 10 2015, 6:25 AM.

Details

Summary

Add method to query segments for specified output section name. Return error if the section is assigned to unknown segment.
Check matching of sections to segments during layout on the subject of correctness.

NOTE: no actual functionality of using custom segments is implemented.

Diff Detail

Repository
rL LLVM

Event Timeline

denis-protivensky retitled this revision from to [lld][LinkerScript] Add matching of output sections to segments.
denis-protivensky updated this object.
denis-protivensky edited the test plan for this revision. (Show Details)
denis-protivensky added a reviewer: Bigcheese.
denis-protivensky added a project: lld.
denis-protivensky added a subscriber: Unknown Object (MLST).
silvas added a subscriber: silvas.Jun 10 2015, 4:58 PM
silvas added inline comments.
test/elf/linkerscript/phdrs-invalid.test
10–35 ↗(On Diff #27438)

You can directly use llvm-mc instead of yaml2obj.

41–62 ↗(On Diff #27438)

Can you put the RUN: lines and check lines in the corresponding files?
(you might need to add a lit.local.cfg that identifies the interesting suffixes as tests)

test/elf/linkerscript/phdrs-invalid.test
10–35 ↗(On Diff #27438)

Good point, but I'd prefer to use yaml2obj for consistency with other tests in lld, and because we already have the corresponding yaml file, so there's no need to add another one with assembly code.

41–62 ↗(On Diff #27438)

Don't understand the purpose of separating test cases. My intent was to logically group similar tests in one file. Moreover, I won't be able to split up phdrs-default.test file above in the same fasion without test code duplication.

silvas added inline comments.Jun 11 2015, 1:58 PM
test/elf/linkerscript/phdrs-invalid.test
10–35 ↗(On Diff #27438)

There's been discussion about this recently on the mailing lists. Whichever tool is most convenient should be used (in this case, llvm-mc is clearly the most convenient). Generally speaking, yaml2obj has been overused in LLD.

silvas added inline comments.Jun 11 2015, 2:05 PM
test/elf/linkerscript/phdrs-invalid.test
41–62 ↗(On Diff #27438)

It's not so much about having them separate as it is about having good locality of the check lines with the actual input file (in this case the linker script).

I can see the benefit in this case of having them together though.

I'll leave it to another reviewer to decide on what is best in this case.

silvas added inline comments.Jun 11 2015, 2:11 PM
test/elf/linkerscript/phdrs-invalid.test
10–35 ↗(On Diff #27438)

Actually now that I think about it (and discuss with Bigcheese), what this is testing is completely independent of the actual section content, so it doesn't make sense to have an assembly input (or an input generated from assembly). I think that yaml2obj is the right tool here, and that the test case can be significantly reduced from one generated from the one you would get from the assembly.

Bigcheese added inline comments.Jun 11 2015, 2:42 PM
include/lld/ReaderWriter/LinkerScript.h
1448 ↗(On Diff #27438)

Why are you storing the error here? It should be emitted when the error is encountered. Also, I think that SmallVector<..., 2> would be better here.

include/lld/ReaderWriter/LinkerScript.h
1448 ↗(On Diff #27438)

Good, will change to throw an error upon encountered and replace the vector.

test/elf/linkerscript/phdrs-invalid.test
10–35 ↗(On Diff #27438)

Yeah, that's right. I'm intrested in sections as the input, not the assembly code.

Updated:

  • return error immediately when encountered
  • use SmallVector instead of std::vector for holding matched headers for sections
Bigcheese accepted this revision.Jun 12 2015, 4:53 PM
Bigcheese edited edge metadata.

lgtm

This revision is now accepted and ready to land.Jun 12 2015, 4:53 PM
This revision was automatically updated to reflect the committed changes.