[lld] [NFC][lld] Pass `sym` as const reference to `GotSection`'s methods (PR #86481)

Daniil Kovalev via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 25 02:49:02 PDT 2024


https://github.com/kovdan01 created https://github.com/llvm/llvm-project/pull/86481

None

>From 98b9e13bf319c3263b974109bebc5aa3520a7c88 Mon Sep 17 00:00:00 2001
From: Daniil Kovalev <dkovalev at accesssoftek.com>
Date: Mon, 25 Mar 2024 12:46:59 +0300
Subject: [PATCH] [NFC][lld] Pass `sym` as const reference to `GotSection`'s
 methods

---
 lld/ELF/SyntheticSections.cpp | 6 +++---
 lld/ELF/SyntheticSections.h   | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index f924756ddddfcd..650bd6cd390060 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -628,19 +628,19 @@ GotSection::GotSection()
 }
 
 void GotSection::addConstant(const Relocation &r) { relocations.push_back(r); }
-void GotSection::addEntry(Symbol &sym) {
+void GotSection::addEntry(const Symbol &sym) {
   assert(sym.auxIdx == symAux.size() - 1);
   symAux.back().gotIdx = numEntries++;
 }
 
-bool GotSection::addTlsDescEntry(Symbol &sym) {
+bool GotSection::addTlsDescEntry(const Symbol &sym) {
   assert(sym.auxIdx == symAux.size() - 1);
   symAux.back().tlsDescIdx = numEntries;
   numEntries += 2;
   return true;
 }
 
-bool GotSection::addDynTlsEntry(Symbol &sym) {
+bool GotSection::addDynTlsEntry(const Symbol &sym) {
   assert(sym.auxIdx == symAux.size() - 1);
   symAux.back().tlsGdIdx = numEntries;
   // Global Dynamic TLS entries take two GOT slots.
diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h
index fa21b80a5a5ea0..02a669b01d1522 100644
--- a/lld/ELF/SyntheticSections.h
+++ b/lld/ELF/SyntheticSections.h
@@ -106,9 +106,9 @@ class GotSection final : public SyntheticSection {
   void writeTo(uint8_t *buf) override;
 
   void addConstant(const Relocation &r);
-  void addEntry(Symbol &sym);
-  bool addTlsDescEntry(Symbol &sym);
-  bool addDynTlsEntry(Symbol &sym);
+  void addEntry(const Symbol &sym);
+  bool addTlsDescEntry(const Symbol &sym);
+  bool addDynTlsEntry(const Symbol &sym);
   bool addTlsIndex();
   uint32_t getTlsDescOffset(const Symbol &sym) const;
   uint64_t getTlsDescAddr(const Symbol &sym) const;



More information about the llvm-commits mailing list