This is an archive of the discontinued LLVM Phabricator instance.

[yaml2obj] Set p_align to the maximum sh_addralign of contained sections
ClosedPublic

Authored by MaskRay on Sep 6 2019, 12:04 AM.

Details

Summary

The address difference between two sections in a PT_LOAD is a constant.
Consider a hypothetical case (pagesize can be very small, say, 4).

.text     sh_addralign=4
.text.hot sh_addralign=16

If we set p_align to 4, the PT_LOAD will be loaded to an address which
is a multiple of 4. The address of .text.hot is guaranteed to be a
multiple of 4, but not necessarily a multiple of 16.

This patch deletes the constraint

if (SHeader->sh_offset == PHeader.p_offset)

Diff Detail

Repository
rL LLVM

Event Timeline

MaskRay created this revision.Sep 6 2019, 12:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 6 2019, 12:04 AM
grimar accepted this revision.Sep 6 2019, 2:07 AM

This LGTM. But please wait a bit to see if others have any comments.

test/tools/yaml2obj/program-header-align.yaml
32 ↗(On Diff #219037)

nit: Excessive ":" here and in the comment above?

This revision is now accepted and ready to land.Sep 6 2019, 2:07 AM
MaskRay updated this revision to Diff 219051.Sep 6 2019, 2:24 AM

Align: -> Align

Move a comment

MaskRay marked an inline comment as done.Sep 6 2019, 2:25 AM
jhenderson added inline comments.Sep 9 2019, 8:38 AM
test/tools/yaml2obj/program-header-align.yaml
2 ↗(On Diff #219051)

alignment of containing sections -> alignment of contained sections

7 ↗(On Diff #219051)

I think you can just get rid of --check-prefix and use CHECK everywhere, right?

8 ↗(On Diff #219051)

Not sure if this is really needed since the yaml2obj below only has one ProgramHeader, but maybe worth considering adding # CHECK-NOT: ProgramHeader after this line, to make sure the Alignment is for the right program header.

33 ↗(On Diff #219051)

containing -> contained

36 ↗(On Diff #219051)

Delete --check-prefix?

MaskRay updated this revision to Diff 219376.Sep 9 2019, 9:46 AM
MaskRay marked 6 inline comments as done.
MaskRay retitled this revision from [yaml2obj] Set p_align to the maximum sh_addralign of containing sections to [yaml2obj] Set p_align to the maximum sh_addralign of contained sections.

containing -> contained

--check-prefix ALIGN-16 -> (empty)

This revision was automatically updated to reflect the committed changes.