From 65f124c64b37ab763c224819271bdeecafec3da0 Mon Sep 17 00:00:00 2001 From: Douglas Gilbert Date: Fri, 13 Jan 2017 11:44:29 -0600 Subject: Code clean up to satisfy gcc version 6 --- bfd/bfd-in.h | 2 +- bfd/bfd-in2.h | 31 +++++++++++++++++++++++++++---- bfd/dwarf2.c | 4 ++-- bfd/elf64-ppc.c | 10 ++++++---- bfd/libbfd.c | 2 +- binutils/dwarf.c | 2 +- gas/config/tc-ppc.c | 2 +- gas/read.c | 2 +- gas/write.c | 2 +- include/opcode/ppc.h | 2 +- 10 files changed, 42 insertions(+), 17 deletions(-) diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h index 3afd71b915..398fe74fa7 100644 --- a/bfd/bfd-in.h +++ b/bfd/bfd-in.h @@ -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; diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 3fbe27da71..2addeca529 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -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. */ diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c index c9349da34a..d5ed605077 100644 --- a/bfd/dwarf2.c +++ b/bfd/dwarf2.c @@ -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; } diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index bf13a5da6b..e5ac88485c 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -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; diff --git a/bfd/libbfd.c b/bfd/libbfd.c index 553c729562..28f64d95d8 100644 --- a/bfd/libbfd.c +++ b/bfd/libbfd.c @@ -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; } diff --git a/binutils/dwarf.c b/binutils/dwarf.c index ae50a65fbd..201181e8a5 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -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; } diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c index d5f8f13785..f66c721f7e 100644 --- a/gas/config/tc-ppc.c +++ b/gas/config/tc-ppc.c @@ -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; diff --git a/gas/read.c b/gas/read.c index 082670c445..ac970613ba 100644 --- a/gas/read.c +++ b/gas/read.c @@ -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++; diff --git a/gas/write.c b/gas/write.c index 745abe66d8..ba776e4d59 100644 --- a/gas/write.c +++ b/gas/write.c @@ -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) diff --git a/include/opcode/ppc.h b/include/opcode/ppc.h index 57d20c96dd..d22f7b060a 100644 --- a/include/opcode/ppc.h +++ b/include/opcode/ppc.h @@ -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. */ -- cgit v1.2.1