aboutsummaryrefslogtreecommitdiff
path: root/bfd/vms-alpha.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2019-12-29 12:56:04 +1030
committerAlan Modra <amodra@gmail.com>2019-12-29 21:26:00 +1030
commit401e101e0274d401e90e50cd8280a9ff36006477 (patch)
tree7a797ef98020d2b66871201201e48de5ca38d57d /bfd/vms-alpha.c
parent37d2e9c7b10e298403640fdd38a50fedae8525b2 (diff)
downloadgdb-401e101e0274d401e90e50cd8280a9ff36006477.zip
gdb-401e101e0274d401e90e50cd8280a9ff36006477.tar.gz
gdb-401e101e0274d401e90e50cd8280a9ff36006477.tar.bz2
ubsan: alpha-vms: shift exponent is too large
* vms-alpha.c (_bfd_vms_slurp_egsd): Make base_addr a bfd_vma. Limit alignment power. Correct and simplify alignment expression. (evax_bfd_print_relocation_records): Avoid signed shift left.
Diffstat (limited to 'bfd/vms-alpha.c')
-rw-r--r--bfd/vms-alpha.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c
index 5d2ff52..6a08761 100644
--- a/bfd/vms-alpha.c
+++ b/bfd/vms-alpha.c
@@ -1180,7 +1180,7 @@ _bfd_vms_slurp_egsd (bfd *abfd)
int gsd_type;
unsigned int gsd_size;
unsigned char *vms_rec;
- unsigned long base_addr;
+ bfd_vma base_addr;
vms_debug2 ((2, "EGSD\n"));
@@ -1196,7 +1196,7 @@ _bfd_vms_slurp_egsd (bfd *abfd)
PRIV (recrd.rec_size) -= 8;
/* Calculate base address for each section. */
- base_addr = 0L;
+ base_addr = 0;
while (PRIV (recrd.rec_size) > 4)
{
@@ -1244,7 +1244,7 @@ _bfd_vms_slurp_egsd (bfd *abfd)
else
{
char *name;
- unsigned long align_addr;
+ bfd_vma align_addr;
name = _bfd_vms_save_counted_string (abfd, &egps->namlng,
gsd_size - 4);
@@ -1255,7 +1255,7 @@ _bfd_vms_slurp_egsd (bfd *abfd)
section->filepos = 0;
section->size = bfd_getl32 (egps->alloc);
- section->alignment_power = egps->align;
+ section->alignment_power = egps->align & 31;
vms_section_data (section)->flags = vms_flags;
vms_section_data (section)->no_flags = 0;
@@ -1283,10 +1283,9 @@ _bfd_vms_slurp_egsd (bfd *abfd)
return FALSE;
/* Give a non-overlapping vma to non absolute sections. */
- align_addr = (1 << section->alignment_power);
- if ((base_addr % align_addr) != 0)
- base_addr += (align_addr - (base_addr % align_addr));
- section->vma = (bfd_vma)base_addr;
+ align_addr = (bfd_vma) 1 << section->alignment_power;
+ base_addr = (base_addr + align_addr - 1) & -align_addr;
+ section->vma = base_addr;
base_addr += section->size;
}
@@ -6648,7 +6647,7 @@ evax_bfd_print_relocation_records (FILE *file, const unsigned char *rel,
fprintf (file, _(" bitmap: 0x%08x (count: %u):\n"), val, count);
for (k = 0; k < 32; k++)
- if (val & (1 << k))
+ if (val & (1u << k))
{
if (n == 0)
fputs (" ", file);