Merge "Add x86 __memset_chk assembler."
This commit is contained in:
commit
728e0e9b97
3 changed files with 34 additions and 66 deletions
|
@ -28,6 +28,8 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <private/bionic_asm.h>
|
||||
|
||||
#include "cache.h"
|
||||
|
||||
#ifndef L
|
||||
|
@ -38,14 +40,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
# define ALIGN(n) .p2align n
|
||||
#endif
|
||||
|
||||
#ifndef cfi_startproc
|
||||
# define cfi_startproc .cfi_startproc
|
||||
#endif
|
||||
|
||||
#ifndef cfi_endproc
|
||||
# define cfi_endproc .cfi_endproc
|
||||
#endif
|
||||
|
||||
#ifndef cfi_rel_offset
|
||||
# define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off
|
||||
#endif
|
||||
|
@ -58,21 +52,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
# define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off
|
||||
#endif
|
||||
|
||||
#ifndef ENTRY
|
||||
# define ENTRY(name) \
|
||||
.type name, @function; \
|
||||
.globl name; \
|
||||
.p2align 4; \
|
||||
name: \
|
||||
cfi_startproc
|
||||
#endif
|
||||
|
||||
#ifndef END
|
||||
# define END(name) \
|
||||
cfi_endproc; \
|
||||
.size name, .-name
|
||||
#endif
|
||||
|
||||
#define CFI_PUSH(REG) \
|
||||
cfi_adjust_cfa_offset (4); \
|
||||
cfi_rel_offset (REG, 0)
|
||||
|
@ -84,10 +63,11 @@ name: \
|
|||
#define PUSH(REG) pushl REG; CFI_PUSH (REG)
|
||||
#define POP(REG) popl REG; CFI_POP (REG)
|
||||
|
||||
#define DEST PARMS
|
||||
#define CHR DEST+4
|
||||
#define DST PARMS
|
||||
#define CHR DST+4
|
||||
#define LEN CHR+4
|
||||
#define SETRTNVAL movl DEST(%esp), %eax
|
||||
#define CHK_DST_LEN (LEN+4)
|
||||
#define SETRTNVAL movl DST(%esp), %eax
|
||||
|
||||
#if (defined SHARED || defined __PIC__)
|
||||
# define ENTRANCE PUSH (%ebx);
|
||||
|
@ -132,13 +112,17 @@ __x86.get_pc_thunk.bx:
|
|||
jmp *TABLE(,%ecx,4)
|
||||
#endif
|
||||
|
||||
#ifndef MEMSET
|
||||
# define MEMSET memset
|
||||
#endif
|
||||
ENTRY(__memset_chk)
|
||||
movl LEN(%esp), %ecx
|
||||
cmpl %ecx, CHK_DST_LEN(%esp)
|
||||
jbe memset
|
||||
|
||||
jmp __memset_chk_fail
|
||||
END(__memset_chk)
|
||||
|
||||
.section .text.sse2,"ax",@progbits
|
||||
ALIGN (4)
|
||||
ENTRY (MEMSET)
|
||||
ENTRY (memset)
|
||||
ENTRANCE
|
||||
|
||||
movl LEN(%esp), %ecx
|
||||
|
@ -148,7 +132,7 @@ ENTRY (MEMSET)
|
|||
movl %eax, %edx
|
||||
shl $16, %eax
|
||||
or %edx, %eax
|
||||
movl DEST(%esp), %edx
|
||||
movl DST(%esp), %edx
|
||||
cmp $32, %ecx
|
||||
jae L(32bytesormore)
|
||||
|
||||
|
@ -903,4 +887,4 @@ L(aligned_16_15bytes):
|
|||
SETRTNVAL
|
||||
RETURN_END
|
||||
|
||||
END (MEMSET)
|
||||
END (memset)
|
||||
|
|
|
@ -28,11 +28,9 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "cache.h"
|
||||
#include <private/bionic_asm.h>
|
||||
|
||||
#ifndef MEMSET
|
||||
# define MEMSET memset
|
||||
#endif
|
||||
#include "cache.h"
|
||||
|
||||
#ifndef L
|
||||
# define L(label) .L##label
|
||||
|
@ -42,14 +40,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
# define ALIGN(n) .p2align n
|
||||
#endif
|
||||
|
||||
#ifndef cfi_startproc
|
||||
# define cfi_startproc .cfi_startproc
|
||||
#endif
|
||||
|
||||
#ifndef cfi_endproc
|
||||
# define cfi_endproc .cfi_endproc
|
||||
#endif
|
||||
|
||||
#ifndef cfi_rel_offset
|
||||
# define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off
|
||||
#endif
|
||||
|
@ -62,21 +52,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
# define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off
|
||||
#endif
|
||||
|
||||
#ifndef ENTRY
|
||||
# define ENTRY(name) \
|
||||
.type name, @function; \
|
||||
.globl name; \
|
||||
.p2align 4; \
|
||||
name: \
|
||||
cfi_startproc
|
||||
#endif
|
||||
|
||||
#ifndef END
|
||||
# define END(name) \
|
||||
cfi_endproc; \
|
||||
.size name, .-name
|
||||
#endif
|
||||
|
||||
#define CFI_PUSH(REG) \
|
||||
cfi_adjust_cfa_offset (4); \
|
||||
cfi_rel_offset (REG, 0)
|
||||
|
@ -88,10 +63,11 @@ name: \
|
|||
#define PUSH(REG) pushl REG; CFI_PUSH (REG)
|
||||
#define POP(REG) popl REG; CFI_POP (REG)
|
||||
|
||||
#define DEST PARMS
|
||||
#define CHR DEST+4
|
||||
#define DST PARMS
|
||||
#define CHR DST+4
|
||||
#define LEN CHR+4
|
||||
#define SETRTNVAL movl DEST(%esp), %eax
|
||||
#define CHK_DST_LEN (LEN+4)
|
||||
#define SETRTNVAL movl DST(%esp), %eax
|
||||
|
||||
#if (defined SHARED || defined __PIC__)
|
||||
# define ENTRANCE PUSH (%ebx);
|
||||
|
@ -136,9 +112,17 @@ __x86.get_pc_thunk.bx:
|
|||
jmp *TABLE(,%ecx,4)
|
||||
#endif
|
||||
|
||||
ENTRY(__memset_chk)
|
||||
movl LEN(%esp), %ecx
|
||||
cmpl %ecx, CHK_DST_LEN(%esp)
|
||||
jbe memset
|
||||
|
||||
jmp __memset_chk_fail
|
||||
END(__memset_chk)
|
||||
|
||||
.section .text.sse2,"ax",@progbits
|
||||
ALIGN (4)
|
||||
ENTRY (MEMSET)
|
||||
ENTRY(memset)
|
||||
ENTRANCE
|
||||
|
||||
movl LEN(%esp), %ecx
|
||||
|
@ -154,7 +138,7 @@ L(1byteormore):
|
|||
movl %eax, %edx
|
||||
shl $16, %eax
|
||||
or %edx, %eax
|
||||
movl DEST(%esp), %edx
|
||||
movl DST(%esp), %edx
|
||||
cmp $1, %ecx
|
||||
je L(1byte)
|
||||
cmp $16, %ecx
|
||||
|
@ -824,4 +808,4 @@ L(aligned_16_15bytes):
|
|||
SETRTNVAL
|
||||
RETURN_END
|
||||
|
||||
END (MEMSET)
|
||||
END(memset)
|
||||
|
|
|
@ -153,7 +153,7 @@ void* __memrchr_chk(const void* s, int c, size_t n, size_t actual_size) {
|
|||
return memrchr(s, c, n);
|
||||
}
|
||||
|
||||
#if !defined(__aarch64__) && !defined(__arm__) && !defined(__x86_64__) // TODO: add optimized assembler for the others too.
|
||||
#if defined(__mips__) // TODO: add optimized assembler for mips too, and remove this.
|
||||
// Runtime implementation of __builtin___memset_chk (used directly by compiler, not in headers).
|
||||
extern "C" void* __memset_chk(void* dst, int byte, size_t count, size_t dst_len) {
|
||||
__check_count("memset", "count", count);
|
||||
|
|
Loading…
Reference in a new issue