[lld] r304369 - Simplify. NFC.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed May 31 15:49:50 PDT 2017
Author: rafael
Date: Wed May 31 17:49:50 2017
New Revision: 304369
URL: http://llvm.org/viewvc/llvm-project?rev=304369&view=rev
Log:
Simplify. NFC.
The sections are ordered, so we can just use the first one when
looking for the lowest address.
Modified:
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=304369&r1=304368&r2=304369&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Wed May 31 17:49:50 2017
@@ -1697,12 +1697,12 @@ template <class ELFT> void Writer<ELFT>:
if (Config->EMachine == EM_MIPS && !ElfSym::MipsGp->Value) {
// Find GP-relative section with the lowest address
// and use this address to calculate default _gp value.
- uint64_t Gp = -1;
- for (const OutputSection *OS : OutputSections)
- if ((OS->Flags & SHF_MIPS_GPREL) && OS->Addr < Gp)
- Gp = OS->Addr;
- if (Gp != (uint64_t)-1)
- ElfSym::MipsGp->Value = Gp + 0x7ff0;
+ for (const OutputSection *OS : OutputSections) {
+ if (OS->Flags & SHF_MIPS_GPREL) {
+ ElfSym::MipsGp->Value = OS->Addr + 0x7ff0;
+ break;
+ }
+ }
}
}
More information about the llvm-commits
mailing list