This is an archive of the discontinued LLVM Phabricator instance.

[yaml2obj] - Add a way to override the sh_addralign field of a section.
ClosedPublic

Authored by grimar on Oct 23 2020, 3:01 AM.

Details

Summary

Imagine the following declaration of a section:

Sections:
  - Name:         .dynsym
    Type:         SHT_DYNSYM
    AddressAlign: 0x1111111111111111

The aligment is large and yaml2obj reports an error currently:
"the desired output size is greater than permitted. Use the --max-size option to change the limit"

This patch implements the "ShAddrAlign" key, which is similar to other "Sh*" keys we have.
With it it is possible to override the sh_addralign field, ignoring the writing of alignment bytes.

Diff Detail

Event Timeline

grimar created this revision.Oct 23 2020, 3:01 AM
Herald added a project: Restricted Project. · View Herald Transcript
grimar requested review of this revision.Oct 23 2020, 3:01 AM
jhenderson added inline comments.Oct 23 2020, 3:46 AM
llvm/test/tools/yaml2obj/ELF/override-shaddralign.yaml
5–10

I'm not sure we need to do this. Showing that the output offset matches what you'd expect due to the AddressAlign field and not the ShAddrAlign field would be better.

40–42

I don't understand why we need multiple different kinds of sections. This is generic behaviour, so doesn't need testing with everything, right?

grimar marked an inline comment as done.Oct 23 2020, 3:49 AM
grimar added inline comments.
llvm/test/tools/yaml2obj/ELF/override-shaddralign.yaml
40–42

Yes, though we do it for ShName , ShOffset and ShSize. I mostly wanted to be consistent.

grimar updated this revision to Diff 300237.Oct 23 2020, 5:06 AM
grimar marked 2 inline comments as done.
  • Addressed review comments.
MaskRay accepted this revision.Oct 26 2020, 11:13 PM
MaskRay added inline comments.
llvm/test/tools/yaml2obj/ELF/override-shaddralign.yaml
5

use of "ShAddrAlign" key -> ShAddrAlign or the "ShAddrAlign" key

This revision is now accepted and ready to land.Oct 26 2020, 11:13 PM
jhenderson accepted this revision.Oct 27 2020, 2:22 AM

One nit, otherwise LGTM.

llvm/test/tools/yaml2obj/ELF/override-shaddralign.yaml
25

I'd explicitly set this to be something larger than the size of the ELF header, e.g. 0x80, to demonstrate that alignment has actually occurred here.

This revision was automatically updated to reflect the committed changes.
grimar marked an inline comment as done.