[PATCH] [ELF] Fix incorrect sorting of .init_array / .fini_array sections
Simon Atanasyan
simon at atanasyan.com
Wed May 28 22:58:17 PDT 2014
Hi Bigcheese, shankarke, ruiu,
The main problem is in the predicate passed to the `std::stable_sort()`. This predicate always returns false if **both** section's names do not start with `.init_array` or `.fini_array` prefixes. In short, it does not define a strict weak ordering. Suppose we have the following sections:
.A .init_array.1 .init_array.2
The predicate states that:
not .init_array.1 < .A
not .A < .init_array.2
but .init_array.1 < .init_array.2 !!!
The second problem is that .init_array section without number should go last in the list. Not it has the lowest priority '0' and goes first.
The patch fix both of the problems.
http://reviews.llvm.org/D3947
Files:
lib/ReaderWriter/ELF/ArrayOrderPass.cpp
test/elf/init_array-order.test
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3947.9906.patch
Type: text/x-patch
Size: 4425 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140529/ceb0a1de/attachment.bin>
More information about the llvm-commits
mailing list