mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2024-12-23 20:03:43 +01:00
(Logical change 1.205)
This commit is contained in:
parent
662957d585
commit
36c7442db3
2 changed files with 45 additions and 0 deletions
|
@ -0,0 +1,25 @@
|
||||||
|
#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;
|
||||||
|
if ((byte & 0x80) == 0)
|
||||||
|
break;
|
||||||
|
shift += 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shift < 8 * sizeof (unw_word_t) && (byte & 0x40) != 0)
|
||||||
|
/* sign-extend negative value */
|
||||||
|
result |= ((unw_word_t) -1) << shift;
|
||||||
|
|
||||||
|
*dpp = bp;
|
||||||
|
return result;
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
#include <libunwind.h>
|
||||||
|
|
||||||
|
unw_word_t
|
||||||
|
_ReadULEB (unsigned char **dpp)
|
||||||
|
{
|
||||||
|
unsigned shift = 0;
|
||||||
|
unw_word_t byte, result = 0;
|
||||||
|
unsigned char *bp = *dpp;
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
byte = *bp++;
|
||||||
|
result |= (byte & 0x7f) << shift;
|
||||||
|
if ((byte & 0x80) == 0)
|
||||||
|
break;
|
||||||
|
shift += 7;
|
||||||
|
}
|
||||||
|
*dpp = bp;
|
||||||
|
return result;
|
||||||
|
}
|
Loading…
Reference in a new issue