From eef2d5d4f03f13187ca2fe11e8249cc7abcd016f Mon Sep 17 00:00:00 2001 From: suwanghw Date: Fri, 25 Aug 2023 17:53:01 +0800 Subject: [PATCH] add musl libc and bound check functions introduction Signed-off-by: suwanghw --- .../opentrustee-app-develop-guidelines.md | 473 +++++++++++++++++- 1 file changed, 472 insertions(+), 1 deletion(-) diff --git a/docs/opentrustee-guidelines/opentrustee-app-develop-guidelines.md b/docs/opentrustee-guidelines/opentrustee-app-develop-guidelines.md index 196c865..73b9fe9 100644 --- a/docs/opentrustee-guidelines/opentrustee-app-develop-guidelines.md +++ b/docs/opentrustee-guidelines/opentrustee-app-develop-guidelines.md @@ -267,4 +267,475 @@ OpenTrustee SDK中提供了TA一键编译和签名脚本,将tee_dev_kit/sdk/bu - 单个TA最大会话数量上限为8 - TA应优化自己的内存占用,避免占用过多内存,导致OpenTrustee系统内存耗尽 -### TA API \ No newline at end of file +### TA API + +### TEE标准C库支持 + +支持大多数的POSIX接口,具体支持情况请参考:POSIX:[https://mirror.math.princeton.edu/pub/oldlinux/download/c953.pdf](https://mirror.math.princeton.edu/pub/oldlinux/download/c953.pdf) + +支持绝大多数的libc接口。使用musl/libc库,接口支持请参考下表。 + +>![](public_sys-resources/icon-note.gif) **说明:** +>- 不支持文件系统、控制台。 +>- 不支持fstat,fsync,writev接口。 +>- stdio中的printf函数目前不支持文件系统,文件操作只支持标准输入输出。 + +**表 1** 标准C支持列表 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

模块

+

函数接口名

+

pthread

+

sem_getvalue

+

sem_init

+

sem_post

+

sem_wait

+

pthread_mutex_destroy

+

pthread_mutex_init

+

pthread_mutex_lock

+

pthread_mutex_trylock

+

pthread_mutex_unlock

+

pthread_mutexattr_destroy

+

pthread_mutexattr_init

+

pthread_mutexattr_setprotocol

+

pthread_mutexattr_settype

+

pthread_mutexattr_setrobust

+

pthread_spin_destroy

+

pthread_spin_init

+

pthread_spin_lock/p> +

pthread_spin_trylock

+

pthread_spin_unlock

+

pthread_cond_broadcast

+

pthread_cond_destroy

+

pthread_cond_init

+

pthread_cond_signal

+

pthread_cond_wait

+

pthread_attr_destroy

+

pthread_attr_getstack

+

pthread_attr_getstacksize

+

pthread_attr_init

+

pthread_attr_setstack

+

pthread_attr_setstacksize

+

pthread_create

+

pthread_equal

+

pthread_exit

+

pthread_getspecific

+

pthread_join

+

pthread_key_create

+

pthread_key_delete

+

pthread_once

+

pthread_self

+

pthread_setschedprio

+

pthread_setspecific

+

malloc

+

aligned_alloc

+

calloc

+

malloc

+

realloc

+

free

+

posix_memalign

+

mman

+

mmap

+

munmap

+

time

+

gettimeofday

+

strftime

+

time

+

stdio

+

printf

+

scanf

+

snprintf

+

sprintf

+

vsnprintf

+

vsprintf

+

errno

+

errno

+

strerror

+

exit

+

abort

+

unistd

+

getpid

+

locale

+

setlocale

+

strcoll

+

strxfrm

+

strtod

+

multibyte

+

mbrtowc

+

wcrtomb

+

wctob

+

prng

+

srandom

+

initstate

+

setstate

+

random

+

string

+

memchr

+

memcmp

+

memcpy

+

memmove

+

memset

+

strchr

+

strcmp

+

strcpy

+

strlen

+

strncmp

+

strncpy

+

strnlen

+

strrchr

+

strstr

+

wcschr

+

wcslen

+

wmemchr

+

ctype

+

isalpha

+

isascii

+

isdigit

+

islower

+

isprint

+

isspace

+

iswctype

+

iswdigit

+

iswlower

+

iswspace

+

iswupper

+

towupper

+

towlower

+

math

+

atan

+

ceil

+

ceilf

+

copysignl

+

exp

+

fabs

+

floor

+

frexp

+

frexpl

+

log

+

log2

+

pow

+

roundf

+

scalbn

+

scalbnl

+

sqrt

+

stdlib

+

abs

+

atof

+

atoi

+

atol

+

atoll

+

bsearch

+

div

+

ecvt

+

imaxabs

+

llabs

+

qsort

+

strtoul

+

strtol

+

wcstod

+
+ +### TEE支持的安全函数 + +#### 安全函数库介绍 + +遵循C11 Annex K \(Bounds-checking interfaces\)的标准,选取并实现了常见的内存/字符串操作类的函数,如memcpy\_s、strcpy\_s等函数。 + +#### 函数清单 + +- memcpy\_s +- memmove\_s +- memset\_s +- strcpy\_s +- strncpy\_s +- strcat\_s +- strncat\_s +- strtok\_s +- snprintf\_s +- vsnprintf\_s \ No newline at end of file -- Gitee