diff options
author | Chris Metcalf <cmetcalf@tilera.com> | 2012-11-05 10:43:40 -0500 |
---|---|---|
committer | Chris Metcalf <cmetcalf@tilera.com> | 2012-11-06 09:48:49 -0500 |
commit | fedff58953bf60c99498c018b6d787db117c8932 (patch) | |
tree | 008a20415ff04434f98dcad935bf4fb548dc5685 /ports/sysdeps/tile/start.S | |
parent | e7776fefa76a5815493b463049fd7ced67cb31a2 (diff) | |
download | glibc-fedff58953bf60c99498c018b6d787db117c8932.tar.gz glibc-fedff58953bf60c99498c018b6d787db117c8932.tar.xz glibc-fedff58953bf60c99498c018b6d787db117c8932.zip |
tile: support very large shared objects
With gcc 4.8 tilegx has support for -mcmodel=large, to tolerate very large shared objects. This option changes the compiler output to not include direct jump instructions, which have a range of only 2^30, i.e +/- 512MB. Instead the compiler marshalls the target PCs into registers and then uses jump- or call-to-register instructions. For glibc, the upshot is that we need to arrange for a few functions to tolerate the possibility of a large range between the PC and the target. In particular, the crti.S and start.S code needs to be able to reach from .init to the PLT, as does gmon-start.c. The elf-init.c code has the reverse problem, needing to call from libc_nonshared.a (linked at the end of shared objects) back to the _init section at the beginning. No other functions in *_nonshared.a need to be built this way, as they only call the PLT (or potentially each other), but all of that code is linked at the very end of the shared object. We don't build the standard -static archives with this option as the performance cost is high enough and the use case is rare enough that it doesn't seem worthwhile. Instead, we would encourage developers who need the -static model with huge executables to build a private copy of glibc and configure it with -mcmodel=large. Note that libc.so et al don't need any changes; the only changes are for code that is statically linked into user code built with -mcmodel=large. For the assembly code, I just rewrote it so that it unconditionally uses the large model. To be able to pass -mcmodel=large to csu/elf-init.c and csu/gmon-start.c, I need to check to see if the compiler supports that flag, since gcc 4.7 doesn't; I added the support by creating a small Makefile fragment that just runs the compiler to check.
Diffstat (limited to 'ports/sysdeps/tile/start.S')
-rw-r--r-- | ports/sysdeps/tile/start.S | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/ports/sysdeps/tile/start.S b/ports/sysdeps/tile/start.S index 999bb535ca..54f015f4d0 100644 --- a/ports/sysdeps/tile/start.S +++ b/ports/sysdeps/tile/start.S @@ -126,27 +126,37 @@ _start: moveli r0, hw2_last(main - .Lmy_pc) } { - moveli r3, hw2_last(__libc_csu_init - .Lmy_pc) shl16insli r0, r0, hw1(main - .Lmy_pc) + moveli r3, hw2_last(__libc_csu_init - .Lmy_pc) } { - shl16insli r3, r3, hw1(__libc_csu_init - .Lmy_pc) shl16insli r0, r0, hw0(main - .Lmy_pc) + shl16insli r3, r3, hw1(__libc_csu_init - .Lmy_pc) } { + ADD_PTR r0, r0, r13 shl16insli r3, r3, hw0(__libc_csu_init - .Lmy_pc) + } + { + moveli r12, hw2_last_plt(__libc_start_main - .Lmy_pc) + ADD_PTR r3, r3, r13 + } + { + shl16insli r12, r12, hw1_plt(__libc_start_main - .Lmy_pc) moveli r4, hw2_last(__libc_csu_fini - .Lmy_pc) } { - ADD_PTR r0, r0, r13 + shl16insli r12, r12, hw0_plt(__libc_start_main - .Lmy_pc) shl16insli r4, r4, hw1(__libc_csu_fini - .Lmy_pc) } { - ADD_PTR r3, r3, r13 + ADD_PTR r12, r12, r13 shl16insli r4, r4, hw0(__libc_csu_fini - .Lmy_pc) } { ADD_PTR r4, r4, r13 + jalr r12 + } #else addli r0, r13, lo16(main - .Lmy_pc) } @@ -160,13 +170,12 @@ _start: } { auli r4, r4, ha16(__libc_csu_fini - .Lmy_pc) - -#endif - /* Call the user's main function, and exit with its value. But let the libc call main. */ j plt(__libc_start_main) } +#endif + { /* Tell backtracer to give up (_start has no caller). */ info INFO_OP_CANNOT_BACKTRACE |