This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Teach LLD to recognize PT_OPENBSD_BOOTDATA
ClosedPublic

Authored by grimar on Dec 6 2016, 8:19 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar updated this revision to Diff 80421.Dec 6 2016, 8:19 AM
grimar retitled this revision from to [ELF] - Teach LLD to recognize PT_OPENBSD_BOOTDATA.
grimar updated this object.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar, evgeny777.
ruiu added inline comments.Dec 6 2016, 8:29 AM
ELF/LinkerScript.cpp
1862 ↗(On Diff #80421)

Sort.

test/ELF/linkerscript/openbsd-bootdata.s
2–4 ↗(On Diff #80421)

Why did you need .text?

Also, please do not use line continuations (\) in echo. It makes output messages hard to read when this test fails.

11–20 ↗(On Diff #80421)

Remove these lines because we are not interested in testing them.

grimar added inline comments.Dec 6 2016, 8:31 AM
ELF/LinkerScript.cpp
1862 ↗(On Diff #80421)

Sorted by value, like others entries.

ruiu added inline comments.Dec 6 2016, 8:32 AM
ELF/LinkerScript.cpp
1862 ↗(On Diff #80421)

But why? Probably nobody memorizes these numbers.

grimar added inline comments.Dec 6 2016, 8:37 AM
ELF/LinkerScript.cpp
1862 ↗(On Diff #80421)

Hmmm. For consistency. Whole StringSwitch is sorted by values.
Also them are sorted in ELF.h in the same way and it is comfortable to compare missings if needed.

ruiu added inline comments.Dec 6 2016, 8:43 AM
ELF/LinkerScript.cpp
1862 ↗(On Diff #80421)

Consistency with ELF.h may make sense, though I'm tempted to sort them here. OK in either way.

grimar updated this revision to Diff 80433.Dec 6 2016, 8:54 AM
  • Addressed review comments.
test/ELF/linkerscript/openbsd-bootdata.s
2–4 ↗(On Diff #80421)

Right, I think i do not need anything except what is in current diff, we can just check that lld creates header.

ruiu edited edge metadata.Dec 6 2016, 9:08 AM

Now that I wonder why we need one file per each program header type. Can you consolidate?

grimar added a comment.Dec 6 2016, 9:28 AM
In D27458#614630, @ruiu wrote:

Now that I wonder why we need one file per each program header type. Can you consolidate?

You mean combine testcases for OpenBSD into single file ? Probably yes, I'll try tomorrow.

ruiu accepted this revision.Dec 6 2016, 9:36 AM
ruiu edited edge metadata.

LGTM. Let's do cleanup in a followup patch.

This revision is now accepted and ready to land.Dec 6 2016, 9:36 AM
grimar added a comment.Dec 6 2016, 9:45 AM
In D27458#614665, @ruiu wrote:

LGTM. Let's do cleanup in a followup patch.

Thanks. By the way, after looking closer, openbsd-randomize.s (PT_OPENBSD_RANDOMIZE) and openbsd-wxneeded.s (PT_OPENBSD_WXNEEDED) are a bit different form this.
Both of them involve additional logic in LLD.

PT_OPENBSD_WXNEEDED relative to -z wxneeded,
PT_OPENBSD_RANDOMIZE is generated when we have ".openbsd.randomdata" section.
I would probably not combine their testcases.

May be we should just rename this testcase to openbsd-common-phdrs.s and use for all OpenBSD program headers that do not require any special logic ?

This revision was automatically updated to reflect the committed changes.