This is an archive of the discontinued LLVM Phabricator instance.

ObjectFile: remove ReadSectionData/MemoryMapSectionData mutual recursion
ClosedPublic

Authored by labath on Dec 13 2017, 4:07 AM.

Details

Summary

These two functions were calling each other, while handling different
branches of the if(IsInMemory()). I am assuming this had a reason at
some point in the past, but right now it's just confusing.

I resolve this by removing the MemoryMapSectionData function and
inlining the !IsInMemory branch into ReadSectionData. There isn't
anything mmap-related in this function anyway, as the decision whether
to mmap is handled at a higher level.

This is a preparatory step to make ObjectFileELF be able to decompress
compressed sections (I want to make sure that all calls reading section
data are routed through a single piece of code).

Diff Detail

Repository
rL LLVM

Event Timeline

labath created this revision.Dec 13 2017, 4:07 AM
davide accepted this revision.Dec 13 2017, 8:02 AM
davide added a subscriber: davide.

LGTM.

This revision is now accepted and ready to land.Dec 13 2017, 8:02 AM
clayborg accepted this revision.Dec 13 2017, 12:22 PM

This was left over from before we mmap'ed the entire object file into memory. Removing it is fine as the backing DataBufferSP for the object file will be mmaped or not depending on where the file was loaded from and if the section isn't compressed, we will just hand out a shared slice of the object file data.

This revision was automatically updated to reflect the committed changes.