Add KX extension to tcc (autoload w/import table support), phase 2.2

Fixed bug in case unused libraries
Improved align algorithm
Filled kx folder including docs, libs

git-svn-id: svn://kolibrios.org@9513 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Coldy 2021-12-28 11:56:49 +00:00
parent ec81f654c0
commit 2f2a91947f
23 changed files with 1412 additions and 22 deletions

View File

@ -0,0 +1,21 @@
+ Library autoload
Now you don't need to think about having to load dependent libraries.
The most of this work will be done by TCC and Dll.obj
+ Easy linking using *.def files
All you need to do is connect the files describing the symbols
of the used libraries. This files have plain text format and may
easy created in any text editor. If one or more libraries use the same
symbols you may use name prefix to solve symbols conflicts
No more complicated of creating *.o and/or *.a files
+ Reduced image size
Since the library loader no longer needs to be placed in every application,
this reduces the size of the image. No more C layer neded, all dependent
libraries loading and also initialized automatically.
The compact format of the import table is also used.
+ Backward compatible
You don't need change your project. But the features described above will
require reconfiguration. Once you have tried it, you do not want to come back.

View File

@ -0,0 +1,30 @@
Версия расширения KX - 0.4.3
Обзор новых возможностей
+ Автозагрузка библиотек
Теперь Вам не нужно думать о загрузке зависимых библиотек.
Большая часть этой работы будет сделана TCC и Dll.obj.
+ Простое связывание с использованием *.def файлов
Все, что Вам нужно сделать, это подключить файлы с описанием символов
используемых библиотек. Эти файлы имеют простой текстовый формат и могут
легко создаваться в любом текстовом редакторе. Если одна или несколько
библиотек используют один или более одинаковых символов, Вы можете
использовать префикс имени для разрешения конфликтов символов.
Больше не нужно создавать и подключать сложные *.o и/или *.a файлы
зависимых бибилиотек (исключение - файлы crt0.o и libtcc.a, но они
поставляются в комлекте).
+ Уменьшенный размер образа
Поскольку загрузчик библиотек больше не нужно размещать в каждом
приложении, это уменьшает размер образа. Больше не нужен слой C
(C layer), все зависимые библиотеки загружаются, а также инициализируются
автоматически. Также используется компактный формат таблицы импорта.
+ Обратная совместимость
Если Вы по каким то причинам не хотите, либо пока не готовы использовать
новые возможности, изменять настройки проекта не требуется. Все будет
работать как раньше. Но для использования описанных выше особенностей
требуется несложная перенастройка проекта.

View File

@ -0,0 +1,9 @@
0.4.4
+ Исправлена ошибка при задании неиспользуемых библиотек
+ Улучшен алгоритм выравнивания после строк библиотек и символов, это
дополнительно уменьшит размер некоторых приложений
0.4.3
Первый релиз, с помощью которого собираются все приложениия использующие
tcc в автосборке

View File

@ -0,0 +1,98 @@
Быстрый старт
Для использования новых возможностей предоставляемых расширением KX
необходимо использовать файл конфигурации tcc.conf в папке где расположен tcc
Этот файл перенастраивает директорию %ktcc_root%\ на %ktcc_root%\kx.
В данной директории присутствует папка lib с файлами
*.def, crt.0 и libtcc.a
Во избежание конфликтов бибилиотек с использованием возможностей
предоставляемых расширением KX рекомендуется использовать только одну
директорию с библиотеками. Если определено несколько директорий библиотек,
в каждой из них не должно быть конфликтных библиотек. Например,
при таком подключении библиотеки
-llibc
tcc ищет файлы в следующем порядке: libc.def, liblibc.def, liblibc.a
Обратите внимание, что все три варианта будут правильными и будет использован
первая найденная бибилиотека. Также обратите внимание, что для корректной
работы приложения с расширением KX все динамические библиотеки должны быть
обработаны только с *.def
В остальном tcc используется как обычно (см. справку tcc)
Примечание:
ключ -nobss был удален, так как он не имеет смысла (ранее генерировавшаяся
bss секция заполнялась нулями и занимала ненужное место в файле, эта секция
не должна содержаться в образе и ядро инициализирует эту часть нялями
автоматически при загрузке)
Файлы определения символов
Расширение KX использует файлы определений символов (*.def). Файлы *.def
используют простой формат и могут создваться и редактироваться в любом
удобном текстовом редакторе. Структура файла *.def описана ниже.
; Комментарии начинаются точкой с запятой и игнорируются при обработке
;
; Первая строка должна начинаться с ключевого слова LIBRARY с указанием
; имени библиотки c расширением (не более 3 симоволов после точки)
LIBRARY libname.obj
; На следующей строке следует ключевое слово EXPORTS и
; опциональный ключ prefix
EXPORTS [prefix]
; если задан ключ prefix, то во всех символах должен использоваться
; префикс из имени библиотеки (без расширения) со следующим за ним символом
; подчеркивания. Префикс будет отброшен при постоении таблицы импорта
; Например, для библиотеки http.obj префикс должен быть http_
; из символа http_get в таблицу импорта будет записан символ get
[libname_]entry1
[libname_]entry2
; все остальные символы библиотеки
Проверка поддержки расширения KX
Для проверки, что tcc поддерживает расширение KX:
1. в командной строке наберите
tcc -v
Строка ниже означает, что имеется поддерка расширения KX
tcc version 0.9.26 (i386 KolibriOS/KX extension)
2. В коде для условной компиляции используйте директивы препроцессора
проверки предопределенного макроса __KX__, например
#ifdef __KX__
// код который должен компилироваться только с расширением KX
#else
// код, который не зависит от расширения KX
#endif
Обратите внимание, что в настоящее всемя этот макрос показывает, что
компилятор поддерживает расширение KX. По умолчанию этот макрос будет
определен всегда, даже если Вы по каким то причинам не желаете
использовать новые преимущества. При использовании текущих
особенностей разделять код описанным в примере выше способом в
большинстве случаев не требуется.
Обеспечение совместимости
Если для обеспечения совместимости необходимо отделить код, чтобы его можно
было использовать как с расширением KX, так и без него, Вы можете определить
дополнительный макрос и таким образом разделять код на нужные участки,
например. Настоятельно рекомендуется использовать только код с поддержкой
расширения KX.
...
#ifdef _C_LAYER
// Код который выполняется без поддержки расширения KX
/ использующий старый метод загрузки
if(!kolibri_libimg_init()){ // Загружаем libimg.obj
notify_show("Libimg.obj not loaded!' -E");
exit(0);
}
#endif
...

