[PATCH] ELF: Don't use LayoutPass.

Rui Ueyama ruiu at google.com
Thu Jan 29 16:38:21 PST 2015


Hi Bigcheese, atanasyan, shankarke,

Previously we applied the LayoutPass to order atoms and then
apply elf::ArrayOrderPass to sort them again. The first pass is
basically supposed to sort atoms in the normal fashion (which
is to sort symbols in the same order as the input files).
The second pass sorts atoms in {init,fini}_array.<priority> by
priority.

The problem is that the LayoutPass is overkill. It analysize
references between atoms to make a decision how to sort them.
It's slow, hard to understand, and above all, it doesn't seem
that we need its feature for ELF in the first place.

This patch remove the LayoutPass from ELF pass list. Now all
reordering is done in elf::OrderPass. That pass sorts atoms by
{init,fini}_array, and if they are not in the special section,
they are ordered as the same order as they appear in the command
line. The new code is far easier to understand, faster, and
still able to create valid executables.

I might have simplified things too much, because previously
we sorted atoms not only by position but by its permissions etc.
Because I didn't see any legitimate need to do so, I just decided
not to do that in this patch.

This patch changes the order of final output, although that's
benign. I didn't update affected tests yet as I'd like to get
feedback first.

http://reviews.llvm.org/D7278

Files:
  include/lld/Core/DefinedAtom.h
  lib/Core/DefinedAtom.cpp
  lib/ReaderWriter/ELF/ArrayOrderPass.cpp
  lib/ReaderWriter/ELF/ArrayOrderPass.h
  lib/ReaderWriter/ELF/CMakeLists.txt
  lib/ReaderWriter/ELF/ELFLinkingContext.cpp
  lib/ReaderWriter/ELF/OrderPass.h
  lib/ReaderWriter/PECOFF/OrderPass.h

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7278.19006.patch
Type: text/x-patch
Size: 10072 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150130/b134188c/attachment.bin>


More information about the llvm-commits mailing list