51 #ifndef _MEMORY_ACCESS_H 
   52 #define _MEMORY_ACCESS_H 1 
   61 #define get_uleb128_step(var, addr, nth, break)                   \ 
   63     var |= (uintmax_t) (__b & 0x7f) << (nth * 7);                 \ 
   64     if (likely ((__b & 0x80) == 0))                       \ 
   67 #define get_uleb128(var, addr)                            \ 
   71     get_uleb128_step (var, addr, 0, break);                   \ 
   72     var = __libdw_get_uleb128 (var, 1, &(addr));                  \ 
   75 #define get_uleb128_rest_return(var, i, addrp)                    \ 
   79     get_uleb128_step (var, *addrp, i, return var);                \ 
   88 #define get_sleb128_step(var, addr, nth, break)                   \ 
   90     _v |= (uint64_t) (__b & 0x7f) << (nth * 7);                   \ 
   91     if (likely ((__b & 0x80) == 0))                       \ 
   93     var = (_v << (64 - (nth * 7) - 7)) >> (64 - (nth * 7) - 7);       \ 
   98 #define get_sleb128(var, addr)                            \ 
  102     get_sleb128_step (var, addr, 0, break);                   \ 
  103     var = __libdw_get_sleb128 (_v, 1, &(addr));                   \ 
  106 #define get_sleb128_rest_return(var, i, addrp)                    \ 
  110     get_sleb128_step (var, *addrp, i, return var);                \ 
  113     if (likely ((__b & 0x80) == 0))                       \ 
  114       return var | ((uint64_t) __b << 63);                    \ 
  122 extern uint64_t __libdw_get_uleb128 (uint64_t acc, 
unsigned int i,
 
  123                      const unsigned char **
addrp)
 
  124      internal_function attribute_hidden;
 
  125 extern int64_t __libdw_get_sleb128 (int64_t acc, 
unsigned int i,
 
  126                     const unsigned char **
addrp)
 
  127      internal_function attribute_hidden;
 
  129 static inline uint64_t
 
  131 __libdw_get_uleb128 (uint64_t acc, 
unsigned int i, const 
unsigned char **
addrp)
 
  136 static inline int64_t
 
  138 __libdw_get_sleb128 (int64_t acc, 
unsigned int i, const 
unsigned char **
addrp)
 
  151 # define read_2ubyte_unaligned(Dbg, Addr) \ 
  152   (unlikely ((Dbg)->other_byte_order)                         \ 
  153    ? bswap_16 (*((const uint16_t *) (Addr)))                      \ 
  154    : *((const uint16_t *) (Addr))) 
  155 # define read_2sbyte_unaligned(Dbg, Addr) \ 
  156   (unlikely ((Dbg)->other_byte_order)                         \ 
  157    ? (int16_t) bswap_16 (*((const int16_t *) (Addr)))                 \ 
  158    : *((const int16_t *) (Addr))) 
  160 # define read_4ubyte_unaligned_noncvt(Addr) \ 
  161    *((const uint32_t *) (Addr)) 
  162 # define read_4ubyte_unaligned(Dbg, Addr) \ 
  163   (unlikely ((Dbg)->other_byte_order)                         \ 
  164    ? bswap_32 (*((const uint32_t *) (Addr)))                      \ 
  165    : *((const uint32_t *) (Addr))) 
  166 # define read_4sbyte_unaligned(Dbg, Addr) \ 
  167   (unlikely ((Dbg)->other_byte_order)                         \ 
  168    ? (int32_t) bswap_32 (*((const int32_t *) (Addr)))                 \ 
  169    : *((const int32_t *) (Addr))) 
  171 # define read_8ubyte_unaligned(Dbg, Addr) \ 
  172   (unlikely ((Dbg)->other_byte_order)                         \ 
  173    ? bswap_64 (*((const uint64_t *) (Addr)))                      \ 
  174    : *((const uint64_t *) (Addr))) 
  175 # define read_8sbyte_unaligned(Dbg, Addr) \ 
  176   (unlikely ((Dbg)->other_byte_order)                         \ 
  177    ? (int64_t) bswap_64 (*((const int64_t *) (Addr)))                 \ 
  178    : *((const int64_t *) (Addr))) 
  193 # define read_2ubyte_unaligned(obo, Addr) \ 
  194   read_2ubyte_unaligned_1 ((obo), (Addr)) 
  195 # define read_2sbyte_unaligned(obo, Addr) \ 
  196   read_2sbyte_unaligned_1 ((obo), (Addr)) 
  197 # define read_4ubyte_unaligned(obo, Addr) \ 
  198   read_4ubyte_unaligned_1 ((obo), (Addr)) 
  199 # define read_4sbyte_unaligned(obo, Addr) \ 
  200   read_4sbyte_unaligned_1 ((obo), (Addr)) 
  201 # define read_8ubyte_unaligned(obo, Addr) \ 
  202   read_8ubyte_unaligned_1 ((obo), (Addr)) 
  203 # define read_8sbyte_unaligned(obo, Addr) \ 
  204   read_8sbyte_unaligned_1 ((obo), (Addr)) 
  206 static inline uint16_t
 
  207 read_2ubyte_unaligned_1 (
bool other_byte_order, 
const void *
p)
 
  211     return bswap_16 (up->
u2);
 
  214 static inline int16_t
 
  215 read_2sbyte_unaligned_1 (
bool other_byte_order, 
const void *
p)
 
  219     return (int16_t) bswap_16 (up->
u2);
 
  223 static inline uint32_t
 
  224 read_4ubyte_unaligned_noncvt (
const void *p)
 
  229 static inline uint32_t
 
  230 read_4ubyte_unaligned_1 (
bool other_byte_order, 
const void *p)
 
  234     return bswap_32 (up->
u4);
 
  237 static inline int32_t
 
  238 read_4sbyte_unaligned_1 (
bool other_byte_order, 
const void *p)
 
  242     return (int32_t) bswap_32 (up->
u4);
 
  246 static inline uint64_t
 
  247 read_8ubyte_unaligned_1 (
bool other_byte_order, 
const void *p)
 
  251     return bswap_64 (up->
u8);
 
  254 static inline int64_t
 
  255 read_8sbyte_unaligned_1 (
bool other_byte_order, 
const void *p)
 
  259     return (int64_t) bswap_64 (up->
u8);
 
  266 #define read_ubyte_unaligned(Nbytes, obo, Addr) \ 
  267   ((Nbytes) == 2 ? read_2ubyte_unaligned (obo, Addr)                  \ 
  268    : (Nbytes) == 4 ? read_4ubyte_unaligned (obo, Addr)                \ 
  269    : read_8ubyte_unaligned (obo, Addr)) 
  271 #define read_sbyte_unaligned(Nbytes, obo, Addr) \ 
  272   ((Nbytes) == 2 ? read_2sbyte_unaligned (obo, Addr)                  \ 
  273    : (Nbytes) == 4 ? read_4sbyte_unaligned (obo, Addr)                \ 
  274    : read_8sbyte_unaligned (obo, Addr)) 
  277 #define read_2ubyte_unaligned_inc(obo, Addr) \ 
  278   ({ uint16_t t_ = read_2ubyte_unaligned (obo, Addr);                 \ 
  279      Addr = (__typeof (Addr)) (((uintptr_t) (Addr)) + 2);             \ 
  281 #define read_2sbyte_unaligned_inc(obo, Addr) \ 
  282   ({ int16_t t_ = read_2sbyte_unaligned (obo, Addr);                  \ 
  283      Addr = (__typeof (Addr)) (((uintptr_t) (Addr)) + 2);             \ 
  286 #define read_4ubyte_unaligned_inc(obo, Addr) \ 
  287   ({ uint32_t t_ = read_4ubyte_unaligned (obo, Addr);                 \ 
  288      Addr = (__typeof (Addr)) (((uintptr_t) (Addr)) + 4);             \ 
  290 #define read_4sbyte_unaligned_inc(obo, Addr) \ 
  291   ({ int32_t t_ = read_4sbyte_unaligned (obo, Addr);                  \ 
  292      Addr = (__typeof (Addr)) (((uintptr_t) (Addr)) + 4);             \ 
  295 #define read_8ubyte_unaligned_inc(obo, Addr) \ 
  296   ({ uint64_t t_ = read_8ubyte_unaligned (obo, Addr);                 \ 
  297      Addr = (__typeof (Addr)) (((uintptr_t) (Addr)) + 8);             \ 
  299 #define read_8sbyte_unaligned_inc(obo, Addr) \ 
  300   ({ int64_t t_ = read_8sbyte_unaligned (obo, Addr);                  \ 
  301      Addr = (__typeof (Addr)) (((uintptr_t) (Addr)) + 8);             \ 
  305 #define read_ubyte_unaligned_inc(Nbytes, obo, Addr) \ 
  306   ((Nbytes) == 2 ? read_2ubyte_unaligned_inc (obo, Addr)              \ 
  307    : (Nbytes) == 4 ? read_4ubyte_unaligned_inc (obo, Addr)            \ 
  308    : read_8ubyte_unaligned_inc (obo, Addr)) 
  310 #define read_sbyte_unaligned_inc(Nbytes, obo, Addr) \ 
  311   ((Nbytes) == 2 ? read_2sbyte_unaligned_inc (obo, Addr)              \ 
  312    : (Nbytes) == 4 ? read_4sbyte_unaligned_inc (obo, Addr)            \ 
  313    : read_8sbyte_unaligned_inc (obo, Addr)) 
static uint64_t unsigned int const unsigned char ** addrp
 
static uint64_t unsigned int i
 
union unaligned __attribute__((packed))
 
#define get_sleb128_rest_return(var, i, addrp)
 
#define get_uleb128_rest_return(var, i, addrp)