Define DefinedAtom::sectionSize.
authorRui Ueyama <ruiu@google.com>
Wed, 4 Mar 2015 21:40:46 +0000 (21:40 +0000)
committerRui Ueyama <ruiu@google.com>
Wed, 4 Mar 2015 21:40:46 +0000 (21:40 +0000)
commit77a4da19914c84e07a82dc22bbbf28540f90ca31
treed8e42d1a0196e871b33467a3c329b0704ea501e7
parent00fb6c9da0b8f9ed6b46f8c71a0f7c73bda177f2
Define DefinedAtom::sectionSize.

Merge::mergeByLargestSection is half-baked since it's defined
in terms of section size, there's no way to get the section size
of an atom.

Currently we work around the issue by traversing the layout edges
to both directions and calculate the sum of all atoms reachable.
I wrote that code but I knew it's hacky. It's even not guaranteed
to work. If you add layout edges before the core linking, it
miscalculates a size.

Also it's of course slow. It's basically a linked list traversal.

In this patch I added DefinedAtom::sectionSize so that we can use
that for mergeByLargestSection. I'm not very happy to add a new
field to DefinedAtom base class, but I think it's legitimate since
mergeByLargestSection is defined for section size, and the section
size is currently just missing.

http://reviews.llvm.org/D7966

llvm-svn: 231290
lld/include/lld/Core/DefinedAtom.h
lld/lib/Core/SymbolTable.cpp
lld/lib/ReaderWriter/Native/NativeFileFormat.h
lld/lib/ReaderWriter/Native/ReaderNative.cpp
lld/lib/ReaderWriter/Native/WriterNative.cpp
lld/lib/ReaderWriter/PECOFF/Atoms.h
lld/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
lld/test/pecoff/Inputs/merge-same-size3.obj.yaml