[lld] [ELF] Set sh_entsize of .{init, fini, preinit}_array to the word size (PR #226697)

via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 26 06:08:21 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- lld/ELF/OutputSections.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index cefa6762e..4cf3cbe9a 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -62,8 +62,9 @@ void OutputSection::writeHeaderTo(typename ELFT::Shdr *shdr) {
   // a multiple of the word size: such a section is not a table of fixed-size
   // entries. GNU ld uses the word size even then.
   uint64_t es = entsize;
-  if (es == 0 && (type == SHT_INIT_ARRAY || type == SHT_FINI_ARRAY ||
-                  type == SHT_PREINIT_ARRAY) &&
+  if (es == 0 &&
+      (type == SHT_INIT_ARRAY || type == SHT_FINI_ARRAY ||
+       type == SHT_PREINIT_ARRAY) &&
       size % ctx.arg.wordsize == 0)
     es = ctx.arg.wordsize;
   shdr->sh_entsize = es;

``````````

</details>


https://github.com/llvm/llvm-project/pull/226697


More information about the llvm-commits mailing list