View File

@ -0,0 +1,98 @@
LIBRARY box_lib.obj
EXPORTS
edit_box
edit_box_key
edit_box_mouse
edit_box_set_text
version_ed
init_checkbox2
check_box_draw2
check_box_mouse2
version_ch2
option_box_draw
option_box_mouse
version_op
scrollbar_v_draw
scrollbar_v_mouse
scrollbar_h_draw
scrollbar_h_mouse
version_scrollbar
dbutton_draw
dbutton_mouse
version_dbutton
menu_bar_draw
menu_bar_mouse
menu_bar_activate
version_menu_bar
FileBrowser_draw
FileBrowser_mouse
FileBrowser_key
version_FileBrowser
tl_data_init
tl_data_clear
tl_info_clear
tl_key
tl_mouse
tl_draw
tl_info_undo
tl_info_redo
tl_node_add
tl_node_set_data
tl_node_get_data
tl_node_delete
tl_cur_beg
tl_cur_next
tl_cur_perv
tl_node_close_open
tl_node_lev_inc
tl_node_lev_dec
tl_node_move_up
tl_node_move_down
tl_node_poi_get_info
tl_node_poi_get_next_info
tl_node_poi_get_data
tl_save_mem
tl_load_mem
tl_get_mem_size
version_tree_list
PathShow_prepare
PathShow_draw
version_PathShow
ted_but_sumb_upper
ted_but_sumb_lover
ted_but_convert_by_table
ted_can_save
ted_clear
ted_delete
ted_draw
ted_init
ted_init_scroll_bars
ted_init_syntax_file
ted_is_select
ted_key
ted_mouse
ted_open_file
ted_save_file
ted_text_add
ted_but_select_word
ted_but_cut
ted_but_copy
ted_but_paste
ted_but_undo
ted_but_redo
ted_but_reverse
ted_but_find
ted_but_replace
ted_text_colored
ted_go_to_position
version_text_edit
frame_draw
version_frame
progressbar_draw
progressbar_progress
tooltip_init
tooltip_delete
tooltip_test_show
tooltip_mouse
get_font_size

View File

@ -0,0 +1,25 @@
LIBRARY console.obj
EXPORTS
;START
con_init
con_write_asciiz
con_write_string
con_printf
con_exit
;version
con_get_flags
con_set_flags
con_kbhit
con_getch
con_getch2
con_gets
con_gets2
con_get_font_height
con_get_cursor_height
con_set_cursor_height
con_cls
con_get_cursor_pos
con_set_cursor_pos
con_set_title
con_get_input

Binary file not shown.

View File

@ -0,0 +1,14 @@
LIBRARY proc_lib.obj
EXPORTS
ColorDialog_init
OpenDialog_start
OpenDialog_init
OpenDialog_set_file_ext
OpenDialog_set_file_name
OpenDialog_start
Version_OpenDialog
Version_ColorDialog
;EXPORTS prefix
;proc_lib_version <<= need local (2x underscores)

View File

@ -0,0 +1,9 @@
LIBRARY http.obj
EXPORTS prefix
http_get
http_head
http_post
http_receive
http_send
http_free

View File

@ -0,0 +1,20 @@
LIBRARY libimg.obj
EXPORTS
img_blend
img_convert
img_count
img_create
img_decode
img_destroy
img_destroy_layer
img_draw
img_encode
img_flip
img_flip_layer
img_resize_data
img_rotate
img_rotate_layer
img_scale
img_to_rgb
img_to_rgb2

View File

