00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include <stdlib.h>
00039 #include <stdio.h>
00040 #include <strings.h>
00041 #include <sys/unwindP.h>
00042 #include "unwind_producer.h"
00043
00044
00045
00046
00047 __unw_error_t unwind_info_add_prologue_rnat_when_info(__unw_info_t *info,
00048 __uint64_t when) {
00049 __unw_error_t ret = __UNW_OK;
00050 __unw_format_p8_t *desc;
00051 __uint64_t rsize, esize;
00052 char encoded[2+__UNW_ENCODING_SIZE];
00053
00054
00055 if (NULL == info) {
00056 return __UNW_NULL_ERROR;
00057 } else if (_unwind_info + _unwind_info_size != info) {
00058 return __UNW_INV_ARG_ERROR;
00059 }
00060
00061
00062 if (when >= _current_region_total_size) {
00063 return __UNW_INV_SIZE_ERROR;
00064 }
00065
00066
00067
00068
00069
00070 encoded[0] = 0xf0;
00071 encoded[1] = 0x0d;
00072 if ((esize = __leb128_encode((char *)&encoded[2],
00073 (__uint64_t)__UNW_ENCODING_SIZE,
00074 when)) == 0) {
00075 return __UNW_INTERNAL_ERROR;
00076 }
00077
00078 desc = (__unw_format_p8_t *)&encoded;
00079 rsize = 2 + esize;
00080
00081
00082 ret = unwind_info_add_desc(rsize, (char *)desc);
00083
00084 return ret;
00085 }
00086
00087
00088
00089
00090 __unw_error_t unwind_info_add_prologue_rnat_gr_info(__unw_info_t *info, __uint32_t gr) {
00091 __unw_error_t ret = __UNW_OK;
00092 __unw_format_p3_t desc;
00093 __uint64_t rsize;
00094
00095
00096 if (NULL == info) {
00097 return __UNW_NULL_ERROR;
00098 } else if (_unwind_info + _unwind_info_size != info) {
00099 return __UNW_INV_ARG_ERROR;
00100 }
00101
00102
00103
00104
00105
00106 if (gr >= 128) {
00107 return __UNW_INV_ARG_ERROR;
00108 }
00109 desc._fix[0] = 0xb3;
00110 desc._fix[1] = 0x80;
00111 desc._fix[1] |= gr;
00112 rsize = 2;
00113
00114
00115 ret = unwind_info_add_desc(rsize, (char *)&desc);
00116
00117 return ret;
00118 }
00119
00120
00121
00122
00123 __unw_error_t unwind_info_add_prologue_rnat_psprel_info(__unw_info_t *info,
00124 __uint64_t offset) {
00125 __unw_error_t ret = __UNW_OK;
00126 __unw_format_p8_t *desc;
00127 __uint64_t rsize, esize;
00128 char encoded[2+__UNW_ENCODING_SIZE];
00129
00130
00131 if (NULL == info) {
00132 return __UNW_NULL_ERROR;
00133 } else if (_unwind_info + _unwind_info_size != info) {
00134 return __UNW_INV_ARG_ERROR;
00135 }
00136
00137
00138
00139
00140
00141 encoded[0] = 0xf0;
00142 encoded[1] = 0x0e;
00143 if ((esize = __leb128_encode((char *)&encoded[2],
00144 (__uint64_t)__UNW_ENCODING_SIZE,
00145 offset)) == 0) {
00146 return __UNW_INTERNAL_ERROR;
00147 }
00148
00149 desc = (__unw_format_p8_t *)&encoded;
00150 rsize = 2 + esize;
00151
00152
00153 ret = unwind_info_add_desc(rsize, (char *)desc);
00154
00155 return ret;
00156 }
00157
00158
00159
00160
00161 __unw_error_t unwind_info_add_prologue_rnat_sprel_info(__unw_info_t *info,
00162 __uint64_t offset) {
00163 __unw_error_t ret = __UNW_OK;
00164 __unw_format_p8_t *desc;
00165 __uint64_t rsize, esize;
00166 char encoded[2+__UNW_ENCODING_SIZE];
00167
00168
00169 if (NULL == info) {
00170 return __UNW_NULL_ERROR;
00171 } else if (_unwind_info + _unwind_info_size != info) {
00172 return __UNW_INV_ARG_ERROR;
00173 }
00174
00175
00176
00177
00178
00179 encoded[0] = 0xf0;
00180 encoded[1] = 0x0f;
00181 if ((esize = __leb128_encode((char *)&encoded[2],
00182 (__uint64_t)__UNW_ENCODING_SIZE,
00183 offset)) == 0) {
00184 return __UNW_INTERNAL_ERROR;
00185 }
00186
00187 desc = (__unw_format_p8_t *)&encoded;
00188 rsize = 2 + esize;
00189
00190
00191 ret = unwind_info_add_desc(rsize, (char *)desc);
00192
00193 return ret;
00194 }