forked from OSchip/llvm-project
Add comments on a mysterious value in MIPS GOT[1].
Thanks to Simon Atanasyan and Igor Kudrin for describing the code! llvm-svn: 259259
This commit is contained in:
parent
00dab22853
commit
8364c6269a
|
@ -1408,9 +1408,24 @@ unsigned MipsTargetInfo<ELFT>::getDynRel(unsigned Type) const {
|
|||
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>
|
||||
|
|
Loading…
Reference in New Issue