This is an archive of the discontinued LLVM Phabricator instance.

[obj2yaml] - Dump the sh_entsize section field.
ClosedPublic

Authored by grimar on Jan 25 2019, 4:12 AM.

Details

Summary

I faced with the fact that obj2yaml does not dump the sh_entsize field.
A problem arose when I tried to dump ELF versioning sections.

This is close to what D50235 did, but D50235 did the change for yaml2obj, and now
I had to do the same for obj2yaml.

Diff Detail

Event Timeline

grimar created this revision.Jan 25 2019, 4:12 AM
jhenderson added inline comments.Jan 28 2019, 2:26 AM
test/tools/obj2yaml/elf-ent-size.yaml
1 ↗(On Diff #183515)

Nit: rename the test elf-entsize.yaml, since entsize is all one "word" in the field name.

12 ↗(On Diff #183515)

You can simplify this somewhat by a) getting rid of the .text section, b) getting rid of the symbol, and c) removing the content and AddressAlign fields from the .rodata.cst4 section.

tools/obj2yaml/elf2yaml.cpp
321

Why are we casting this, but none of the other fields?

grimar marked 4 inline comments as done.Jan 28 2019, 4:41 AM
grimar added inline comments.
test/tools/obj2yaml/elf-ent-size.yaml
1 ↗(On Diff #183515)

OK. FWIW naming was based on a similar test from yaml2obj folder (llvm\test\tools\yam2obj\elf-ent-size.yaml) (Oh, and it was me who committed it initially..). Thanks :)

tools/obj2yaml/elf2yaml.cpp
321

EntSize is the only Optional<llvm::yaml::Hex64> here. Without the cast I have an error:

1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(321): error C2679: binary '=': no operator found which takes a right-hand operand of type 'const llvm::support::detail::packed_endian_specific_integral<uint32_t,llvm::support::little,1>' (or there is no acceptable conversion)
1>D:\Work2\llvm\llvm\include\llvm/ADT/Optional.h(150): note: could be 'llvm::Optional<llvm::yaml::Hex64> &llvm::Optional<llvm::yaml::Hex64>::operator =(const llvm::Optional<llvm::yaml::Hex64> &)'
1>D:\Work2\llvm\llvm\include\llvm/ADT/Optional.h(146): note: or       'llvm::Optional<llvm::yaml::Hex64> &llvm::Optional<llvm::yaml::Hex64>::operator =(const T &)'
1>        with
1>        [
1>            T=llvm::yaml::Hex64
1>        ]
1>D:\Work2\llvm\llvm\include\llvm/ADT/Optional.h(133): note: or       'llvm::Optional<llvm::yaml::Hex64> &llvm::Optional<llvm::yaml::Hex64>::operator =(llvm::Optional<llvm::yaml::Hex64> &&)'
1>D:\Work2\llvm\llvm\include\llvm/ADT/Optional.h(129): note: or       'llvm::Optional<llvm::yaml::Hex64> &llvm::Optional<llvm::yaml::Hex64>::operator =(T &&)'
1>        with
1>        [
1>            T=llvm::yaml::Hex64
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(321): note: while trying to match the argument list '(llvm::Optional<llvm::yaml::Hex64>, const llvm::support::detail::packed_endian_specific_integral<uint32_t,llvm::support::little,1>)'
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(315): note: while compiling class template member function 'std::error_code `anonymous-namespace'::ELFDumper<ELFT>::dumpCommonSection(const llvm::object::Elf_Shdr_Impl<ELFT> *,llvm::ELFYAML::Section &)'
1>        with
1>        [
1>            ELFT=llvm::object::ELF32LE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(420): note: see reference to function template instantiation 'std::error_code `anonymous-namespace'::ELFDumper<ELFT>::dumpCommonSection(const llvm::object::Elf_Shdr_Impl<ELFT> *,llvm::ELFYAML::Section &)' being compiled
1>        with
1>        [
1>            ELFT=llvm::object::ELF32LE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(205): note: while compiling class template member function 'std::error_code `anonymous-namespace'::ELFDumper<ELFT>::dumpSymbols(const llvm::object::Elf_Shdr_Impl<ELFT> *,llvm::ELFYAML::LocalGlobalWeakSymbols &)'
1>        with
1>        [
1>            ELFT=llvm::object::ELF32LE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(194): note: see reference to function template instantiation 'std::error_code `anonymous-namespace'::ELFDumper<ELFT>::dumpSymbols(const llvm::object::Elf_Shdr_Impl<ELFT> *,llvm::ELFYAML::LocalGlobalWeakSymbols &)' being compiled
1>        with
1>        [
1>            ELFT=llvm::object::ELF32LE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(71): note: while compiling class template member function '`anonymous-namespace'::ELFDumper<ELFT>::ELFDumper(const llvm::object::ELFFile<ELFT> &)'
1>        with
1>        [
1>            ELFT=llvm::object::ELF32LE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(523): note: see reference to function template instantiation '`anonymous-namespace'::ELFDumper<ELFT>::ELFDumper(const llvm::object::ELFFile<ELFT> &)' being compiled
1>        with
1>        [
1>            ELFT=llvm::object::ELF32LE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(523): note: see reference to class template instantiation '`anonymous-namespace'::ELFDumper<ELFT>' being compiled
1>        with
1>        [
1>            ELFT=llvm::object::ELF32LE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(537): note: see reference to function template instantiation 'std::error_code elf2yaml<llvm::object::ELF32LE>(llvm::raw_ostream &,const llvm::object::ELFFile<llvm::object::ELF32LE> &)' being compiled
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(321): error C2679: binary '=': no operator found which takes a right-hand operand of type 'const llvm::support::detail::packed_endian_specific_integral<uint32_t,llvm::support::big,1>' (or there is no acceptable conversion)
1>D:\Work2\llvm\llvm\include\llvm/ADT/Optional.h(150): note: could be 'llvm::Optional<llvm::yaml::Hex64> &llvm::Optional<llvm::yaml::Hex64>::operator =(const llvm::Optional<llvm::yaml::Hex64> &)'
1>D:\Work2\llvm\llvm\include\llvm/ADT/Optional.h(146): note: or       'llvm::Optional<llvm::yaml::Hex64> &llvm::Optional<llvm::yaml::Hex64>::operator =(const T &)'
1>        with
1>        [
1>            T=llvm::yaml::Hex64
1>        ]
1>D:\Work2\llvm\llvm\include\llvm/ADT/Optional.h(133): note: or       'llvm::Optional<llvm::yaml::Hex64> &llvm::Optional<llvm::yaml::Hex64>::operator =(llvm::Optional<llvm::yaml::Hex64> &&)'
1>D:\Work2\llvm\llvm\include\llvm/ADT/Optional.h(129): note: or       'llvm::Optional<llvm::yaml::Hex64> &llvm::Optional<llvm::yaml::Hex64>::operator =(T &&)'
1>        with
1>        [
1>            T=llvm::yaml::Hex64
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(321): note: while trying to match the argument list '(llvm::Optional<llvm::yaml::Hex64>, const llvm::support::detail::packed_endian_specific_integral<uint32_t,llvm::support::big,1>)'
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(315): note: while compiling class template member function 'std::error_code `anonymous-namespace'::ELFDumper<ELFT>::dumpCommonSection(const llvm::object::Elf_Shdr_Impl<ELFT> *,llvm::ELFYAML::Section &)'
1>        with
1>        [
1>            ELFT=llvm::object::ELF32BE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(420): note: see reference to function template instantiation 'std::error_code `anonymous-namespace'::ELFDumper<ELFT>::dumpCommonSection(const llvm::object::Elf_Shdr_Impl<ELFT> *,llvm::ELFYAML::Section &)' being compiled
1>        with
1>        [
1>            ELFT=llvm::object::ELF32BE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(205): note: while compiling class template member function 'std::error_code `anonymous-namespace'::ELFDumper<ELFT>::dumpSymbols(const llvm::object::Elf_Shdr_Impl<ELFT> *,llvm::ELFYAML::LocalGlobalWeakSymbols &)'
1>        with
1>        [
1>            ELFT=llvm::object::ELF32BE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(194): note: see reference to function template instantiation 'std::error_code `anonymous-namespace'::ELFDumper<ELFT>::dumpSymbols(const llvm::object::Elf_Shdr_Impl<ELFT> *,llvm::ELFYAML::LocalGlobalWeakSymbols &)' being compiled
1>        with
1>        [
1>            ELFT=llvm::object::ELF32BE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(71): note: while compiling class template member function '`anonymous-namespace'::ELFDumper<ELFT>::ELFDumper(const llvm::object::ELFFile<ELFT> &)'
1>        with
1>        [
1>            ELFT=llvm::object::ELF32BE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(523): note: see reference to function template instantiation '`anonymous-namespace'::ELFDumper<ELFT>::ELFDumper(const llvm::object::ELFFile<ELFT> &)' being compiled
1>        with
1>        [
1>            ELFT=llvm::object::ELF32BE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(523): note: see reference to class template instantiation '`anonymous-namespace'::ELFDumper<ELFT>' being compiled
1>        with
1>        [
1>            ELFT=llvm::object::ELF32BE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(540): note: see reference to function template instantiation 'std::error_code elf2yaml<llvm::object::ELF32BE>(llvm::raw_ostream &,const llvm::object::ELFFile<llvm::object::ELF32BE> &)' being compiled
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(321): error C2679: binary '=': no operator found which takes a right-hand operand of type 'const llvm::support::detail::packed_endian_specific_integral<uint64_t,llvm::support::little,1>' (or there is no acceptable conversion)
1>D:\Work2\llvm\llvm\include\llvm/ADT/Optional.h(150): note: could be 'llvm::Optional<llvm::yaml::Hex64> &llvm::Optional<llvm::yaml::Hex64>::operator =(const llvm::Optional<llvm::yaml::Hex64> &)'
1>D:\Work2\llvm\llvm\include\llvm/ADT/Optional.h(146): note: or       'llvm::Optional<llvm::yaml::Hex64> &llvm::Optional<llvm::yaml::Hex64>::operator =(const T &)'
1>        with
1>        [
1>            T=llvm::yaml::Hex64
1>        ]
1>D:\Work2\llvm\llvm\include\llvm/ADT/Optional.h(133): note: or       'llvm::Optional<llvm::yaml::Hex64> &llvm::Optional<llvm::yaml::Hex64>::operator =(llvm::Optional<llvm::yaml::Hex64> &&)'
1>D:\Work2\llvm\llvm\include\llvm/ADT/Optional.h(129): note: or       'llvm::Optional<llvm::yaml::Hex64> &llvm::Optional<llvm::yaml::Hex64>::operator =(T &&)'
1>        with
1>        [
1>            T=llvm::yaml::Hex64
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(321): note: while trying to match the argument list '(llvm::Optional<llvm::yaml::Hex64>, const llvm::support::detail::packed_endian_specific_integral<uint64_t,llvm::support::little,1>)'
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(315): note: while compiling class template member function 'std::error_code `anonymous-namespace'::ELFDumper<ELFT>::dumpCommonSection(const llvm::object::Elf_Shdr_Impl<ELFT> *,llvm::ELFYAML::Section &)'
1>        with
1>        [
1>            ELFT=llvm::object::ELF64LE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(420): note: see reference to function template instantiation 'std::error_code `anonymous-namespace'::ELFDumper<ELFT>::dumpCommonSection(const llvm::object::Elf_Shdr_Impl<ELFT> *,llvm::ELFYAML::Section &)' being compiled
1>        with
1>        [
1>            ELFT=llvm::object::ELF64LE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(205): note: while compiling class template member function 'std::error_code `anonymous-namespace'::ELFDumper<ELFT>::dumpSymbols(const llvm::object::Elf_Shdr_Impl<ELFT> *,llvm::ELFYAML::LocalGlobalWeakSymbols &)'
1>        with
1>        [
1>            ELFT=llvm::object::ELF64LE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(194): note: see reference to function template instantiation 'std::error_code `anonymous-namespace'::ELFDumper<ELFT>::dumpSymbols(const llvm::object::Elf_Shdr_Impl<ELFT> *,llvm::ELFYAML::LocalGlobalWeakSymbols &)' being compiled
1>        with
1>        [
1>            ELFT=llvm::object::ELF64LE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(71): note: while compiling class template member function '`anonymous-namespace'::ELFDumper<ELFT>::ELFDumper(const llvm::object::ELFFile<ELFT> &)'
1>        with
1>        [
1>            ELFT=llvm::object::ELF64LE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(523): note: see reference to function template instantiation '`anonymous-namespace'::ELFDumper<ELFT>::ELFDumper(const llvm::object::ELFFile<ELFT> &)' being compiled
1>        with
1>        [
1>            ELFT=llvm::object::ELF64LE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(523): note: see reference to class template instantiation '`anonymous-namespace'::ELFDumper<ELFT>' being compiled
1>        with
1>        [
1>            ELFT=llvm::object::ELF64LE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(543): note: see reference to function template instantiation 'std::error_code elf2yaml<llvm::object::ELF64LE>(llvm::raw_ostream &,const llvm::object::ELFFile<llvm::object::ELF64LE> &)' being compiled
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(321): error C2679: binary '=': no operator found which takes a right-hand operand of type 'const llvm::support::detail::packed_endian_specific_integral<uint64_t,llvm::support::big,1>' (or there is no acceptable conversion)
1>D:\Work2\llvm\llvm\include\llvm/ADT/Optional.h(150): note: could be 'llvm::Optional<llvm::yaml::Hex64> &llvm::Optional<llvm::yaml::Hex64>::operator =(const llvm::Optional<llvm::yaml::Hex64> &)'
1>D:\Work2\llvm\llvm\include\llvm/ADT/Optional.h(146): note: or       'llvm::Optional<llvm::yaml::Hex64> &llvm::Optional<llvm::yaml::Hex64>::operator =(const T &)'
1>        with
1>        [
1>            T=llvm::yaml::Hex64
1>        ]
1>D:\Work2\llvm\llvm\include\llvm/ADT/Optional.h(133): note: or       'llvm::Optional<llvm::yaml::Hex64> &llvm::Optional<llvm::yaml::Hex64>::operator =(llvm::Optional<llvm::yaml::Hex64> &&)'
1>D:\Work2\llvm\llvm\include\llvm/ADT/Optional.h(129): note: or       'llvm::Optional<llvm::yaml::Hex64> &llvm::Optional<llvm::yaml::Hex64>::operator =(T &&)'
1>        with
1>        [
1>            T=llvm::yaml::Hex64
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(321): note: while trying to match the argument list '(llvm::Optional<llvm::yaml::Hex64>, const llvm::support::detail::packed_endian_specific_integral<uint64_t,llvm::support::big,1>)'
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(315): note: while compiling class template member function 'std::error_code `anonymous-namespace'::ELFDumper<ELFT>::dumpCommonSection(const llvm::object::Elf_Shdr_Impl<ELFT> *,llvm::ELFYAML::Section &)'
1>        with
1>        [
1>            ELFT=llvm::object::ELF64BE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(420): note: see reference to function template instantiation 'std::error_code `anonymous-namespace'::ELFDumper<ELFT>::dumpCommonSection(const llvm::object::Elf_Shdr_Impl<ELFT> *,llvm::ELFYAML::Section &)' being compiled
1>        with
1>        [
1>            ELFT=llvm::object::ELF64BE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(205): note: while compiling class template member function 'std::error_code `anonymous-namespace'::ELFDumper<ELFT>::dumpSymbols(const llvm::object::Elf_Shdr_Impl<ELFT> *,llvm::ELFYAML::LocalGlobalWeakSymbols &)'
1>        with
1>        [
1>            ELFT=llvm::object::ELF64BE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(194): note: see reference to function template instantiation 'std::error_code `anonymous-namespace'::ELFDumper<ELFT>::dumpSymbols(const llvm::object::Elf_Shdr_Impl<ELFT> *,llvm::ELFYAML::LocalGlobalWeakSymbols &)' being compiled
1>        with
1>        [
1>            ELFT=llvm::object::ELF64BE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(71): note: while compiling class template member function '`anonymous-namespace'::ELFDumper<ELFT>::ELFDumper(const llvm::object::ELFFile<ELFT> &)'
1>        with
1>        [
1>            ELFT=llvm::object::ELF64BE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(523): note: see reference to function template instantiation '`anonymous-namespace'::ELFDumper<ELFT>::ELFDumper(const llvm::object::ELFFile<ELFT> &)' being compiled
1>        with
1>        [
1>            ELFT=llvm::object::ELF64BE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(523): note: see reference to class template instantiation '`anonymous-namespace'::ELFDumper<ELFT>' being compiled
1>        with
1>        [
1>            ELFT=llvm::object::ELF64BE
1>        ]
1>D:\Work2\llvm\llvm\tools\obj2yaml\elf2yaml.cpp(546): note: see reference to function template instantiation 'std::error_code elf2yaml<llvm::object::ELF64BE>(llvm::raw_ostream &,const llvm::object::ELFFile<llvm::object::ELF64BE> &)' being compiled
1>Done building project "obj2yaml.vcxproj" -- FAILED.
grimar updated this revision to Diff 183828.Jan 28 2019, 4:44 AM
grimar marked an inline comment as done.
  • Addressed review comments.
jhenderson accepted this revision.Jan 28 2019, 5:58 AM

LGTM.

tools/obj2yaml/elf2yaml.cpp
321

Okay. Use static_cast, I think, unless there's precedent for C-style casts in this project.

This revision is now accepted and ready to land.Jan 28 2019, 5:58 AM
This revision was automatically updated to reflect the committed changes.