@ -0,0 +1,177 @@
LIBRARY libc.obj
EXPORTS
;____STDIO______
clearerr
debug_printf
fclose
feof
ferror
fflush
fgetc
fgetpos
fgets
fopen
fprintf
fputc
fputs
fread
freopen
fscanf
fseek
fsetpos
ftell
fwrite
getchar
gets
perror
printf
puts
remove
rename
rewind
scanf
setbuf
setvbuf
snprintf
sprintf
sscanf
tmpfile
tmpnam
vfscanf
vprintf
vfscanf
vsprintf
vsnprintf
vsscanf
ungetc
;____STDLIB____
abs
atoi
atol
atoll
atof
calloc
exit
free
itoa
labs
llabs
malloc
realloc
strtol
srand
rand
qsort
strtod
__assert_fail
;____STRING____
;memcpy
memchr
memcmp
!memmove
!memset
strncat
strchr
strcat
strcmp
strcoll
strcpy
strcspn
strdup
strerror
strlen
strncat
strncmp
strncpy
strrchr
strrev
strspn
strstr
strtok
strxfrm
_errno
;____SYS____
closedir
opendir
readdir
rewinddir
seekdir
telldir
getcwd
mkdir
rmdir
setcwd
getcwd
;____SOCKET____
socket
close
bind
listen
connect
accept
send
recv
setsockopt
socketpair
;____UNISTD____
;____MATH____
acosh
asinh
atanh
acosh
frexp
hypot
ldexp
sinh
tanh
acos
asin
atan
atan2
ceil
cos
exp
fabs
floor
fmod
log
modf
modfl
pow
pow2
pow10
;____LONGJMP____
longjmp
setjmp
;____CTYPE____
__is
tolower
toupper
;___CONIO___
con_set_title
con_init
con_init_opt
con_write_asciiz
con_write_string
con_printf
con_exit
con_get_flags
con_set_flags
con_kbhit
con_getch
con_getch2
con_gets
con_gets2
con_get_font_height
con_get_cursor_height
con_set_cursor_height
con_cls
con_get_cursor_pos
con_set_cursor_pos
;____TIME____
mktime
time
localtime
asctime
difftime

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,751 @@
LIBRARY mbedtls.obj
EXPORTS
mbedtls_aes_crypt_cbc
mbedtls_aes_crypt_cfb128
mbedtls_aes_crypt_cfb8
mbedtls_aes_crypt_ctr
mbedtls_aes_crypt_ecb
mbedtls_aes_crypt_ofb
mbedtls_aes_crypt_xts
mbedtls_aes_decrypt
mbedtls_aes_encrypt
mbedtls_aes_free
mbedtls_aes_init
mbedtls_aes_self_test
mbedtls_aes_setkey_dec
mbedtls_aes_setkey_enc
mbedtls_aes_xts_free
mbedtls_aes_xts_init
mbedtls_aes_xts_setkey_dec
mbedtls_aes_xts_setkey_enc
mbedtls_arc4_crypt
mbedtls_arc4_free
mbedtls_arc4_init
mbedtls_arc4_self_test
mbedtls_arc4_setup
mbedtls_asn1_find_named_data
mbedtls_asn1_free_named_data
mbedtls_asn1_free_named_data_list
mbedtls_asn1_get_alg
mbedtls_asn1_get_alg_null
mbedtls_asn1_get_bitstring
mbedtls_asn1_get_bitstring_null
mbedtls_asn1_get_bool
mbedtls_asn1_get_int
mbedtls_asn1_get_len
mbedtls_asn1_get_mpi
mbedtls_asn1_get_sequence_of
mbedtls_asn1_get_tag
mbedtls_asn1_store_named_data
mbedtls_asn1_write_algorithm_identifier
mbedtls_asn1_write_bitstring
mbedtls_asn1_write_bool
mbedtls_asn1_write_ia5_string
mbedtls_asn1_write_int
mbedtls_asn1_write_len
mbedtls_asn1_write_mpi
mbedtls_asn1_write_null
mbedtls_asn1_write_octet_string
mbedtls_asn1_write_oid
mbedtls_asn1_write_printable_string
mbedtls_asn1_write_raw_buffer
mbedtls_asn1_write_tag
mbedtls_asn1_write_tagged_string
mbedtls_asn1_write_utf8_string
mbedtls_base64_decode
mbedtls_base64_encode
mbedtls_base64_self_test
mbedtls_blowfish_crypt_cbc
mbedtls_blowfish_crypt_cfb64
mbedtls_blowfish_crypt_ctr
mbedtls_blowfish_crypt_ecb
mbedtls_blowfish_free
mbedtls_blowfish_init
mbedtls_blowfish_setkey
mbedtls_camellia_crypt_cbc
mbedtls_camellia_crypt_cfb128
mbedtls_camellia_crypt_ctr
mbedtls_camellia_crypt_ecb
mbedtls_camellia_free
mbedtls_camellia_init
mbedtls_camellia_self_test
mbedtls_camellia_setkey_dec
mbedtls_camellia_setkey_enc
mbedtls_ccm_auth_decrypt
mbedtls_ccm_encrypt_and_tag
mbedtls_ccm_free
mbedtls_ccm_init
mbedtls_ccm_self_test
mbedtls_ccm_setkey
mbedtls_ccm_star_auth_decrypt
mbedtls_ccm_star_encrypt_and_tag
mbedtls_chacha20_crypt
mbedtls_chacha20_free
mbedtls_chacha20_init
mbedtls_chacha20_self_test
mbedtls_chacha20_setkey
mbedtls_chacha20_starts
mbedtls_chacha20_update
mbedtls_chachapoly_auth_decrypt
mbedtls_chachapoly_encrypt_and_tag
mbedtls_chachapoly_finish
mbedtls_chachapoly_free
mbedtls_chachapoly_init
mbedtls_chachapoly_self_test
mbedtls_chachapoly_setkey
mbedtls_chachapoly_starts
mbedtls_chachapoly_update
mbedtls_chachapoly_update_aad
mbedtls_cipher_auth_decrypt
mbedtls_cipher_auth_encrypt
mbedtls_cipher_check_tag
mbedtls_cipher_crypt
mbedtls_cipher_finish
mbedtls_cipher_free
mbedtls_cipher_info_from_string
mbedtls_cipher_info_from_type
mbedtls_cipher_info_from_values
mbedtls_cipher_init
mbedtls_cipher_list
mbedtls_cipher_reset
mbedtls_cipher_set_iv
mbedtls_cipher_setkey
mbedtls_cipher_set_padding_mode
mbedtls_cipher_setup
mbedtls_cipher_update
mbedtls_cipher_update_ad
mbedtls_cipher_write_tag
mbedtls_ctr_drbg_free
mbedtls_ctr_drbg_init
mbedtls_ctr_drbg_random
mbedtls_ctr_drbg_random_with_add
mbedtls_ctr_drbg_reseed
mbedtls_ctr_drbg_seed
mbedtls_ctr_drbg_seed_entropy_len
mbedtls_ctr_drbg_self_test
mbedtls_ctr_drbg_set_entropy_len
mbedtls_ctr_drbg_set_prediction_resistance
mbedtls_ctr_drbg_set_reseed_interval
mbedtls_ctr_drbg_update
mbedtls_ctr_drbg_update_ret
mbedtls_debug_print_buf
mbedtls_debug_print_crt
mbedtls_debug_print_ecp
mbedtls_debug_printf_ecdh
mbedtls_debug_print_mpi
mbedtls_debug_print_msg
mbedtls_debug_print_ret
mbedtls_debug_set_threshold
mbedtls_des3_crypt_cbc
mbedtls_des3_crypt_ecb
mbedtls_des3_free
mbedtls_des3_init
mbedtls_des3_set2key_dec
mbedtls_des3_set2key_enc
mbedtls_des3_set3key_dec
mbedtls_des3_set3key_enc
mbedtls_des_crypt_cbc
mbedtls_des_crypt_ecb
mbedtls_des_free
mbedtls_des_init
mbedtls_des_key_check_key_parity
mbedtls_des_key_check_weak
mbedtls_des_key_set_parity
mbedtls_des_self_test
mbedtls_des_setkey
mbedtls_des_setkey_dec
mbedtls_des_setkey_enc
mbedtls_dhm_calc_secret
mbedtls_dhm_free
mbedtls_dhm_init
mbedtls_dhm_make_params
mbedtls_dhm_make_public
mbedtls_dhm_parse_dhm
mbedtls_dhm_read_params
mbedtls_dhm_read_public
mbedtls_dhm_self_test
mbedtls_dhm_set_group
mbedtls_ecdh_calc_secret
mbedtls_ecdh_compute_shared
mbedtls_ecdh_free
mbedtls_ecdh_gen_public
mbedtls_ecdh_get_params
mbedtls_ecdh_init
mbedtls_ecdh_make_params
mbedtls_ecdh_make_public
mbedtls_ecdh_read_params
mbedtls_ecdh_read_public
mbedtls_ecdh_setup
mbedtls_ecdsa_free
mbedtls_ecdsa_from_keypair
mbedtls_ecdsa_genkey
mbedtls_ecdsa_init
mbedtls_ecdsa_read_signature
mbedtls_ecdsa_read_signature_restartable
mbedtls_ecdsa_sign
mbedtls_ecdsa_sign_det
mbedtls_ecdsa_sign_det_ext
mbedtls_ecdsa_verify
mbedtls_ecdsa_write_signature
mbedtls_ecdsa_write_signature_det
mbedtls_ecdsa_write_signature_restartable
mbedtls_ecp_check_privkey
mbedtls_ecp_check_pubkey
mbedtls_ecp_check_pub_priv
mbedtls_ecp_copy
mbedtls_ecp_curve_info_from_grp_id
mbedtls_ecp_curve_info_from_name
mbedtls_ecp_curve_info_from_tls_id
mbedtls_ecp_curve_list
mbedtls_ecp_gen_key
mbedtls_ecp_gen_keypair
mbedtls_ecp_gen_keypair_base
mbedtls_ecp_gen_privkey
mbedtls_ecp_group_copy
mbedtls_ecp_group_free
mbedtls_ecp_group_init
mbedtls_ecp_group_load
mbedtls_ecp_grp_id_list
mbedtls_ecp_is_zero
mbedtls_ecp_keypair_free
mbedtls_ecp_keypair_init
mbedtls_ecp_mul
mbedtls_ecp_muladd
mbedtls_ecp_muladd_restartable
mbedtls_ecp_mul_restartable
mbedtls_ecp_point_cmp
mbedtls_ecp_point_free
mbedtls_ecp_point_init
mbedtls_ecp_point_read_binary
mbedtls_ecp_point_read_string
mbedtls_ecp_point_write_binary
mbedtls_ecp_self_test
mbedtls_ecp_set_zero
mbedtls_ecp_tls_read_group
mbedtls_ecp_tls_read_group_id
mbedtls_ecp_tls_read_point
mbedtls_ecp_tls_write_group
mbedtls_ecp_tls_write_point
mbedtls_entropy_add_source
mbedtls_entropy_free
mbedtls_entropy_func
mbedtls_entropy_gather
mbedtls_entropy_init
mbedtls_entropy_self_test
mbedtls_entropy_update_manual
mbedtls_gcm_auth_decrypt
mbedtls_gcm_crypt_and_tag
mbedtls_gcm_finish
mbedtls_gcm_free
mbedtls_gcm_init
mbedtls_gcm_self_test
mbedtls_gcm_setkey
mbedtls_gcm_starts
mbedtls_gcm_update
mbedtls_hkdf
mbedtls_hkdf_expand
mbedtls_hkdf_extract
mbedtls_hmac_drbg_free
mbedtls_hmac_drbg_init
mbedtls_hmac_drbg_random
mbedtls_hmac_drbg_random_with_add
mbedtls_hmac_drbg_reseed
mbedtls_hmac_drbg_seed
mbedtls_hmac_drbg_seed_buf
mbedtls_hmac_drbg_self_test
mbedtls_hmac_drbg_set_entropy_len
mbedtls_hmac_drbg_set_prediction_resistance
mbedtls_hmac_drbg_set_reseed_interval
mbedtls_hmac_drbg_update
mbedtls_hmac_drbg_update_ret
mbedtls_init
mbedtls_internal_aes_decrypt
mbedtls_internal_aes_encrypt
mbedtls_internal_md5_process
mbedtls_internal_ripemd160_process
mbedtls_internal_sha1_process
mbedtls_internal_sha256_process
mbedtls_internal_sha512_process
mbedtls_md
mbedtls_md5
mbedtls_md5_clone
mbedtls_md5_finish
mbedtls_md5_finish_ret
mbedtls_md5_free
mbedtls_md5_init
mbedtls_md5_process
mbedtls_md5_ret
mbedtls_md5_self_test
mbedtls_md5_starts
mbedtls_md5_starts_ret
mbedtls_md5_update
mbedtls_md5_update_ret
mbedtls_md_clone
mbedtls_md_finish
mbedtls_md_free
mbedtls_md_get_name
mbedtls_md_get_size
mbedtls_md_get_type
mbedtls_md_hmac
mbedtls_md_hmac_finish
mbedtls_md_hmac_reset
mbedtls_md_hmac_starts
mbedtls_md_hmac_update
mbedtls_md_info_from_string
mbedtls_md_info_from_type
mbedtls_md_init
mbedtls_md_init_ctx
mbedtls_md_list
mbedtls_md_process
mbedtls_md_setup
mbedtls_md_starts
mbedtls_md_update
mbedtls_mpi_add_abs
mbedtls_mpi_add_int
mbedtls_mpi_add_mpi
mbedtls_mpi_bitlen
mbedtls_mpi_cmp_abs
mbedtls_mpi_cmp_int
mbedtls_mpi_cmp_mpi
mbedtls_mpi_copy
mbedtls_mpi_div_int
mbedtls_mpi_div_mpi
mbedtls_mpi_exp_mod
mbedtls_mpi_fill_random
mbedtls_mpi_free
mbedtls_mpi_gcd
mbedtls_mpi_gen_prime
mbedtls_mpi_get_bit
mbedtls_mpi_grow
mbedtls_mpi_init
mbedtls_mpi_inv_mod
mbedtls_mpi_is_prime
mbedtls_mpi_is_prime_ext
mbedtls_mpi_lsb
mbedtls_mpi_lset
mbedtls_mpi_lt_mpi_ct
mbedtls_mpi_mod_int
mbedtls_mpi_mod_mpi
mbedtls_mpi_mul_int
mbedtls_mpi_mul_mpi
mbedtls_mpi_read_binary
mbedtls_mpi_read_string
mbedtls_mpi_safe_cond_assign
mbedtls_mpi_safe_cond_swap
mbedtls_mpi_self_test
mbedtls_mpi_set_bit
mbedtls_mpi_shift_l
mbedtls_mpi_shift_r
mbedtls_mpi_shrink
mbedtls_mpi_size
mbedtls_mpi_sub_abs
mbedtls_mpi_sub_int
mbedtls_mpi_sub_mpi
mbedtls_mpi_swap
mbedtls_mpi_write_binary
mbedtls_mpi_write_string
mbedtls_net_connect
mbedtls_net_free
mbedtls_net_init
mbedtls_net_recv
mbedtls_net_send
mbedtls_oid_get_attr_short_name
mbedtls_oid_get_cipher_alg
mbedtls_oid_get_ec_grp
mbedtls_oid_get_extended_key_usage
mbedtls_oid_get_md_alg
mbedtls_oid_get_md_hmac
mbedtls_oid_get_numeric_string
mbedtls_oid_get_oid_by_ec_grp
mbedtls_oid_get_oid_by_md
mbedtls_oid_get_oid_by_pk_alg
mbedtls_oid_get_oid_by_sig_alg
mbedtls_oid_get_pk_alg
mbedtls_oid_get_pkcs12_pbe_alg
mbedtls_oid_get_sig_alg
mbedtls_oid_get_sig_alg_desc
mbedtls_oid_get_x509_ext_type
mbedtls_padlock_has_support
mbedtls_padlock_xcryptcbc
mbedtls_padlock_xcryptecb
mbedtls_pem_free
mbedtls_pem_init
mbedtls_pem_read_buffer
mbedtls_pem_write_buffer
mbedtls_pk_can_do
mbedtls_pk_check_pair
mbedtls_pkcs12_derivation
mbedtls_pkcs12_pbe
mbedtls_pkcs12_pbe_sha1_rc4_128
mbedtls_pkcs5_pbes2
mbedtls_pkcs5_pbkdf2_hmac
mbedtls_pkcs5_self_test
mbedtls_pk_debug
mbedtls_pk_decrypt
mbedtls_pk_encrypt
mbedtls_pk_free
mbedtls_pk_get_bitlen
mbedtls_pk_get_name
mbedtls_pk_get_type
mbedtls_pk_info_from_type
mbedtls_pk_init
mbedtls_pk_parse_key
mbedtls_pk_parse_public_key
mbedtls_pk_parse_subpubkey
mbedtls_pk_setup
mbedtls_pk_setup_rsa_alt
mbedtls_pk_sign
mbedtls_pk_sign_restartable
mbedtls_pk_verify
mbedtls_pk_verify_ext
mbedtls_pk_verify_restartable
mbedtls_pk_write_key_der
mbedtls_pk_write_key_pem
mbedtls_pk_write_pubkey
mbedtls_pk_write_pubkey_der
mbedtls_pk_write_pubkey_pem
mbedtls_platform_gmtime_r
mbedtls_platform_setup
mbedtls_platform_teardown
mbedtls_platform_zeroize
mbedtls_poly1305_finish
mbedtls_poly1305_free
mbedtls_poly1305_init
mbedtls_poly1305_mac
mbedtls_poly1305_self_test
mbedtls_poly1305_starts
mbedtls_poly1305_update
mbedtls_ripemd160
mbedtls_ripemd160_clone
mbedtls_ripemd160_finish
mbedtls_ripemd160_finish_ret
mbedtls_ripemd160_free
mbedtls_ripemd160_init
mbedtls_ripemd160_process
mbedtls_ripemd160_ret
mbedtls_ripemd160_self_test
mbedtls_ripemd160_starts
mbedtls_ripemd160_starts_ret
mbedtls_ripemd160_update
mbedtls_ripemd160_update_ret
mbedtls_rsa_check_privkey
mbedtls_rsa_check_pubkey
mbedtls_rsa_check_pub_priv
mbedtls_rsa_complete
mbedtls_rsa_copy
mbedtls_rsa_deduce_crt
mbedtls_rsa_deduce_primes
mbedtls_rsa_deduce_private_exponent
mbedtls_rsa_export
mbedtls_rsa_export_crt
mbedtls_rsa_export_raw
mbedtls_rsa_free
mbedtls_rsa_gen_key
mbedtls_rsa_get_len
mbedtls_rsa_import
mbedtls_rsa_import_raw
mbedtls_rsa_init
mbedtls_rsa_pkcs1_decrypt
mbedtls_rsa_pkcs1_encrypt
mbedtls_rsa_pkcs1_sign
mbedtls_rsa_pkcs1_verify
mbedtls_rsa_private
mbedtls_rsa_public
mbedtls_rsa_rsaes_oaep_decrypt
mbedtls_rsa_rsaes_oaep_encrypt
mbedtls_rsa_rsaes_pkcs1_v15_decrypt
mbedtls_rsa_rsaes_pkcs1_v15_encrypt
mbedtls_rsa_rsassa_pkcs1_v15_sign
mbedtls_rsa_rsassa_pkcs1_v15_verify
mbedtls_rsa_rsassa_pss_sign
mbedtls_rsa_rsassa_pss_verify
mbedtls_rsa_rsassa_pss_verify_ext
mbedtls_rsa_self_test
mbedtls_rsa_set_padding
mbedtls_rsa_validate_crt
mbedtls_rsa_validate_params
mbedtls_sha1
mbedtls_sha1_clone
mbedtls_sha1_finish
mbedtls_sha1_finish_ret
mbedtls_sha1_free
mbedtls_sha1_init
mbedtls_sha1_process
mbedtls_sha1_ret
mbedtls_sha1_self_test
mbedtls_sha1_starts
mbedtls_sha1_starts_ret
mbedtls_sha1_update
mbedtls_sha1_update_ret
mbedtls_sha256
mbedtls_sha256_clone
mbedtls_sha256_finish
mbedtls_sha256_finish_ret
mbedtls_sha256_free
mbedtls_sha256_init
mbedtls_sha256_process
mbedtls_sha256_ret
mbedtls_sha256_self_test
mbedtls_sha256_starts
mbedtls_sha256_starts_ret
mbedtls_sha256_update
mbedtls_sha256_update_ret
mbedtls_sha512
mbedtls_sha512_clone
mbedtls_sha512_finish
mbedtls_sha512_finish_ret
mbedtls_sha512_free
mbedtls_sha512_init
mbedtls_sha512_process
mbedtls_sha512_ret
mbedtls_sha512_self_test
mbedtls_sha512_starts
mbedtls_sha512_starts_ret
mbedtls_sha512_update
mbedtls_sha512_update_ret
mbedtls_ssl_cache_free
mbedtls_ssl_cache_get
mbedtls_ssl_cache_init
mbedtls_ssl_cache_set
mbedtls_ssl_cache_set_max_entries
mbedtls_ssl_cache_set_timeout
mbedtls_ssl_check_cert_usage
mbedtls_ssl_check_curve
mbedtls_ssl_check_pending
mbedtls_ssl_check_sig_hash
mbedtls_ssl_ciphersuite_from_id
mbedtls_ssl_ciphersuite_from_string
mbedtls_ssl_ciphersuite_uses_ec
mbedtls_ssl_ciphersuite_uses_psk
mbedtls_ssl_close_notify
mbedtls_ssl_conf_alpn_protocols
mbedtls_ssl_conf_arc4_support
mbedtls_ssl_conf_authmode
mbedtls_ssl_conf_ca_chain
mbedtls_ssl_conf_cbc_record_splitting
mbedtls_ssl_conf_cert_profile
mbedtls_ssl_conf_cert_req_ca_list
mbedtls_ssl_conf_ciphersuites
mbedtls_ssl_conf_ciphersuites_for_version
mbedtls_ssl_conf_curves
mbedtls_ssl_conf_dbg
mbedtls_ssl_conf_dhm_min_bitlen
mbedtls_ssl_conf_dh_param
mbedtls_ssl_conf_dh_param_bin
mbedtls_ssl_conf_dh_param_ctx
mbedtls_ssl_conf_dtls_anti_replay
mbedtls_ssl_conf_dtls_badmac_limit
mbedtls_ssl_conf_dtls_cookies
mbedtls_ssl_conf_encrypt_then_mac
mbedtls_ssl_conf_endpoint
mbedtls_ssl_conf_export_keys_cb
mbedtls_ssl_conf_extended_master_secret
mbedtls_ssl_conf_fallback
mbedtls_ssl_conf_handshake_timeout
mbedtls_ssl_config_defaults
mbedtls_ssl_config_free
mbedtls_ssl_config_init
mbedtls_ssl_conf_legacy_renegotiation
mbedtls_ssl_conf_max_frag_len
mbedtls_ssl_conf_max_version
mbedtls_ssl_conf_min_version
mbedtls_ssl_conf_own_cert
mbedtls_ssl_conf_psk
mbedtls_ssl_conf_psk_cb
mbedtls_ssl_conf_read_timeout
mbedtls_ssl_conf_renegotiation
mbedtls_ssl_conf_renegotiation_enforced
mbedtls_ssl_conf_renegotiation_period
mbedtls_ssl_conf_rng
mbedtls_ssl_conf_session_cache
mbedtls_ssl_conf_session_tickets
mbedtls_ssl_conf_session_tickets_cb
mbedtls_ssl_conf_sig_hashes
mbedtls_ssl_conf_sni
mbedtls_ssl_conf_transport
mbedtls_ssl_conf_truncated_hmac
mbedtls_ssl_conf_verify
mbedtls_ssl_cookie_check
mbedtls_ssl_cookie_free
mbedtls_ssl_cookie_init
mbedtls_ssl_cookie_set_timeout
mbedtls_ssl_cookie_setup
mbedtls_ssl_cookie_write
mbedtls_ssl_derive_keys
mbedtls_ssl_dtls_replay_check
mbedtls_ssl_dtls_replay_update
mbedtls_ssl_fetch_input
mbedtls_ssl_flight_transmit
mbedtls_ssl_flush_output
mbedtls_ssl_free
mbedtls_ssl_get_alpn_protocol
mbedtls_ssl_get_bytes_avail
mbedtls_ssl_get_ciphersuite
mbedtls_ssl_get_ciphersuite_id
mbedtls_ssl_get_ciphersuite_name
mbedtls_ssl_get_ciphersuite_sig_alg
mbedtls_ssl_get_ciphersuite_sig_pk_alg
mbedtls_ssl_get_key_exchange_md_ssl_tls
mbedtls_ssl_get_key_exchange_md_tls1_2
mbedtls_ssl_get_max_frag_len
mbedtls_ssl_get_max_out_record_payload
mbedtls_ssl_get_peer_cert
mbedtls_ssl_get_record_expansion
mbedtls_ssl_get_session
mbedtls_ssl_get_verify_result
mbedtls_ssl_get_version
mbedtls_ssl_handle_message_type
mbedtls_ssl_handshake
mbedtls_ssl_handshake_client_step
mbedtls_ssl_handshake_free
mbedtls_ssl_handshake_server_step
mbedtls_ssl_handshake_step
mbedtls_ssl_handshake_wrapup
mbedtls_ssl_hash_from_md_alg
mbedtls_ssl_init
mbedtls_ssl_list_ciphersuites
mbedtls_ssl_md_alg_from_hash
mbedtls_ssl_optimize_checksum
mbedtls_ssl_parse_certificate
mbedtls_ssl_parse_change_cipher_spec
mbedtls_ssl_parse_finished
mbedtls_ssl_pk_alg_from_sig
mbedtls_ssl_prepare_handshake_record
mbedtls_ssl_psk_derive_premaster
mbedtls_ssl_read
mbedtls_ssl_read_record
mbedtls_ssl_read_version
mbedtls_ssl_recv_flight_completed
mbedtls_ssl_renegotiate
mbedtls_ssl_resend
mbedtls_ssl_reset_checksum
mbedtls_ssl_send_alert_message
mbedtls_ssl_send_fatal_handshake_failure
mbedtls_ssl_send_flight_completed
mbedtls_ssl_session_free
mbedtls_ssl_session_init
mbedtls_ssl_session_reset
mbedtls_ssl_set_bio
mbedtls_ssl_set_calc_verify_md
mbedtls_ssl_set_client_transport_id
mbedtls_ssl_set_datagram_packing
mbedtls_ssl_set_hostname
mbedtls_ssl_set_hs_authmode
mbedtls_ssl_set_hs_ca_chain
mbedtls_ssl_set_hs_own_cert
mbedtls_ssl_set_hs_psk
mbedtls_ssl_set_mtu
mbedtls_ssl_set_session
mbedtls_ssl_set_timer_cb
mbedtls_ssl_setup
mbedtls_ssl_sig_from_pk
mbedtls_ssl_sig_from_pk_alg
mbedtls_ssl_sig_hash_set_add
mbedtls_ssl_sig_hash_set_const_hash
mbedtls_ssl_sig_hash_set_find
mbedtls_ssl_ticket_free
mbedtls_ssl_ticket_init
mbedtls_ssl_ticket_parse
mbedtls_ssl_ticket_setup
mbedtls_ssl_ticket_write
mbedtls_ssl_transform_free
mbedtls_ssl_update_handshake_status
mbedtls_ssl_write
mbedtls_ssl_write_certificate
mbedtls_ssl_write_change_cipher_spec
mbedtls_ssl_write_finished
mbedtls_ssl_write_handshake_msg
mbedtls_ssl_write_record
mbedtls_ssl_write_version
mbedtls_strerror
mbedtls_sysfn_14_poll
mbedtls_sysfn_18_4_poll
mbedtls_sysfn_26_9_poll
mbedtls_sysfn_37_0_poll
mbedtls_sysfn_3_poll
mbedtls_sysfn_66_3_poll
mbedtls_sysfn_68_0_poll
mbedtls_version_check_feature
mbedtls_version_get_number
mbedtls_version_get_string
mbedtls_version_get_string_full
mbedtls_x509_crl_free
mbedtls_x509_crl_info
mbedtls_x509_crl_init
mbedtls_x509_crl_parse
mbedtls_x509_crl_parse_der
mbedtls_x509_crt_check_extended_key_usage
mbedtls_x509_crt_check_key_usage
mbedtls_x509_crt_free
mbedtls_x509_crt_info
mbedtls_x509_crt_init
mbedtls_x509_crt_is_revoked
mbedtls_x509_crt_parse
mbedtls_x509_crt_parse_der
mbedtls_x509_crt_verify
mbedtls_x509_crt_verify_info
mbedtls_x509_crt_verify_restartable
mbedtls_x509_crt_verify_with_profile
mbedtls_x509_csr_free
mbedtls_x509_csr_info
mbedtls_x509_csr_init
mbedtls_x509_csr_parse
mbedtls_x509_csr_parse_der
mbedtls_x509_dn_gets
mbedtls_x509_get_alg
mbedtls_x509_get_alg_null
mbedtls_x509_get_ext
mbedtls_x509_get_name
mbedtls_x509_get_rsassa_pss_params
mbedtls_x509_get_serial
mbedtls_x509_get_sig
mbedtls_x509_get_sig_alg
mbedtls_x509_get_time
mbedtls_x509_key_size_helper
mbedtls_x509_self_test
mbedtls_x509_serial_gets
mbedtls_x509_set_extension
mbedtls_x509_sig_alg_gets
mbedtls_x509_string_to_names
mbedtls_x509_time_is_future
mbedtls_x509_time_is_past
mbedtls_x509write_crt_der
mbedtls_x509write_crt_free
mbedtls_x509write_crt_init
mbedtls_x509write_crt_pem
mbedtls_x509write_crt_set_authority_key_identifier
mbedtls_x509write_crt_set_basic_constraints
mbedtls_x509write_crt_set_extension
mbedtls_x509write_crt_set_issuer_key
mbedtls_x509write_crt_set_issuer_name
mbedtls_x509write_crt_set_key_usage
mbedtls_x509write_crt_set_md_alg
mbedtls_x509write_crt_set_ns_cert_type
mbedtls_x509write_crt_set_serial
mbedtls_x509write_crt_set_subject_key
mbedtls_x509write_crt_set_subject_key_identifier
mbedtls_x509write_crt_set_subject_name
mbedtls_x509write_crt_set_validity
mbedtls_x509write_crt_set_version
mbedtls_x509write_csr_der
mbedtls_x509write_csr_free
mbedtls_x509write_csr_init
mbedtls_x509write_csr_pem
mbedtls_x509write_csr_set_extension
mbedtls_x509write_csr_set_key
mbedtls_x509write_csr_set_key_usage
mbedtls_x509write_csr_set_md_alg
mbedtls_x509write_csr_set_ns_cert_type
mbedtls_x509write_csr_set_subject_name
mbedtls_x509_write_extensions
mbedtls_x509_write_names
mbedtls_x509_write_sig
mbedtls_xtea_crypt_cbc
mbedtls_xtea_crypt_ecb
mbedtls_xtea_free
mbedtls_xtea_init
mbedtls_xtea_self_test
mbedtls_xtea_setup
mbedtls_test_cas_pem
mbedtls_test_cas_pem_len

