Commit 394161cb authored by Douglas Gilbert's avatar Douglas Gilbert Committed by Doug Gilbert

Code clean up to satisfy gcc version 6

Backport of 29f628db8 and other issues
parent 5b161fc3
......@@ -272,7 +272,7 @@ alent;
/* Object and core file sections. */
#define align_power(addr, align) \
(((addr) + ((bfd_vma) 1 << (align)) - 1) & ((bfd_vma) -1 << (align)))
(((addr) + ((bfd_vma) 1 << (align)) - 1) & (-((bfd_vma) 1 << (align))))
typedef struct bfd_section *sec_ptr;
......
......@@ -279,7 +279,7 @@ alent;
/* Object and core file sections. */
#define align_power(addr, align) \
(((addr) + ((bfd_vma) 1 << (align)) - 1) & ((bfd_vma) -1 << (align)))
(((addr) + ((bfd_vma) 1 << (align)) - 1) & (-((bfd_vma) 1 << (align))))
typedef struct bfd_section *sec_ptr;
......@@ -299,9 +299,6 @@ typedef struct bfd_section *sec_ptr;
#define bfd_is_com_section(ptr) (((ptr)->flags & SEC_IS_COMMON) != 0)
#define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (ptr)->lma = (val)), ((ptr)->user_set_vma = TRUE), TRUE)
#define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),TRUE)
#define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE)
/* Find the address one past the end of SEC. */
#define bfd_get_section_limit(bfd, sec) \
(((bfd)->direction != write_direction && (sec)->rawsize != 0 \
......@@ -1594,6 +1591,32 @@ struct relax_table {
int size;
};
/* Note: the following are provided as inline functions rather than macros
because not all callers use the return value. A macro implementation
would use a comma expression, eg: "((ptr)->foo = val, TRUE)" and some
compilers will complain about comma expressions that have no effect. */
static inline bfd_boolean
bfd_set_section_userdata (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, void * val)
{
ptr->userdata = val;
return TRUE;
}
static inline bfd_boolean
bfd_set_section_vma (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, bfd_vma val)
{
ptr->vma = ptr->lma = val;
ptr->user_set_vma = TRUE;
return TRUE;
}
static inline bfd_boolean
bfd_set_section_alignment (bfd * abfd ATTRIBUTE_UNUSED, asection * ptr, unsigned int val)
{
ptr->alignment_power = val;
return TRUE;
}
/* These sections are global, and are managed by BFD. The application
and target back end are not permitted to change the values in
these sections. */
......
......@@ -3074,8 +3074,8 @@ place_sections (bfd *abfd, struct dwarf2_debug *stash)
/* Align the new address to the current section
alignment. */
last_vma = ((last_vma
+ ~((bfd_vma) -1 << sect->alignment_power))
& ((bfd_vma) -1 << sect->alignment_power));
+ ~(-((bfd_vma) 1 << sect->alignment_power)))
& (-((bfd_vma) 1 << sect->alignment_power)));
sect->vma = last_vma;
last_vma += sect->vma + sz;
}
......
......@@ -12253,8 +12253,9 @@ ppc64_elf_size_stubs (struct bfd_link_info *info, bfd_signed_vma group_size,
stub_sec != NULL;
stub_sec = stub_sec->next)
if ((stub_sec->flags & SEC_LINKER_CREATED) == 0)
stub_sec->size = ((stub_sec->size + (1 << htab->plt_stub_align) - 1)
& (-1 << htab->plt_stub_align));
stub_sec->size = ((stub_sec->size
+ (1 << htab->plt_stub_align) - 1)
& -(1 << htab->plt_stub_align));
for (stub_sec = htab->stub_bfd->sections;
stub_sec != NULL;
......@@ -12721,8 +12722,9 @@ ppc64_elf_build_stubs (bfd_boolean emit_stub_syms,
stub_sec != NULL;
stub_sec = stub_sec->next)
if ((stub_sec->flags & SEC_LINKER_CREATED) == 0)
stub_sec->size = ((stub_sec->size + (1 << htab->plt_stub_align) - 1)
& (-1 << htab->plt_stub_align));
stub_sec->size = ((stub_sec->size
+ (1 << htab->plt_stub_align) - 1)
& -(1 << htab->plt_stub_align));
for (stub_sec = htab->stub_bfd->sections;
stub_sec != NULL;
......
......@@ -1102,7 +1102,7 @@ read_signed_leb128 (bfd *abfd ATTRIBUTE_UNUSED,
}
while (byte & 0x80);
if (shift < 8 * sizeof (result) && (byte & 0x40))
result |= (((bfd_vma) -1) << shift);
result |= -((bfd_vma) 1 << shift);
*bytes_read_ptr = num_read;
return result;
}
......
......@@ -263,7 +263,7 @@ read_leb128 (unsigned char *data,
*length_return = num_read;
if (sign && (shift < 8 * sizeof (result)) && (byte & 0x40))
result |= -1L << shift;
result |= -1UL << shift;
return result;
}
......
......@@ -1482,7 +1482,7 @@ insn_validate (const struct powerpc_opcode *op)
else
{
const struct powerpc_operand *operand = &powerpc_operands[*o];
if (operand->shift != PPC_OPSHIFT_INV)
if (operand->shift != (int) PPC_OPSHIFT_INV)
{
unsigned long mask;
......
......@@ -5019,7 +5019,7 @@ output_big_sleb128 (char *p, LITTLENUM_TYPE *bignum, int size)
{
/* Sign-extend VAL. */
if (val & (1 << (loaded - 1)))
val |= ~0 << loaded;
val |= -1U << loaded;
if (orig)
*p = val & 0x7f;
p++;
......
......@@ -2292,7 +2292,7 @@ relax_align (register relax_addressT address, /* Address now. */
relax_addressT mask;
relax_addressT new_address;
mask = ~((~0) << alignment);
mask = ~((-1U) << alignment);
new_address = (address + mask) & (~mask);
#ifdef LINKER_RELAXING_SHRINKS_ONLY
if (linkrelax)
......
......@@ -281,7 +281,7 @@ extern const unsigned int num_powerpc_operands;
/* Use with the shift field of a struct powerpc_operand to indicate
that BITM and SHIFT cannot be used to determine where the operand
goes in the insn. */
#define PPC_OPSHIFT_INV (-1 << 31)
#define PPC_OPSHIFT_INV (-1U << 31)
/* Values defined for the flags field of a struct powerpc_operand. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment