mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2024-11-28 18:07:37 +01:00
15df8b804c
for loop-exit. Otherwise, sign-extension may clobber the most recently read 7 bits. (Logical change 1.284)
25 lines
465 B
C
25 lines
465 B
C
#include <libunwind.h>
|
|
|
|
unw_word_t
|
|
_ReadSLEB (unsigned char **dpp)
|
|
{
|
|
unsigned shift = 0;
|
|
unw_word_t byte, result = 0;
|
|
unsigned char *bp = *dpp;
|
|
|
|
while (1)
|
|
{
|
|
byte = *bp++;
|
|
result |= (byte & 0x7f) << shift;
|
|
shift += 7;
|
|
if ((byte & 0x80) == 0)
|
|
break;
|
|
}
|
|
|
|
if (shift < 8 * sizeof (unw_word_t) && (byte & 0x40) != 0)
|
|
/* sign-extend negative value */
|
|
result |= ((unw_word_t) -1) << shift;
|
|
|
|
*dpp = bp;
|
|
return result;
|
|
}
|