Align the stack in _rtld_bind_start. Normally this is called with the
correct stack alignment, however when we have a leaf function that uses thread local storage it calls __aeabi_read_tp to get the thread pointer. Neither GCC or clang see this as a function call so will align the stack to a 4-byte boundary. This may be a problem as _rtld_bind expects to be on an 8-byte boundary. The solution is to store a copy of the stack pointer and force the alignment before calling _rtld_bind. This fixes a problem with armeb where applications would crash in odd ways. It should also remove the need for a local patch to clang to force the stack alignment to an 8-byte boundary, even for leaf functions. Further testing will be needed before reverting this local change to clang as we may rely on it in other places. Reviewed by: jmg@
This commit is contained in:
parent
99ae56ac82
commit
0685d955d6
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=268310
@ -77,7 +77,7 @@ __FBSDID("$FreeBSD$");
|
||||
* lr = &GOT[2]
|
||||
*/
|
||||
_rtld_bind_start:
|
||||
stmdb sp!,{r0-r4,sl,fp}
|
||||
stmdb sp!,{r0-r5,sl,fp}
|
||||
|
||||
sub r1, ip, lr /* r1 = 4 * (n + 1) */
|
||||
sub r1, r1, #4 /* r1 = 4 * n */
|
||||
@ -86,11 +86,14 @@ _rtld_bind_start:
|
||||
ldr r0, [lr, #-4] /* get obj ptr from GOT[1] */
|
||||
mov r4, ip /* save GOT location */
|
||||
|
||||
mov r5, sp /* Save the stack pointer */
|
||||
bic sp, sp, #7 /* Align the stack pointer */
|
||||
bl _rtld_bind /* Call the binder */
|
||||
mov sp, r5 /* Restore the old stack pointer */
|
||||
|
||||
str r0, [r4] /* save address in GOT */
|
||||
mov ip, r0 /* save new address */
|
||||
|
||||
ldmia sp!,{r0-r4,sl,fp,lr} /* restore the stack */
|
||||
ldmia sp!,{r0-r5,sl,fp,lr} /* restore the stack */
|
||||
mov pc, ip /* jump to the new address */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user