aboutsummaryrefslogtreecommitdiff
path: root/bfd/peXXigen.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/peXXigen.c')
-rw-r--r--bfd/peXXigen.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
index 513b593..83bbac5 100644
--- a/bfd/peXXigen.c
+++ b/bfd/peXXigen.c
@@ -933,11 +933,13 @@ _bfd_XXi_swap_scnhdr_out (bfd * abfd, void * in, void * out)
memcpy (scnhdr_ext->s_name, scnhdr_int->s_name, sizeof (scnhdr_int->s_name));
- PUT_SCNHDR_VADDR (abfd,
- ((scnhdr_int->s_vaddr
- - pe_data (abfd)->pe_opthdr.ImageBase)
- & 0xffffffff),
- scnhdr_ext->s_vaddr);
+ ss = scnhdr_int->s_vaddr - pe_data (abfd)->pe_opthdr.ImageBase;
+ if (scnhdr_int->s_vaddr < pe_data (abfd)->pe_opthdr.ImageBase)
+ _bfd_error_handler ("%pB:%.8s: section below image base",
+ abfd, scnhdr_int->s_name);
+ else if(ss != (ss & 0xffffffff))
+ _bfd_error_handler ("%pB:%.8s: RVA truncated", abfd, scnhdr_int->s_name);
+ PUT_SCNHDR_VADDR (abfd, ss & 0xffffffff, scnhdr_ext->s_vaddr);
/* NT wants the size data to be rounded up to the next
NT_FILE_ALIGNMENT, but zero if it has no content (as in .bss,