diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h index 3afd71b915e7c9d33433d341667540b4f8885f50..398fe74fa74dbdc4e3de4d2f7c281bd98fa40da8 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 3fbe27da7128d6eaffda6a114e63b62fa4d09aca..2addeca52990a75afaeeac0ad100c629b88b99f2 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 c9349da34a55d1897c491ff140b2fda812b8d11c..d5ed6050771cc52a65b6eff3c581313c9b66f16e 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 bf13a5da6b184a1554239a249524bed84d6ea05b..e5ac88485c289d63c0f0047ef75eca16641b3876 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 553c729562acaa497dff6eb67dc3c2b995538ae7..28f64d95d8508002482fa7eb74aad3834071acab 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 ae50a65fbdf026d764d7ca350a74faddeb4dd633..201181e8a5dd70e298e8541fb955afb7b5eb8fac 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 d5f8f13785df402f0eed32cb21de46858c895772..f66c721f7e585bfefd28df9ce5259ad9ecc2f095 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 082670c44509d8db231c345af4320d815db97227..ac970613ba779d3e25770e7b43d91a55a0c5dc5f 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 745abe66d8d844e45d3060d2b99ac3d960a9a291..ba776e4d59988a580ef05fcff8208fbab5e0de1e 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 57d20c96ddcbf9c4d71e441b64d91de8e727a4e9..d22f7b060a9284c848ea0768815b7d49d54870bf 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. */