[lld] Fix .bss section accumulated in ELF file (PR #78265)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 16 04:21:58 PST 2024


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 26d3cd1d07ae3fc8312feb2ab3a3a86414f28c70 03a4c4e5f150ab9215ccc817b950f39c96c1ecdb -- lld/ELF/Writer.cpp lld/ELF/Writer.h
``````````

</details>

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

``````````diff
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 59c240a0c8..5b5a350c31 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -2629,11 +2629,10 @@ static uint64_t computeFileOffset(OutputSection *os, uint64_t off) {
   // in a PT_LOAD/PT_TLS. By convention, we keep section offsets monotonically
   // increasing rather than setting to zero.
   if (os->type == SHT_NOBITS &&
-      (!Out::tlsPhdr || Out::tlsPhdr->firstSec != os))
-  {
+      (!Out::tlsPhdr || Out::tlsPhdr->firstSec != os)) {
     // Update no_bits size in the current segment
     if (os->ptLoad)
-      os->ptLoad->p_nobits +=  os->size;
+      os->ptLoad->p_nobits += os->size;
     return off;
   }
 
diff --git a/lld/ELF/Writer.h b/lld/ELF/Writer.h
index 6f5ab6ce32..df3640c035 100644
--- a/lld/ELF/Writer.h
+++ b/lld/ELF/Writer.h
@@ -38,7 +38,7 @@ struct PhdrEntry {
   uint32_t p_type = 0;
   uint32_t p_flags = 0;
   // NO_BITS size processed in the output section..
-  uint64_t p_nobits =0;
+  uint64_t p_nobits = 0;
   OutputSection *firstSec = nullptr;
   OutputSection *lastSec = nullptr;
   bool hasLMA = false;

``````````

</details>


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


More information about the llvm-commits mailing list