This is an archive of the discontinued LLVM Phabricator instance.

[obj2yaml/yaml2obj] Add section group support.
ClosedPublic

Authored by shankarke on Feb 19 2015, 10:13 PM.

Details

Summary

This adds support of reading and writing section groups.

Diff Detail

Event Timeline

shankarke updated this revision to Diff 20375.Feb 19 2015, 10:13 PM
shankarke retitled this revision from to [obj2yaml/yaml2obj] Add section group support..
shankarke updated this object.
shankarke edited the test plan for this revision. (Show Details)
shankarke added reviewers: atanasyan, Bigcheese.
shankarke set the repository for this revision to rL LLVM.
shankarke added a subscriber: Unknown Object (MLST).
atanasyan added inline comments.Feb 19 2015, 11:58 PM
include/llvm/Object/ELFYAML.h
88

Can we remove now the Info member field from the RelocationSection class?

lib/Object/ELFYAML.cpp
526

Is it possible/correct to get or create a group section with missed Members list? Should we made this field mandatory?

tools/obj2yaml/elf2yaml.cpp
306

I would write this loop with the if/else statement. It's a bit shorter and emphasizes the fact that we have two kinds of group section members:

for (int i = 0; i < count; i++) {
  if (groupMembers[i] == llvm::ELF::GRP_COMDAT) {
    s.sectionNameOrType = "GRP_COMDAT";
  } else {
    const Elf_Shdr *sHdr = Obj.getSection(groupMembers[i]);
    ErrorOr<StringRef> sectionName = Obj.getSectionName(sHdr);
    if (std::error_code ec = sectionName.getError())
      return ec;
    s.sectionNameOrType = *sectionName;
  }
  S->Members.push_back(s);
}
tools/yaml2obj/yaml2elf.cpp
391

Why does this error message mention the relocation section type?

shankarke added inline comments.Feb 20 2015, 7:36 AM
include/llvm/Object/ELFYAML.h
88

Good catch. Fixed.

lib/Object/ELFYAML.cpp
526

Yes we need to make it mandatory. I was thinking if we would want to create invalid tests cases using these tools.

tools/obj2yaml/elf2yaml.cpp
306

Sure.

tools/yaml2obj/yaml2elf.cpp
391

Copy/paste error. Will fix.

shankarke updated this revision to Diff 20402.Feb 20 2015, 7:37 AM
shankarke removed rL LLVM as the repository for this revision.

Updated with comments from atanasyan.

atanasyan accepted this revision.Feb 20 2015, 1:33 PM
atanasyan edited edge metadata.

LGTM

This revision is now accepted and ready to land.Feb 20 2015, 1:33 PM