Skip to content

Commit

Permalink
Preserve bound registers in _dl_runtime_resolve
Browse files Browse the repository at this point in the history
We need to add a BND prefix before indirect branch at the end of
_dl_runtime_resolve to preserve bound registers.

	[BZ #18134]
	* sysdeps/x86_64/dl-trampoline.S (PRESERVE_BND_REGS_PREFIX): New.
	(_dl_runtime_resolve): Add a BND prefix before indirect branch.
  • Loading branch information
H.J. Lu committed Mar 16, 2015
1 parent cb21929 commit b97eb2b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2015-03-16 H.J. Lu <hongjiu.lu@intel.com>

[BZ #18134]
* sysdeps/x86_64/dl-trampoline.S (PRESERVE_BND_REGS_PREFIX): New.

2015-03-15 Paul Eggert <eggert@cs.ucla.edu>

* stdlib/setenv.c (__add_to_environ): Revert previous change.
Expand Down
8 changes: 8 additions & 0 deletions sysdeps/x86_64/dl-trampoline.S
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
/* X32 saves RCX, RDX, RSI, RDI, R8 and R9 plus RAX. */
# define REGISTER_SAVE_AREA (8 * 7)
# define REGISTER_SAVE_RAX 0
# define PRESERVE_BND_REGS_PREFIX
#else
/* X86-64 saves RCX, RDX, RSI, RDI, R8 and R9 plus RAX as well as BND0,
BND1, BND2, BND3. */
Expand All @@ -40,6 +41,11 @@
# define REGISTER_SAVE_BND2 (REGISTER_SAVE_BND1 + 16)
# define REGISTER_SAVE_BND3 (REGISTER_SAVE_BND2 + 16)
# define REGISTER_SAVE_RAX (REGISTER_SAVE_BND3 + 16)
# ifdef HAVE_MPX_SUPPORT
# define PRESERVE_BND_REGS_PREFIX bnd
# else
# define PRESERVE_BND_REGS_PREFIX .byte 0xf2
# endif
#endif
#define REGISTER_SAVE_RCX (REGISTER_SAVE_RAX + 8)
#define REGISTER_SAVE_RDX (REGISTER_SAVE_RCX + 8)
Expand Down Expand Up @@ -112,6 +118,8 @@ _dl_runtime_resolve:
# Adjust stack(PLT did 2 pushes)
addq $(REGISTER_SAVE_AREA + 16), %rsp
cfi_adjust_cfa_offset(-(REGISTER_SAVE_AREA + 16))
# Preserve bound registers.
PRESERVE_BND_REGS_PREFIX
jmp *%r11 # Jump to function address.
cfi_endproc
.size _dl_runtime_resolve, .-_dl_runtime_resolve
Expand Down

0 comments on commit b97eb2b

Please sign in to comment.