On Thu, 22 Jan 2015, Matthew Fortune wrote: > > This is a follow-up to a change [1] in glibc. It fixes the issue [2] > > when jal can not reach a target in different region.
Is it not a problem that can be solved with rearranging the order of sections in output? > > It has been tested with DejaGnu for mips32/o32, mips64/n32 and > > mips64/n64. You forgot a ChangeLog entry, the lack of which made me chase the bits you intend to change. :( > > Let me know what you think. You need to use DLA rather than LA for n64. This should have been caught in testing as a combination of the GAS warning and -Werror should have caused the compilation to bail out. But perhaps this isn't covered for some reason. > Otherwise for PIC the issue is dealt with by the assembler with the > JAL <sym> being expanded to a load from the got and indirect call through > t9. Previously t9 would not have been set up for the callee if the code > was built non-pic (as it would just use a JAL). That would have made > the setup of gp somewhat pointless in the CRT_CALL_STATIC_FUNCTION > code. I am therefore a little confused by the existing code that sets > up GP but then it seemingly is not used unless built for PIC. Bear in mind MIPS used to be PIC for everything except bare iron, so you had to set up $gp even in executables. Support for non-PIC abicalls is a relatively recent addition, so it looks to me nobody bothered to optimise these chunks as only executed once each and not really critical for performance. This code dates back to: 2003-01-15 Alexandre Oliva <aol...@redhat.com> * config/mips/mips.h (CRT_CALL_STATIC_FUNCTION): Define so as to set $gp before the call. and as I have suspected it was made with multi-GOT support in mind or otherwise $gp could have been set up the usual way. See the original submission here: http://gcc.gnu.org/ml/gcc-patches/2003-01/msg00919.html All this predates non-PIC abicalls by over 5 years and has only changed a little since the original addition. Maciej