[lld] r285996 - Add a few const qualifiers.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 4 06:20:45 PDT 2016


Author: rafael
Date: Fri Nov  4 08:20:45 2016
New Revision: 285996

URL: http://llvm.org/viewvc/llvm-project?rev=285996&view=rev
Log:
Add a few const qualifiers.

Modified:
    lld/trunk/ELF/OutputSections.h
    lld/trunk/ELF/Writer.cpp
    lld/trunk/ELF/Writer.h

Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=285996&r1=285995&r2=285996&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Fri Nov  4 08:20:45 2016
@@ -79,7 +79,7 @@ public:
   uintX_t getFileOffset() { return Header.sh_offset; }
   void setSHName(unsigned Val) { Header.sh_name = Val; }
   void writeHeaderTo(Elf_Shdr *SHdr);
-  StringRef getName() { return Name; }
+  StringRef getName() const { return Name; }
 
   virtual void addSection(InputSectionBase<ELFT> *C) {}
   virtual Kind getKind() const { return Base; }

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=285996&r1=285995&r2=285996&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Fri Nov  4 08:20:45 2016
@@ -385,7 +385,8 @@ static int getPPC64SectionRank(StringRef
       .Default(1);
 }
 
-template <class ELFT> bool elf::isRelroSection(OutputSectionBase<ELFT> *Sec) {
+template <class ELFT>
+bool elf::isRelroSection(const OutputSectionBase<ELFT> *Sec) {
   if (!Config->ZRelro)
     return false;
   typename ELFT::uint Flags = Sec->getFlags();
@@ -407,8 +408,8 @@ template <class ELFT> bool elf::isRelroS
 }
 
 template <class ELFT>
-static bool compareSectionsNonScript(OutputSectionBase<ELFT> *A,
-                                     OutputSectionBase<ELFT> *B) {
+static bool compareSectionsNonScript(const OutputSectionBase<ELFT> *A,
+                                     const OutputSectionBase<ELFT> *B) {
   // Put .interp first because some loaders want to see that section
   // on the first page of the executable file when loaded into memory.
   bool AIsInterp = A->getName() == ".interp";
@@ -489,8 +490,8 @@ static bool compareSectionsNonScript(Out
 
 // Output section ordering is determined by this function.
 template <class ELFT>
-static bool compareSections(OutputSectionBase<ELFT> *A,
-                            OutputSectionBase<ELFT> *B) {
+static bool compareSections(const OutputSectionBase<ELFT> *A,
+                            const OutputSectionBase<ELFT> *B) {
   // For now, put sections mentioned in a linker script first.
   int AIndex = Script<ELFT>::X->getSectionIndex(A->getName());
   int BIndex = Script<ELFT>::X->getSectionIndex(B->getName());
@@ -1473,10 +1474,10 @@ template struct elf::PhdrEntry<ELF32BE>;
 template struct elf::PhdrEntry<ELF64LE>;
 template struct elf::PhdrEntry<ELF64BE>;
 
-template bool elf::isRelroSection<ELF32LE>(OutputSectionBase<ELF32LE> *);
-template bool elf::isRelroSection<ELF32BE>(OutputSectionBase<ELF32BE> *);
-template bool elf::isRelroSection<ELF64LE>(OutputSectionBase<ELF64LE> *);
-template bool elf::isRelroSection<ELF64BE>(OutputSectionBase<ELF64BE> *);
+template bool elf::isRelroSection<ELF32LE>(const OutputSectionBase<ELF32LE> *);
+template bool elf::isRelroSection<ELF32BE>(const OutputSectionBase<ELF32BE> *);
+template bool elf::isRelroSection<ELF64LE>(const OutputSectionBase<ELF64LE> *);
+template bool elf::isRelroSection<ELF64BE>(const OutputSectionBase<ELF64BE> *);
 
 template void elf::reportDiscarded<ELF32LE>(InputSectionBase<ELF32LE> *);
 template void elf::reportDiscarded<ELF32BE>(InputSectionBase<ELF32BE> *);

Modified: lld/trunk/ELF/Writer.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.h?rev=285996&r1=285995&r2=285996&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.h (original)
+++ lld/trunk/ELF/Writer.h Fri Nov  4 08:20:45 2016
@@ -22,7 +22,7 @@ template <class ELFT> class ObjectFile;
 template <class ELFT> class SymbolTable;
 template <class ELFT> void writeResult();
 template <class ELFT> void markLive();
-template <class ELFT> bool isRelroSection(OutputSectionBase<ELFT> *Sec);
+template <class ELFT> bool isRelroSection(const OutputSectionBase<ELFT> *Sec);
 
 // This describes a program header entry.
 // Each contains type, access flags and range of output sections that will be




More information about the llvm-commits mailing list