This is an archive of the discontinued LLVM Phabricator instance.

ELF2: Merge .{text,rodata,data,bss}.* sections.
ClosedPublic

Authored by ruiu on Oct 14 2015, 8:05 AM.

Details

Reviewers
rafael
Summary

Previously, we used input section names as output section names. That resulted
that we created lots of sections for comdat or -f{function,data}-section sections.

This patch is reduces the number of sections by dropping suffix from
all section names which start with ".text.", ".rodata.", ".data." or ".bss.".
GNU linker does this using the internal linker script, but for LLD I just
chose to do that directly.

Interestingly, this makes the linker faster. Time to link Clang is this.

Before:

real    0m0.537s
user    0m0.433s
sys     0m0.104s

After:

real    0m0.390s
user    0m0.268s
sys     0m0.120s

It make sense because previously we created 57659 sections, and it's now
only 27.

Diff Detail

Event Timeline

ruiu updated this revision to Diff 37357.Oct 14 2015, 8:05 AM
ruiu retitled this revision from to ELF2: Merge .{text,rodata,data,bss}.* sections..
ruiu updated this object.
ruiu added a reviewer: rafael.
ruiu added a subscriber: llvm-commits.
rafael accepted this revision.Oct 14 2015, 12:07 PM
rafael edited edge metadata.

Thanks!

I always compile with -fno-unique-section-names, which is why I didn't notice this.

ELF/Writer.cpp
371

Pass in the name and you can drop the template.

test/elf2/section-name.s
28

foo.a?

This revision is now accepted and ready to land.Oct 14 2015, 12:07 PM
Eugene.Zelenko added a subscriber: Eugene.Zelenko.

Committed in r250315.