This is an archive of the discontinued LLVM Phabricator instance.

[yaml2obj][obj2yaml] - Improve how we set/dump the sh_entsize field.
ClosedPublic

Authored by grimar on Jan 25 2021, 7:28 AM.

Details

Summary

We already set the sh_entsize field in a single place
for all non-implicit sections.

This patch reorders the logic slightly and with it
we finally have the only one place where the sh_entsize is set.

obj2yaml will not dump the EntSize key for SHT_DYNSYM/SHT_SYMTAB sections anymore,
when the value of sh_entsize is equal to sizeof(Elf_Sym)

Note that this also seems revealed an issue in llvm-objcopy:
Previously yaml2obj set the sh_entsize for the .symtab section to 0x18,
now we it sets it for SHT_SYMTAB sections, i.e. by type.
But the llvm-objcopy/ELF/only-keep-debug.test has a .symtab section of type SHT_STRTAB,
and now yaml2obj sets the sh_entsize to 0 for it.
I had to update the corresponding check lines for ES, but the behavior of
llvm-objcopy should be fixed instead I think.
I've added a TODO and a comment.

Depends on D95354

Diff Detail

Event Timeline

grimar created this revision.Jan 25 2021, 7:28 AM
grimar requested review of this revision.Jan 25 2021, 7:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 25 2021, 7:28 AM

Looks reasonable, but perhaps fixing the llvm-objcopy issue first would be best. What do you think?

Looks reasonable, but perhaps fixing the llvm-objcopy issue first would be best. What do you think?

I think it is independent and can be fixed in a follow-up probably.

E.g. it seems that the expected behavior of llvm-objcopy would be to drop the sh_link for symbol table in this case. Because it is of SHT_NOBITS type.
Perhaps I'd wait from some input from @MaskRay as he was the author of the test case I think.

jhenderson accepted this revision.Jan 26 2021, 1:59 AM
This revision is now accepted and ready to land.Jan 26 2021, 1:59 AM