This is an archive of the discontinued LLVM Phabricator instance.

ELF2; Make singleton output sections globally accessible
ClosedPublic

Authored by ruiu on Oct 6 2015, 4:15 PM.

Details

Reviewers
rafael
Summary

Previously, output sections handled specially by the linker (e.g. PLT or GOT)
are created by Writer and passed to other classes that need them. The problem
was that because these special sections are required by so many classes, the
plumbing work became too much burden.

This patch is to simply make them accessible from anywhere in the linker to
eliminate the plumbing work once and for all.

Diff Detail

Event Timeline

ruiu updated this revision to Diff 36673.Oct 6 2015, 4:15 PM
ruiu retitled this revision from to ELF2; Make singleton output sections globally accessible.
ruiu updated this object.
ruiu added a reviewer: rafael.
ruiu added a subscriber: llvm-commits.
ruiu updated this revision to Diff 36695.Oct 6 2015, 6:12 PM

Rebased on top of current head

rafael edited edge metadata.Oct 7 2015, 8:53 AM

I like where this is going, but would you mind committing the changes moving stuff out of line first and rebase?

Thanks!

ELF/InputSection.cpp
40

Why remove this?

ELF/InputSection.h
78

Independent change. Please commit the rename first.

ELF/OutputSections.h
157

Moving it out of line is good, but please do it in a independent cleanup patch first.

ruiu added inline comments.Oct 7 2015, 9:15 AM
ELF/InputSection.cpp
40

I'll revert this change.

ELF/InputSection.h
78

Out conflicts with the global varaible Out, so we have to rename this. Technically we can use ::Out<ELFT>:: to refer to the global Out and Out for local variable Out, but that's confusing.

ELF/OutputSections.h
157

OK, I'll submit a clean up change first. This is needed before this patch because this contains StrTabSec.

ruiu updated this revision to Diff 36765.Oct 7 2015, 10:36 AM
ruiu edited edge metadata.

Rebased to the head.

rafael added inline comments.Oct 7 2015, 11:37 AM
ELF/Writer.cpp
128

This is a leak, no?

Can the Out struct contain the sections themselves instead of pointers?
Failing that, could these be kept in Writer and have the writer constructor set the pointers in Out:

Out<ELFT>::StrTab = &StrTabSec;
...

ruiu updated this revision to Diff 36776.Oct 7 2015, 12:06 PM

Fixed memory leak

ruiu added a subscriber: ruiu.Oct 7 2015, 12:11 PM

Please ignore #Driver.cpp# in the patch, that's garbage. Other changes are
real.

rafael accepted this revision.Oct 7 2015, 12:14 PM
rafael edited edge metadata.

LGTM with a nit.

ELF/Target.cpp
12

Target should still be the first include, no?

This revision is now accepted and ready to land.Oct 7 2015, 12:14 PM
ruiu added inline comments.Oct 7 2015, 12:16 PM
ELF/Target.cpp
12

Done.

Eugene.Zelenko added a subscriber: Eugene.Zelenko.

Committed in r249590.