This is an archive of the discontinued LLVM Phabricator instance.

[obj2yaml] - Zero initialize program headers. NFCI.
ClosedPublic

Authored by grimar on Apr 22 2020, 4:58 AM.

Details

Summary

It allows to simplify the current code and also
might help for the code around.

It is also consistent with what we do for another headers,
e.g. section headers, ELF header etc.

Diff Detail

Event Timeline

grimar created this revision.Apr 22 2020, 4:58 AM
grimar edited the summary of this revision. (Show Details)Apr 22 2020, 5:10 AM
MaskRay accepted this revision.EditedApr 22 2020, 10:02 AM

section headers, elf file header etc.

The canonical name for elf file header is "ELF header".

This revision is now accepted and ready to land.Apr 22 2020, 10:02 AM
jhenderson accepted this revision.Apr 23 2020, 12:38 AM

LGTM, with one suggestion.

llvm/lib/ObjectYAML/ELFEmitter.cpp
764

Maybe worth pulling Fragments.front().Offset into a variable so that you don't have to repeat its call three times?

grimar marked an inline comment as done.Apr 23 2020, 1:19 AM
grimar added inline comments.
llvm/lib/ObjectYAML/ELFEmitter.cpp
764

OK, will do.

grimar marked an inline comment as done.Apr 23 2020, 1:31 AM
grimar added inline comments.
llvm/lib/ObjectYAML/ELFEmitter.cpp
764

Ah, no, sorry, I can't do it. Otherwise we need to return the following line:

uint64_t PhdrFileOffset = Fragments.empty() ? 0 : Fragments.front().Offset;

i.e. need to check that Fragments is not empty again. This is probably a bit more complicated than inlining it.

grimar marked an inline comment as done.Apr 23 2020, 1:45 AM
grimar added inline comments.
llvm/lib/ObjectYAML/ELFEmitter.cpp
764

I.e. it would just revert all changes done by this patch here. As an alternative I can abandon this patch and just add zero(Phdr); in D78628.
What do you think?

jhenderson added inline comments.Apr 23 2020, 2:22 AM
llvm/lib/ObjectYAML/ELFEmitter.cpp
764

It's fine. It was only a suggestion. Happy for it to go in as is.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptApr 23 2020, 2:41 AM
grimar edited the summary of this revision. (Show Details)Apr 23 2020, 2:41 AM