This is an archive of the discontinued LLVM Phabricator instance.

Avoid almost duplication in .dynamic finalize and write.
ClosedPublic

Authored by rafael on Jan 25 2016, 9:54 AM.

Details

Reviewers
ruiu
Summary

There are a few cases where we have almost duplicated code.

This patches fixes the simplest: the finalize and write of dynamic section. Right now they have to have exactly the same structure to decide if a DT_* entry is needed and then to actually write it.

We cannot just write it to a std::vector in the first pass since addresses have not been computed yet.

Diff Detail

Event Timeline

rafael updated this revision to Diff 45875.Jan 25 2016, 9:54 AM
rafael retitled this revision from to Avoid almost duplication in .dynamic finalize and write..
rafael updated this object.
rafael added a reviewer: ruiu.
rafael set the repository for this revision to rL LLVM.
rafael added a subscriber: llvm-commits.
rafael removed rL LLVM as the repository for this revision.

rebased

ruiu accepted this revision.Jan 25 2016, 11:28 AM
ruiu edited edge metadata.

LGTM. This is a very nice change. Thank you for doing this.

ELF/OutputSections.cpp
596

It is better to describe a bit more detail. Because only this DynamicSection adds strings to DynStrTab, we can compute the size of DynStrTab early in this function, and that helps us to fill DT_STRSZ field in this function.

This revision is now accepted and ready to land.Jan 25 2016, 11:28 AM
ruiu added inline comments.Jan 25 2016, 11:54 AM
ELF/OutputSections.cpp
713–723

These helper functions don't make sense any more. You can inline them.

emaste added a subscriber: emaste.Jan 25 2016, 12:13 PM

I wondered about this when I added DT_DEBUG -- thanks for doing this!