From b5801a4c576f063b30c220191161e5e4aaa88891 Mon Sep 17 00:00:00 2001 From: Bill Schmidt Date: Wed, 30 Nov 2016 16:00:14 -0600 Subject: [PATCH] Fix issue #22, Prologue for large code model. Signed-off-by: Bill Schmidt --- specification/ch_3.xml | 46 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/specification/ch_3.xml b/specification/ch_3.xml index 5845481..b7696ec 100644 --- a/specification/ch_3.xml +++ b/specification/ch_3.xml @@ -442,7 +442,8 @@ e_ident[EI_DATA] ELFDATA2LSB For all little-endian implementations. The local-entry-point handling field of st_other is generated with - the .localentry pseudo op: + the .localentry pseudo op. The following is an example using the medium + code model: .globl my_func .type my_func, @function my_func: @@ -458,6 +459,30 @@ my_func: points, even if the global entry point will not be used. (In such a case, the instructions of the global entry setup sequence may optionally be initialized with TRAP instructions.) + For very large programs, a 32-bit offset from + the TOC base may not suffice to reach all function addresses. In this + case, the large program model must be used, and the above sequence is + replaced by: + .globl my_func + .type my_func, @function + .quad .TOC.-my_func +my_func: + .reloc ., R_PPC64_ENTRY ; optional + ld r2,-8(r12) + add r2,r2,r12 + .localentry my_func, .-my_func + ... ; function definition + blr + The linker will resolve .TOC.-my_func to a + 64-bit offset stored 8 bytes prior to the global entry point. The + prologue code then forms the absolute address of the TOC base. + Optionally, the linker may optimize the + prologue sequence for functions that are within 2GB of the TOC base. + To faciliate this, the compiler may associate an R_PPC64_ENTRY + relocation with the global entry point. Note that this relocation + simply provides a hint, and imposes no obligations on the linker to + optimize the prologue sequence. Nor does the absence of this relocation + forbid the linker from optimizing the prologue sequence.
Use of the Small Data Area @@ -4005,6 +4030,20 @@ my_func: .) + + + R_PPC64_ENTRY + + + 118 + + + none + + + none + + R_PPC64_IRELATIVE @@ -4195,6 +4234,11 @@ my_func: inserting a call to a PLT stub code, the PLT stub code must not rely on the presence of a valid TOC base address in TOC register r2 to reference the PLT function table. + R_PPC64_ENTRY + This relocation type may optionally be + associated with a global entry point. See + for discussion of its + use.
Assembler Syntax