This is an archive of the discontinued LLVM Phabricator instance.

[yaml2obj] - Add a way to exclude specified sections from the section header.
ClosedPublic

Authored by grimar on Jun 2 2020, 7:03 AM.

Details

Summary

This implements the new "Excluded" key that can be used
to exclude entries from section header:

SectionHeaderTable:
  Sections:
    ...
  Excluded:
    - Name: .foo

Diff Detail

Event Timeline

grimar created this revision.Jun 2 2020, 7:03 AM
Herald added a project: Restricted Project. · View Herald Transcript
grimar edited the summary of this revision. (Show Details)Jun 2 2020, 7:03 AM

Perhaps worth an additional test case for excluded sections linking to other excluded sections.

llvm/lib/ObjectYAML/ELFEmitter.cpp
131

I might have missed something, but what's the benefit of making this a SetVector rather than some form of unordered_map?

523

it's -> its

(it's == it is, its == belonging to it)

1618

"Sections" and "Excluded" are using different markers for their formatting.

llvm/test/tools/yaml2obj/ELF/section-headers-exclude.yaml
2

Perhaps "from the section header table."

4

sections header table -> section header table

5

include ... to the -> include ... in the

I'd probably just delete the "sections" from "sections string table". I think it's fairly obvious what we're referring to here.

7

Use -p .shstrtab for a string dump of the string table here and below. I think that would be cleaner.

13–16

Can we get rid of the ES and onwards columns? I'm not sure they add much value (but could be persuaded otherwise).

42

the both -> both the

Perhaps also worth mentioning: "Also check that we report an error if a section is missing from the lists." or something like that.

77

section header -> section header table (?)

Assuming I've understood this correctly, why should this be an error? Perhaps a user wants to omit ALL section headers except the implicit null one?

104

it's -> its

109

Here and below: "has the Link" -> "has a Link"

113–114

Do we really need both cases? It seems unnecessary to me.

139

We probably want a SHT_DYNSYM version of this same case.

215

What's the purpose of the debug section case?

237

We probably want a case for an explicit .symtab reference when .symtab has been excluded.

245

has the -> has a

271

Case E?

Similar issues below.

275

We probably don't need the "YAML" part of this message.

321–322

Similar to above, we also probably want a test case for an explicit Link reference to an excluded section.

349–350

Similar to above, we also probably want a test case for an explicit Link references to an excluded section.

Could all these implicit cases linking to .symtab be folded together into one?

Here and below: "the latter one" -> "the latter" (feels more natural to me).

grimar updated this revision to Diff 268179.Jun 3 2020, 6:57 AM
grimar marked 31 inline comments as done.
  • Addressed review comments.
llvm/lib/ObjectYAML/ELFEmitter.cpp
131

You're right. I've experimented with different ways to implement this patch and at some point wanted to iterate over headers in an insertion order using this variable.
(I've tried to make it a member of SectionHeaderTable I think). There is no need to require it to be vector with the current code.

I can't use srd::unordered_set, because it wants a std::hash function for StringRef which we do not have I think:
"error C2280: 'std::hash<_Kty>::hash(const std::hash<_Kty> &)': attempting to reference a deleted function"

I've used StringSet<>.

523

Thanks!

llvm/test/tools/yaml2obj/ELF/section-headers-exclude.yaml
13–16

I've removed all columns except the "Name" one.

77

Hmm. Yes, I've missed this case. Fixed.

113–114

Probably we can go with only one. Done.

139

Ok. Though the related code is in the initSymtabSectionHeader(), and it is shared for both cases.

215

To test the code I've changed in initDWARFSectionHeader().
It is the same (i.e. shared) for all .debug_* sections currently.

237

I've added D.3

245

has an?

349–350

All done.

jhenderson accepted this revision.Jun 4 2020, 1:37 AM

LGTM, with nits.

llvm/test/tools/yaml2obj/ELF/section-headers-exclude.yaml
3

Nit: too many full stops

245

Oops, yeah, thanks :)

328–329

linked with -> linked to

(it's a one-way relationship typically, so I think this phrasing expresses it better)

This revision is now accepted and ready to land.Jun 4 2020, 1:37 AM
This revision was automatically updated to reflect the committed changes.
grimar marked 2 inline comments as done.