[PATCH] D27524: [ELF][MIPS] Make _gp, _gp_disp, __gnu_local_gp global symbols

Simon Atanasyan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 7 12:44:04 PST 2016


atanasyan added inline comments.


================
Comment at: ELF/Relocations.cpp:351-353
+  // Another special case is MIPS _gp_disp symbol which represents offset
+  // between start of a function and '_gp' value and defined as absolute just
+  // to simplify the code.
----------------
ruiu wrote:
> Doesn't _gp_disp represents offset between _gp and .got? I'm not sure what you mean by "a function" in the above description.
> Doesn't _gp_disp represents offset between _gp and .got? I'm not sure what you mean by "a function" in the above description.

By definition _gp_disp represents the offset between the beginning of the function and the _gp. This symbol is used in a position-independent function prologue in a combination with R_MIPS_HI16/LO16 relocations. So for each function _gp_disp has a unique value. Moreover we do not have to really define this symbol and put it to the symbol table. From the other side we need to define this symbol to escape "not defined symbol" error.

Your question gives me a good idea. Maybe it is better to add a new expression R_MIPS_GP_DISP for this case. So we will not mix these specific relocations with regular R_PC relocations and will be able to write checking more clear.


================
Comment at: ELF/Relocations.cpp:357
       return true;
+    if (&Body == ElfSym<ELFT>::MipsGpDisp)
+      return true;
----------------
meadori wrote:
> Is this related to the problem being discussed in D26133?
> Is this related to the problem being discussed in D26133?

Yes and no. With D26133 we will not need this `if` condition. From the other side _gp_disp is not true absolute symbol but just a "marker". If we could suppress "symbol not found error" for _gp_disp we even would not need to define it, add to a symbol table etc.


Repository:
  rL LLVM

https://reviews.llvm.org/D27524





More information about the llvm-commits mailing list