mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-11-16 04:24:43 +00:00
Introduce attribute::signed_constant
This introduces a new method, attribute::signed_constant. This should be used wherever DWARF specifies a signed integer constant, or where this is implied by the context. It properly handles sign-extension for DW_FORM_data*. To my surprise, there doesn't seem to be a pre-existing sign-extension function. I've added one to common-utils.h alongside the align functions. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32680
This commit is contained in:
@@ -196,6 +196,16 @@ in_inclusive_range (T value, T low, T high)
|
||||
extern ULONGEST align_up (ULONGEST v, int n);
|
||||
extern ULONGEST align_down (ULONGEST v, int n);
|
||||
|
||||
/* Sign-extend the value V, using N as the number of valid bits. That
|
||||
is, bit N-1 is the sign bit. The higher-order bits (those outside
|
||||
0..N-1) must be zero. */
|
||||
static inline ULONGEST
|
||||
sign_extend (ULONGEST v, int n)
|
||||
{
|
||||
ULONGEST mask = (ULONGEST) 1 << (n - 1);
|
||||
return (v ^ mask) - mask;
|
||||
}
|
||||
|
||||
/* Convert hex digit A to a number, or throw an exception. */
|
||||
extern int fromhex (int a);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user