This is an archive of the discontinued LLVM Phabricator instance.

Make CommonInputSection singleton class.
ClosedPublic

Authored by ruiu on Jul 28 2016, 2:02 PM.

Details

Summary

All other singleton instances are accessible globally.
CommonInputSection shouldn't be an exception.

Diff Detail

Repository
rL LLVM

Event Timeline

ruiu updated this revision to Diff 65991.Jul 28 2016, 2:02 PM
ruiu retitled this revision from to Make CommonInputSection singleton class..
ruiu updated this object.
ruiu added a reviewer: evgeny777.
ruiu added a subscriber: llvm-commits.
rafael accepted this revision.Jul 28 2016, 2:10 PM
rafael added a reviewer: rafael.
rafael added a subscriber: rafael.

LGTM, nice cleanup!

This revision is now accepted and ready to land.Jul 28 2016, 2:10 PM
evgeny777 accepted this revision.Jul 28 2016, 2:11 PM
evgeny777 edited edge metadata.

LGTM

This revision was automatically updated to reflect the committed changes.

Rui, I wonder why have you removed zero(&Hdr) from CommonInputSection constructor?
The InputSectionBase<ELFT> constructor reads sh_addralign from Hdr to calculate Alignment field, and this can be done incorrectly in case Hdr is not zeroed

ruiu added a comment.Aug 1 2016, 1:43 PM

It is guaranteed by the language spec (and by the fact that they are allocated to the .bss section) that global variables are initialized to zeros, no?

Yes, it is. But it looks like CommonInputSection singleton is actually a stack variable. See Writer.cpp:224

ruiu added a comment.Aug 1 2016, 1:54 PM

Hdr is a static class member, so it should be initialized to zero, I think.

Oh, I didn't noticed that change, sorry