View File

@ -0,0 +1,7 @@
LIBRARY network.obj
EXPORTS
inet_addr
inet_ntoa
getaddrinfo
freeaddrinfo

View File

@ -0,0 +1,18 @@
//
// This sample show that KX extension supported or not
#include <stdio.h>
int main(){
char* kx_ext =
#ifndef __KX__
"not "
#endif
"supported"
;
printf("KX extension %s", kx_ext);
return 0;
}

View File

@ -0,0 +1,3 @@
#SHS
../../../tcc ../src/tests/kxtest.c -o kxtest -I../../include -llibc
exit

View File

@ -113,12 +113,17 @@ static void tcc_set_lib_path_w32(TCCState *s)
{
char path[1024], *p;
GetModuleFileNameA(tcc_module, path, sizeof path);
#ifdef TCC_TARGET_KX
kx_fix_root_directory(path, sizeof path);
normalize_slashes(strlwr(path));
#else
p = tcc_basename(normalize_slashes(strlwr(path)));
if (p - 5 > path && 0 == strncmp(p - 5, "/bin/", 5))
p -= 5;
else if (p > path)
p--;
*p = 0;
#endif
tcc_set_lib_path(s, path);
}
@ -154,9 +159,13 @@ static void tcc_set_lib_path_kos(TCCState *s)
char** argv0 = (char**)0x20; // path in kolibri header
char path[1024], *p;
strncpy(path, *argv0, sizeof path);
#ifdef TCC_TARGET_KX
kx_fix_root_directory(path, sizeof path);
#else
p = tcc_basename(path);
if (p > path) p--;
*p = 0;
#endif
tcc_set_lib_path(s, path);
}
@ -165,7 +174,12 @@ static void tcc_set_lib_path_linux(TCCState *s)
{
char buff[4096+1];
readlink("/proc/self/exe", buff, 4096);
#ifdef TCC_TARGET_KX
kx_fix_root_directory(buff, sizeof buff);
const char *path = buff;
#else
const char *path = dirname(buff);
#endif
tcc_set_lib_path(s, path);
}

