From 38f7d433ef45bd7860c305d8398965094b81d3db Mon Sep 17 00:00:00 2001 From: Simon Atanasyan Date: Tue, 17 Oct 2017 14:39:03 +0000 Subject: [PATCH] [mips] Provide more detailed comment. NFC llvm-svn: 316003 --- lld/ELF/Relocations.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index 8b6c51021fb7..b80e3e2f175e 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -304,8 +304,14 @@ static RelType getMipsPairType(RelType Type, bool IsLocal) { case R_MIPS_HI16: return R_MIPS_LO16; case R_MIPS_GOT16: - // I don't know why these relocations had to be defined like this, - // but they are handled differently when they refer to local symbols. + // In case of global symbol, the R_MIPS_GOT16 relocation does not + // have a pair. Each global symbol has a unique entry in the GOT + // and a corresponding instruction with help of the R_MIPS_GOT16 + // relocation loads an address of the symbol. In case of local + // symbol, the R_MIPS_GOT16 relocation creates a GOT entry to hold + // the high 16 bits of the symbol's value. A paired R_MIPS_LO16 + // relocations handle low 16 bits of the address. That allows + // to allocate only one GOT entry for every 64 KBytes of local data. return IsLocal ? R_MIPS_LO16 : R_MIPS_NONE; case R_MICROMIPS_GOT16: return IsLocal ? R_MICROMIPS_LO16 : R_MIPS_NONE; -- GitLab