if (output_bfd != NULL)
return bfd_reloc_continue;
- relocation = symbol->value + symbol->section->output_section->vma
- + symbol->section->output_offset + reloc_entry->addend;
+ relocation = (symbol->value + symbol->section->output_section->vma
+ + symbol->section->output_offset + reloc_entry->addend);
- bfd_size_type octets = reloc_entry->address
- * bfd_octets_per_byte (abfd, input_section);
+ bfd_size_type octets = (reloc_entry->address
+ * bfd_octets_per_byte (abfd, input_section));
if (!bfd_reloc_offset_in_range (reloc_entry->howto, abfd,
input_section, octets))
return bfd_reloc_outofrange;
break;
}
- bfd_vma mask = (1 << (7 * len)) - 1;
- relocation = relocation & mask;
+ if (7 * len < sizeof (bfd_vma))
+ {
+ bfd_vma mask = ((bfd_vma) 1 << (7 * len)) - 1;
+ relocation = relocation & mask;
+ }
loongarch_write_unsigned_leb128 (p, len, relocation);
return bfd_reloc_ok;
}