View File

@ -47,6 +47,7 @@
#ifndef TCC_TARGET_MEOS
#define TCC_TARGET_MEOS
#endif
void kx_fix_root_directory(char *buf, size_t size);
#endif
#ifndef _WIN32

View File

@ -34,7 +34,7 @@ typedef struct {
/*union ImportEntry {
uint32_t ImportStr;
uint32_t ImportPrt;
};*/
};*/
//static char __kx_import_table_sym[] = "__i_ptr__";
@ -43,19 +43,21 @@ typedef struct {
ElfW(Sym) *sym;
int sym_index, sym_end;
sym_end = symtab_section->data_offset / sizeof(ElfW(Sym));
DLLReference **dllref = me->s1->loaded_dlls;
CString *str_arr, *len_arr, *sym_arr;
char dll_len;
int dll_loaded = me->s1->nb_loaded_dlls;
int nlib = 0;
int i;
if (me->header.version != 2)
return;
str_arr = tcc_malloc(sizeof(CString) * me->s1->nb_loaded_dlls);
str_arr = tcc_malloc(sizeof(CString) * dll_loaded);
len_arr = tcc_malloc(sizeof(CString)* me->s1->nb_loaded_dlls);
len_arr = tcc_malloc(sizeof(CString)* dll_loaded);
sym_arr = tcc_malloc(sizeof(CString)* me->s1->nb_loaded_dlls);
sym_arr = tcc_malloc(sizeof(CString)* dll_loaded);
for (sym_index = 1; sym_index < sym_end; ++sym_index) {
sym = (ElfW(Sym) *)symtab_section->data + sym_index;
@ -66,18 +68,13 @@ typedef struct {
if (dynsym_index == 0) {
//if (strcmp(name, __kx_import_table_sym) != 0) {
tcc_error/*_noabort*/("undefined symbol '%s'", name);
//continue; // FIXME: stop compile!
//}
//continue;
}
// KOS support 32 bit only
Elf32_Sym* dyn_sym = &((ElfW(Sym) *)me->s1->dynsymtab_section->data)[dynsym_index];
DLLReference **dllref = me->s1->loaded_dlls;
char* dll_name;
i = dyn_sym->st_size - 1;
// TCC store dll index in dyn_sym->st_size field
i = dyn_sym->st_size - 1;
if (dllref[i]->level != -1) {
dll_name = dllref[i]->name;
dll_len = strlen(dll_name) + 1;
@ -115,6 +112,46 @@ typedef struct {
return;
}*/
// Fixed BUG#15 (possible access to uninitialized due unused library)
// Exclude unused librarys
if (nlib < dll_loaded) {
i = 0; int j, n = 0;
do {
// Find unused library
if (dllref[i]->level == 0) {
j = i + 1;
while (j < dll_loaded) {
// Find first used library
if (dllref[j]->level == -1) {
// Found, copy i from j
str_arr[i] = str_arr[j];
len_arr[i] = len_arr[j];
sym_arr[i] = sym_arr[j];
// Mark j as unused
dllref[j]->level = 0;
if (++n == nlib)
goto __done;
break;
}
j++;
}
}
i++;
} while (i < dll_loaded);
}
__done:
// Zero terminate of ptr (was BUG#3)
i = 0;
do {
@ -128,7 +165,7 @@ typedef struct {
kx_import_table* imp_sect;
imp_sect = tcc_mallocz(sizeof(kx_import_table));
imp_sect->data = tcc_mallocz(1024); // FIXME!!!
imp_sect->data = tcc_mallocz(4096); // FIXME!!! I increased it to 4Kb, but steel need dynamicaly size
imp_sect->data_size = 0;
//imp_sect->sh_addr = me->header.image_size;// +1;
@ -147,6 +184,7 @@ typedef struct {
// Align pad (check algorithm!)
int align = 4 - (me->header.image_size + imp_sect->data_size) % 4;
align = align < 4 ? align : 0;
imp_data += align;
imp_sect->data_size += align;
@ -246,11 +284,9 @@ typedef struct {
break;
}
if ((sym_index < sym_end) &&
// ... and user attached at last one *.def
// ... and user attached at least one *.def
(me->s1->nb_loaded_dlls))
me->header.version = 2;
//tcc_add_crt(me->s1, "start1.o");
}
long kx_get_header_length(me_info* me) {
@ -278,3 +314,57 @@ typedef struct {
tcc_free(imp);
}
}
#if /*!*/defined(_DEBUG)// && !defined(_WIN32)
#define kx_debug_output printf
#else
#define kx_debug_output(s,p) ((void)0)
#endif
/*
Calling once from tcc_set_lib_path_xxx
This function correct tcc_root if tcc_root/kx is a run directory,
otherwise do trim filename
*/
void kx_fix_root_directory(char *buf, size_t size) {
int defult = 1;
char* tcc_conf = tcc_malloc(strlen(buf)+5);
strcpy(tcc_conf, buf);
char* base = tcc_basename(tcc_conf);
*base = 0;
base = tcc_basename(buf);
strcat(tcc_conf, "tcc.conf");
FILE* f = fopen(tcc_conf,"r");
if (f) {
char line[100];
while (fgets(line, sizeof line, f)){
switch (*line)
case '#':
case '\n':
continue;
if ((strspn(line, "tcc_root") == 8) && line[8] == ' ') {
if (strcmp(line + 9, "kx") == 0) {
strcpy(base, line + 9);
defult = 0;
}
else
{
// Disallow change tcc_root with arbitrary path
continue;
}
}
}
fclose(f);
}
if (defult) {
*--base = 0;
}
tcc_free(tcc_conf);
//kx_debug_output("tcc root = %s\n", buf);
}

View File

@ -0,0 +1,5 @@
# This configuration file for TCC behaviour
# (actually was added for on/off KX extension)
# Change %ktcc_root%\ to %ktcc_root%\kx
tcc_root kx