[PATCH] D27036: [ELF][MIPS] Fix handling of _gp/_gp_disp/__gnu_local_gp symbols

Simon Atanasyan via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 22 21:27:50 PST 2016


atanasyan created this revision.
atanasyan added a reviewer: ruiu.
atanasyan added subscribers: llvm-commits, emaste.
atanasyan set the repository for this revision to rL LLVM.
atanasyan added a project: lld.
Herald added a subscriber: sdardis.

Offset between beginning of a .got section and _gp symbols used in MIPS GOT relocations calculations. Usually the expression looks like VA + Offset - GP, where VA is the .got section address, Offset - offset of the GOT entry, GP - offset between .got and _gp. Also there two "magic" symbols _gp_disp and __gnu_local_gp which hold the offset mentioned above. These symbols might be referenced by MIPS relocations.

      

Now the linker always defines _gp symbol and uses hardcoded value for its initialization. So offset between .got and _gp is 0x7ff0. The _gp_disp and __gnu_local_gp defined if required and initialized by 0x7ff0. In fact that is not correct because _gp symbol might be defined by a linker script and holds arbitrary value. In that case we need to use this value in relocation calculation and initialize _gp_disp and __gnu_local_gp properly.

      

The patch fixes the problem and completes fixing the bug #30311.
https://llvm.org/bugs/show_bug.cgi?id=30311


Repository:
  rL LLVM

https://reviews.llvm.org/D27036

Files:
  ELF/InputSection.cpp
  ELF/Symbols.h
  ELF/SyntheticSections.cpp
  ELF/SyntheticSections.h
  ELF/Target.h
  ELF/Writer.cpp
  test/ELF/mips-gp-ext.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27036.79024.patch
Type: text/x-patch
Size: 9320 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161123/b935a0ed/attachment.bin>


More information about the llvm-commits mailing list