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_lc_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] = 0xea;
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_lc_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] = 0xb2;
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_lc_psprel_info(__unw_info_t *info,
00123 __uint64_t offset) {
00124 __unw_error_t ret = __UNW_OK;
00125 __unw_format_p7_t *desc;
00126 __uint64_t rsize, esize;
00127 char encoded[1+__UNW_ENCODING_SIZE];
00128
00129
00130 if (NULL == info) {
00131 return __UNW_NULL_ERROR;
00132 } else if (_unwind_info + _unwind_info_size != info) {
00133 return __UNW_INV_ARG_ERROR;
00134 }
00135
00136
00137
00138
00139
00140 encoded[0] = 0xeb;
00141 if ((esize = __leb128_encode((char *)&encoded[1],
00142 (__uint64_t)__UNW_ENCODING_SIZE,
00143 offset)) == 0) {
00144 return __UNW_INTERNAL_ERROR;
00145 }
00146
00147 desc = (__unw_format_p7_t *)&encoded;
00148 rsize = 1 + esize;
00149
00150
00151 ret = unwind_info_add_desc(rsize, (char *)desc);
00152
00153 return ret;
00154 }
00155
00156
00157
00158
00159 __unw_error_t unwind_info_add_prologue_lc_sprel_info(__unw_info_t *info,
00160 __uint64_t offset) {
00161 __unw_error_t ret = __UNW_OK;
00162 __unw_format_p8_t *desc;
00163 __uint64_t rsize, esize;
00164 char encoded[2+__UNW_ENCODING_SIZE];
00165
00166
00167 if (NULL == info) {
00168 return __UNW_NULL_ERROR;
00169 } else if (_unwind_info + _unwind_info_size != info) {
00170 return __UNW_INV_ARG_ERROR;
00171 }
00172
00173
00174
00175
00176
00177 encoded[0] = 0xf0;
00178 encoded[1] = 0x04;
00179 if ((esize = __leb128_encode((char *)&encoded[2],
00180 (__uint64_t)__UNW_ENCODING_SIZE,
00181 offset)) == 0) {
00182 return __UNW_INTERNAL_ERROR;
00183 }
00184
00185 desc = (__unw_format_p8_t *)&encoded;
00186 rsize = 2 + esize;
00187
00188
00189 ret = unwind_info_add_desc(rsize, (char *)desc);
00190
00191 return ret;
00192 }