[lld] r259259 - Add comments on a mysterious value in MIPS GOT[1].
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 29 14:55:38 PST 2016
Author: ruiu
Date: Fri Jan 29 16:55:38 2016
New Revision: 259259
URL: http://llvm.org/viewvc/llvm-project?rev=259259&view=rev
Log:
Add comments on a mysterious value in MIPS GOT[1].
Thanks to Simon Atanasyan and Igor Kudrin for describing the code!
Modified:
lld/trunk/ELF/Target.cpp
Modified: lld/trunk/ELF/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Target.cpp?rev=259259&r1=259258&r2=259259&view=diff
==============================================================================
--- lld/trunk/ELF/Target.cpp (original)
+++ lld/trunk/ELF/Target.cpp Fri Jan 29 16:55:38 2016
@@ -1408,9 +1408,24 @@ unsigned MipsTargetInfo<ELFT>::getDynRel
template <class ELFT>
void MipsTargetInfo<ELFT>::writeGotHeader(uint8_t *Buf) const {
typedef typename ELFFile<ELFT>::Elf_Off Elf_Off;
+ typedef typename ELFFile<ELFT>::uintX_t uintX_t;
+
+ // Set the MSB of the second GOT slot. This is not required by any
+ // MIPS ABI documentation, though.
+ //
+ // There is a comment in glibc saying that "The MSB of got[1] of a
+ // gnu object is set to identify gnu objects," and in GNU gold it
+ // says "the second entry will be used by some runtime loaders".
+ // But how this field is being used is unclear.
+ //
+ // We are not really willing to mimic other linkers behaviors
+ // without understanding why they do that, but because all files
+ // generated by GNU tools have this special GOT value, and because
+ // we've been doing this for years, it is probably a safe bet to
+ // keep doing this for now. We really need to revisit this to see
+ // if we had to do this.
auto *P = reinterpret_cast<Elf_Off *>(Buf);
- // Module pointer
- P[1] = ELFT::Is64Bits ? 0x8000000000000000 : 0x80000000;
+ P[1] = uintX_t(1) << (ELFT::Is64Bits ? 63 : 31);
}
template <class ELFT>
More information about the llvm-commits
mailing list