[PATCH] D26537: Fix llvm-symbolizer to correctly sort a symbol array and calculate symbol sizes

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 10 19:36:27 PST 2016


testcase?

On 10 November 2016 at 21:27, Kuba Brecka <kuba.brecka at gmail.com> wrote:
> kubabrecka created this revision.
> kubabrecka added reviewers: aprantl, dvyukov, kcc, rafael.
> kubabrecka added subscribers: llvm-commits, zaks.anna.
> kubabrecka set the repository for this revision to rL LLVM.
>
> I noticed that llvm-symbolizer gives wrong results sometimes, this was due to incorrect sizes of some symbols.  The reason for that was an incorrectly sorted array in computeSymbolSizes.  The comparison function used subtraction of unsigned types, which is incorrect.  Let's change this to return explicit -1 or 1.
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D26537
>
> Files:
>   lib/Object/SymbolSize.cpp
>
>
> Index: lib/Object/SymbolSize.cpp
> ===================================================================
> --- lib/Object/SymbolSize.cpp
> +++ lib/Object/SymbolSize.cpp
> @@ -27,8 +27,10 @@
>
>  static int compareAddress(const SymEntry *A, const SymEntry *B) {
>    if (A->SectionID != B->SectionID)
> -    return A->SectionID - B->SectionID;
> -  return A->Address - B->Address;
> +    return A->SectionID < B->SectionID ? -1 : 1;
> +  if (A->Address != B->Address)
> +    return A->Address < B->Address ? -1 : 1;
> +  return 0;
>  }
>
>  static unsigned getSectionID(const ObjectFile &O, SectionRef Sec) {
>
>


More information about the llvm-commits mailing list