[lld] r276868 - Make toPhdrFlags a member function. NFC.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 27 07:10:57 PDT 2016
Author: rafael
Date: Wed Jul 27 09:10:56 2016
New Revision: 276868
URL: http://llvm.org/viewvc/llvm-project?rev=276868&view=rev
Log:
Make toPhdrFlags a member function. NFC.
Modified:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/ELF/OutputSections.cpp
lld/trunk/ELF/OutputSections.h
lld/trunk/ELF/Writer.cpp
lld/trunk/ELF/Writer.h
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=276868&r1=276867&r2=276868&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Wed Jul 27 09:10:56 2016
@@ -281,13 +281,13 @@ LinkerScript<ELFT>::createPhdrs(ArrayRef
break;
case PT_DYNAMIC:
if (isOutputDynamic<ELFT>()) {
- Phdr.H.p_flags = toPhdrFlags(Out<ELFT>::Dynamic->getFlags());
+ Phdr.H.p_flags = Out<ELFT>::Dynamic->getPhdrFlags();
Phdr.add(Out<ELFT>::Dynamic);
}
break;
case PT_GNU_EH_FRAME:
if (!Out<ELFT>::EhFrame->empty() && Out<ELFT>::EhFrameHdr) {
- Phdr.H.p_flags = toPhdrFlags(Out<ELFT>::EhFrameHdr->getFlags());
+ Phdr.H.p_flags = Out<ELFT>::EhFrameHdr->getPhdrFlags();
Phdr.add(Out<ELFT>::EhFrameHdr);
}
break;
@@ -306,12 +306,12 @@ LinkerScript<ELFT>::createPhdrs(ArrayRef
for (size_t Id : PhdrIds) {
Ret[Id].add(Sec);
if (Opt.PhdrsCommands[Id].Flags == UINT_MAX)
- Ret[Id].H.p_flags |= toPhdrFlags(Sec->getFlags());
+ Ret[Id].H.p_flags |= Sec->getPhdrFlags();
}
} else {
// If we have no load segment or flags've changed then we want new load
// segment.
- uintX_t NewFlags = toPhdrFlags(Sec->getFlags());
+ uintX_t NewFlags = Sec->getPhdrFlags();
if (Load == nullptr || Flags != NewFlags) {
Load = &*Ret.emplace(Ret.end(), PT_LOAD, NewFlags);
Flags = NewFlags;
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=276868&r1=276867&r2=276868&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Wed Jul 27 09:10:56 2016
@@ -40,6 +40,16 @@ OutputSectionBase<ELFT>::OutputSectionBa
Header.sh_addralign = 1;
}
+template <class ELFT> uint32_t OutputSectionBase<ELFT>::getPhdrFlags() const {
+ uintX_t Flags = getFlags();
+ uint32_t Ret = PF_R;
+ if (Flags & SHF_WRITE)
+ Ret |= PF_W;
+ if (Flags & SHF_EXECINSTR)
+ Ret |= PF_X;
+ return Ret;
+}
+
template <class ELFT>
void OutputSectionBase<ELFT>::writeHeaderTo(Elf_Shdr *Shdr) {
*Shdr = Header;
Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=276868&r1=276867&r2=276868&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Wed Jul 27 09:10:56 2016
@@ -65,6 +65,7 @@ public:
uintX_t getSize() const { return Header.sh_size; }
void setSize(uintX_t Val) { Header.sh_size = Val; }
uintX_t getFlags() const { return Header.sh_flags; }
+ uint32_t getPhdrFlags() const;
uintX_t getFileOff() const { return Header.sh_offset; }
uintX_t getAlignment() const { return Header.sh_addralign; }
uint32_t getType() const { return Header.sh_type; }
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=276868&r1=276867&r2=276868&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Wed Jul 27 09:10:56 2016
@@ -467,15 +467,6 @@ static bool compareSections(OutputSectio
return false;
}
-uint32_t elf::toPhdrFlags(uint64_t Flags) {
- uint32_t Ret = PF_R;
- if (Flags & SHF_WRITE)
- Ret |= PF_W;
- if (Flags & SHF_EXECINSTR)
- Ret |= PF_X;
- return Ret;
-}
-
template <class ELFT> bool elf::isOutputDynamic() {
return !Symtab<ELFT>::X->getSharedFiles().empty() || Config->Pic;
}
@@ -959,7 +950,7 @@ std::vector<PhdrEntry<ELFT>> Writer<ELFT
// PT_INTERP must be the second entry if exists.
if (Out<ELFT>::Interp) {
- Phdr &Hdr = *AddHdr(PT_INTERP, toPhdrFlags(Out<ELFT>::Interp->getFlags()));
+ Phdr &Hdr = *AddHdr(PT_INTERP, Out<ELFT>::Interp->getPhdrFlags());
Hdr.add(Out<ELFT>::Interp);
}
@@ -986,7 +977,7 @@ std::vector<PhdrEntry<ELFT>> Writer<ELFT
continue;
// If flags changed then we want new load segment.
- uintX_t NewFlags = toPhdrFlags(Sec->getFlags());
+ uintX_t NewFlags = Sec->getPhdrFlags();
if (Flags != NewFlags) {
Load = AddHdr(PT_LOAD, NewFlags);
Flags = NewFlags;
@@ -1006,7 +997,7 @@ std::vector<PhdrEntry<ELFT>> Writer<ELFT
// Add an entry for .dynamic.
if (isOutputDynamic<ELFT>()) {
- Phdr &H = *AddHdr(PT_DYNAMIC, toPhdrFlags(Out<ELFT>::Dynamic->getFlags()));
+ Phdr &H = *AddHdr(PT_DYNAMIC, Out<ELFT>::Dynamic->getPhdrFlags());
H.add(Out<ELFT>::Dynamic);
}
@@ -1017,8 +1008,7 @@ std::vector<PhdrEntry<ELFT>> Writer<ELFT
// PT_GNU_EH_FRAME is a special section pointing on .eh_frame_hdr.
if (!Out<ELFT>::EhFrame->empty() && Out<ELFT>::EhFrameHdr) {
- Phdr &Hdr = *AddHdr(PT_GNU_EH_FRAME,
- toPhdrFlags(Out<ELFT>::EhFrameHdr->getFlags()));
+ Phdr &Hdr = *AddHdr(PT_GNU_EH_FRAME, Out<ELFT>::EhFrameHdr->getPhdrFlags());
Hdr.add(Out<ELFT>::EhFrameHdr);
}
Modified: lld/trunk/ELF/Writer.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.h?rev=276868&r1=276867&r2=276868&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.h (original)
+++ lld/trunk/ELF/Writer.h Wed Jul 27 09:10:56 2016
@@ -27,7 +27,6 @@ template <class ELFT> void writeResult(S
template <class ELFT> void markLive();
template <class ELFT> bool isOutputDynamic();
template <class ELFT> bool isRelroSection(OutputSectionBase<ELFT> *Sec);
-uint32_t toPhdrFlags(uint64_t Flags);
// 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