[PATCH] D48929: [ELF] Update addends in non-allocatable sections for REL targets when creating a relocatable output.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 5 10:56:19 PDT 2018


ruiu added inline comments.


================
Comment at: ELF/InputSection.cpp:817
+// sections, such as sections with debug information.
+void InputSectionBase::relocateNonAllocForRelocatable(uint8_t *Buf,
+                                                      uint8_t *BufEnd) {
----------------
Can this be a non-member function? I mean if you explicitly pass `cast<InputSection>(this)` as an argument for this function, can't you make this a non-member, static function? Non-member functions are generally preferred over member functions if they don't depend on non-public part of a class.


================
Comment at: ELF/InputSection.cpp:818
+void InputSectionBase::relocateNonAllocForRelocatable(uint8_t *Buf,
+                                                      uint8_t *BufEnd) {
+  const unsigned Bits = Config->Wordsize * 8;
----------------
You are not using BufEnd, so please remove.


================
Comment at: ELF/InputSection.cpp:819
+                                                      uint8_t *BufEnd) {
+  const unsigned Bits = Config->Wordsize * 8;
+
----------------
I believe `const unsigned Bits = Config->Is64 ? 64 : 32` would produce slightly better code because by doing that, a compiler knows Bits is either 32 or 64 and not any other value.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D48929





More information about the llvm-commits mailing list