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?

522

it's -> its

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

1616

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

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

Perhaps "from the section header table."

5

sections header table -> section header table

6

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.

8

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

14–17

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

43

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.

78

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?

105

it's -> its

110

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

114–115

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

140

We probably want a SHT_DYNSYM version of this same case.

216

What's the purpose of the debug section case?

238

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

246

has the -> has a

272

Case E?

Similar issues below.

276

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

322–323

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

350–351

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<>.

522

Thanks!

llvm/test/tools/yaml2obj/ELF/section-headers-exclude.yaml
14–17

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

78

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

114–115

Probably we can go with only one. Done.

140

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

216

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

238

I've added D.3

246

has an?

350–351

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

246

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.