davide added a comment. This can be probably separated in two commits, which sorts and the other one which adds PT_NOTE. For 1), LGTM, and you can probably commit it as is. For 2), please add a test and I'll take another look. https://reviews.llvm.org/D28085