[PATCH] D13815: [ELF2] Add support for Gnu Hash section

Igor Kudrin via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 21 08:53:17 PDT 2015


ikudrin added inline comments.

================
Comment at: ELF/OutputSections.cpp:324
@@ +323,3 @@
+  // GNU Hash table requirement: it should be power of 2.
+  return static_cast<unsigned>(NextPowerOf2((NumHashed - 1) / sizeof(Elf_Off)));
+}
----------------
rafael wrote:
> ikudrin wrote:
> > On the fresh look, I've forgotten about the requirement for this value to be a power of 2.
> Why the -1?
> Why the static_cast?
> 
For 64-bit target: calcMaskWords(0..8) = 1, calcMaskWords(9..16) = 2, calcMaskWords(17..32) = 4... I feel like it'd be better to have a unit test here.

The return type of NextPowerOf2 is uint64_t. I try to avoid a potential warning here about value truncation.


http://reviews.llvm.org/D13815





More information about the llvm-commits mailing list