summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2017-06-16 14:32:02 -0700
committerH.J. Lu <hjl.tools@gmail.com>2017-06-17 06:15:23 -0700
commit24a5df4d2540d59cb1395fb28d26a80dc861faef (patch)
tree4351eca190a2b389c106f6b79cf98396fc16f32d
parent32604815347b5316e46d481c2967bd526410a2c8 (diff)
downloadglibc-hjl/pr21598.tar.gz
i386: Update _dl_runtime_resolve/_dl_runtime_profilehjl/pr21598
To make symbol resolver compatible with Shadow Stack in Intel Control-flow Enforcement Technology (CET) instructions: https://software.intel.com/sites/default/files/managed/4d/2a/control-flow-enforcement-technology-preview.pdf call resolved function indirectly with %ecx. [BZ #21598] * sysdeps/i386/dl-trampoline.S (_dl_runtime_resolve): Call resolved function indirectly with %ecx. (_dl_runtime_profile): Likewise.
-rw-r--r--sysdeps/i386/dl-trampoline.S34
1 files changed, 16 insertions, 18 deletions
diff --git a/sysdeps/i386/dl-trampoline.S b/sysdeps/i386/dl-trampoline.S
index 6e7f3aef92..d6c90a2d48 100644
--- a/sysdeps/i386/dl-trampoline.S
+++ b/sysdeps/i386/dl-trampoline.S
@@ -34,19 +34,17 @@ _dl_runtime_resolve:
cfi_adjust_cfa_offset (8)
pushl %eax # Preserve registers otherwise clobbered.
cfi_adjust_cfa_offset (4)
- pushl %ecx
- cfi_adjust_cfa_offset (4)
pushl %edx
cfi_adjust_cfa_offset (4)
- movl 16(%esp), %edx # Copy args pushed by PLT in register. Note
- movl 12(%esp), %eax # that `fixup' takes its parameters in regs.
+ movl 12(%esp), %edx # Copy args pushed by PLT in register. Note
+ movl 8(%esp), %eax # that `fixup' takes its parameters in regs.
call _dl_fixup # Call resolver.
- popl %edx # Get register content back.
- cfi_adjust_cfa_offset (-4)
- movl (%esp), %ecx
- movl %eax, (%esp) # Store the function address.
- movl 4(%esp), %eax
- ret $12 # Jump to function address.
+ movl (%esp), %edx # Get register content back.
+ movl %eax, %ecx # Store the function address.
+ movl 4(%esp), %eax # Get register content back.
+ addl $16, %esp # Adjust stack: PLT1 + PLT2 + %eax + %edx
+ cfi_adjust_cfa_offset (-16)
+ jmp *%ecx # Jump to function address.
cfi_endproc
.size _dl_runtime_resolve, .-_dl_runtime_resolve
@@ -85,14 +83,14 @@ _dl_runtime_profile:
movl (%esp), %edx
testl %edx, %edx
jns 1f
- popl %edx
- cfi_adjust_cfa_offset (-4)
- popl %edx # Get register content back.
- cfi_adjust_cfa_offset (-4)
- movl (%esp), %ecx
- movl %eax, (%esp) # Store the function address.
- movl 4(%esp), %eax
- ret $20 # Jump to function address.
+ movl 4(%esp), %edx # Get register content back.
+ movl %eax, %ecx # Store the function address.
+ movl 12(%esp), %eax # Get register content back.
+ # Adjust stack: PLT1 + PLT2 + %esp + %ebp + %eax + %ecx + %edx
+ # + free.
+ addl $32, %esp
+ cfi_adjust_cfa_offset (-32)
+ jmp *%ecx # Jump to function address.
/*
+32 return address