Community
Participate
Working Groups
A new version of PowerPC 64 ABI was recently released. With the previous version (1.9) of the ABI, using function descriptors, a function call was indirect, and the caller was setting the value of the TOC (Table of content) base pointer in register r2 prior to the call. The new ABI (v2) no longer uses function pointer. The callee has code to set the r2 register right after its entry point. This is described in the ABI : > All functions have a global entry point (GEP) available to any caller > and pointing to the beginning of the prologue. Some functions may have > a secondary entry point to optimize the cost of TOC pointer management. > In particular, functions within a common module sharing the same TOC base > value in r2 may be entered using a secondary entry point (the local > entry point or LEP) that may bypass the code that loads a suitable > TOC pointer value into the r2 register > The OpenPOWER ABI uses the three most-significant bits in the symbol st_other > field to specify the number of instructions between a function's > global entry point and local entry point. Here is an example of v2 code : > void testRtn(void) > { > 140: 3c 4c 00 00 addis r2,r12,0 > 142: R_PPC64_REL16_HA .TOC.+0x2 > 144: 38 42 00 00 addi r2,r2,0 > 146: R_PPC64_REL16_LO .TOC.+0x6 > 148: 7c 08 02 a6 mflr r0 > 14c: f8 01 00 10 std r0,16(r1) > 150: fb e1 ff f8 std r31,-8(r1) > 154: f8 21 ff d1 stdu r1,-48(r1) > 158: 7c 3f 0b 78 mr r31,r1 "external" call will go to 0x140. The compile may also permit functions in the same module (sharing same TOC) to go directly to 0x148. The issue for TCF agent is in the setting of function breakpoint. The current expression evaluator will use the GEP as function address. But setting a breakpoint at the GEP will work only when the call is not optimized. If we want to break for both optimized and non-optimized calls, the breakpoints need to be set on the LEP. A hook needs to be put in place to offset the BP location based on the ELF information for the function symbol.
Created attachment 253157 [details] Proposed patch
Hi Eugene, Attached a proposed patch. Sorry, I could not get the git push review to work. (ssh: connect to host git.eclipse.org port 29418: Connection timed out) Thanks ! Xavier.
https://git.eclipse.org/r/#/c/47135/
(In reply to xavier pouyollon from comment #3) > https://git.eclipse.org/r/#/c/47135/ Submitted. Thanks!
Comment on attachment 253157 [details] Proposed patch Marking the patch as obsolete since it was actually submitted via Gerrit.