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_rp_when_info(__unw_info_t *info,
00048 __uint64_t when) {
00049 __unw_error_t ret = __UNW_OK;
00050 __unw_format_p7_t *desc;
00051 __uint64_t rsize, esize;
00052 char encoded[1+__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] = 0xe4;
00071 if ((esize = __leb128_encode((char *)&encoded[1],
00072 (__uint64_t)__UNW_ENCODING_SIZE,
00073 when)) == 0) {
00074 return __UNW_INTERNAL_ERROR;
00075 }
00076
00077 desc = (__unw_format_p7_t *)&encoded;
00078 rsize = 1 + esize;
00079
00080
00081 ret = unwind_info_add_desc(rsize, (char *)desc);
00082
00083 return ret;
00084 }
00085
00086
00087
00088
00089 __unw_error_t unwind_info_add_prologue_rp_gr_info(__unw_info_t *info, __uint32_t gr) {
00090 __unw_error_t ret = __UNW_OK;
00091 __unw_format_p3_t desc;
00092 __uint64_t rsize;
00093
00094
00095 if (NULL == info) {
00096 return __UNW_NULL_ERROR;
00097 } else if (_unwind_info + _unwind_info_size != info) {
00098 return __UNW_INV_ARG_ERROR;
00099 }
00100
00101
00102
00103
00104
00105 if (gr >= 128) {
00106 return __UNW_INV_ARG_ERROR;
00107 }
00108 desc._fix[0] = 0xb0;
00109 desc._fix[1] = 0x80;
00110 desc._fix[1] |= gr;
00111 rsize = 2;
00112
00113
00114 ret = unwind_info_add_desc(rsize, (char *)&desc);
00115
00116 return ret;
00117 }
00118
00119
00120
00121
00122 __unw_error_t unwind_info_add_prologue_rp_br_info(__unw_info_t *info,
00123 __uint32_t br) {
00124 __unw_error_t ret = __UNW_OK;
00125 __unw_format_p3_t desc;
00126 __uint64_t rsize;
00127
00128
00129 if (NULL == info) {
00130 return __UNW_NULL_ERROR;
00131 } else if (_unwind_info + _unwind_info_size != info) {
00132 return __UNW_INV_ARG_ERROR;
00133 }
00134
00135
00136
00137
00138
00139 if (br >= 128) {
00140 return __UNW_INV_ARG_ERROR;
00141 }
00142 desc._fix[0] = 0xb3;
00143 desc._fix[1] = 0x00;
00144 desc._fix[1] |= br;
00145 rsize = 2;
00146
00147
00148 ret = unwind_info_add_desc(rsize, (char *)&desc);
00149
00150 return ret;
00151 }
00152
00153
00154
00155
00156 __unw_error_t unwind_info_add_prologue_rp_psprel_info(__unw_info_t *info,
00157 __uint64_t offset) {
00158 __unw_error_t ret = __UNW_OK;
00159 __unw_format_p7_t *desc;
00160 __uint64_t rsize, esize;
00161 char encoded[1+__UNW_ENCODING_SIZE];
00162
00163
00164 if (NULL == info) {
00165 return __UNW_NULL_ERROR;
00166 } else if (_unwind_info + _unwind_info_size != info) {
00167 return __UNW_INV_ARG_ERROR;
00168 }
00169
00170
00171
00172
00173
00174 encoded[0] = 0xe5;
00175 if ((esize = __leb128_encode((char *)&encoded[1],
00176 (__uint64_t)__UNW_ENCODING_SIZE,
00177 offset)) == 0) {
00178 return __UNW_INTERNAL_ERROR;
00179 }
00180
00181 desc = (__unw_format_p7_t *)&encoded;
00182 rsize = 1 + esize;
00183
00184
00185 ret = unwind_info_add_desc(rsize, (char *)desc);
00186
00187 return ret;
00188 }
00189
00190
00191
00192
00193 __unw_error_t unwind_info_add_prologue_rp_sprel_info(__unw_info_t *info,
00194 __uint64_t offset) {
00195 __unw_error_t ret = __UNW_OK;
00196 __unw_format_p8_t *desc;
00197 __uint64_t rsize, esize;
00198 char encoded[2+__UNW_ENCODING_SIZE];
00199
00200
00201 if (NULL == info) {
00202 return __UNW_NULL_ERROR;
00203 } else if (_unwind_info + _unwind_info_size != info) {
00204 return __UNW_INV_ARG_ERROR;
00205 }
00206
00207
00208
00209
00210
00211 encoded[0] = 0xf0;
00212 encoded[1] = 0x01;
00213 if ((esize = __leb128_encode((char *)&encoded[2],
00214 (__uint64_t)__UNW_ENCODING_SIZE,
00215 offset)) == 0) {
00216 return __UNW_INTERNAL_ERROR;
00217 }
00218
00219 desc = (__unw_format_p8_t *)&encoded;
00220 rsize = 2 + esize;
00221
00222
00223 ret = unwind_info_add_desc(rsize, (char *)desc);
00224
00225 return ret;
00226 }