This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] RISC-V: Print an error when unable to align a section


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9eb7b0acb54e18e7cbca196a8bdb320844a858b3

commit 9eb7b0acb54e18e7cbca196a8bdb320844a858b3
Author: Palmer Dabbelt <palmer@dabbelt.com>
Date:   Fri Jun 16 14:19:55 2017 -0700

    RISC-V: Print an error when unable to align a section
    
    This used to just print "can't relax section: Success", which is a silly
    error message.
    
    bfd/ChangeLog
    
    2017-09-07  Palmer Dabbelt  <palmer@dabbelt.com>
    
            * elfnn-riscv.c (_bfd_riscv_relax_align): Call bfd_set_error and
            print an error message when unable to relax a .align directive.

Diff:
---
 bfd/ChangeLog     |  5 +++++
 bfd/elfnn-riscv.c | 11 +++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 8096040..d89909b 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,10 @@
 2017-09-07  Palmer Dabbelt  <palmer@dabbelt.com>
 
+	* (_bfd_riscv_relax_align): Call bfd_set_error and
+	print an error message when unable to relax a .align directive.
+
+2017-09-07  Palmer Dabbelt  <palmer@dabbelt.com>
+
 	* elfnn-riscv.c (riscv_zero_pcrel_hi_reloc): New function.
 	(riscv_record_pcrel_hi_reloc): Add absolute argument.
 	(riscv_elf_relocate_section): Call riscv_zero_pcrel_hi_reloc for
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index fdb151b..b4d7b9b 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -2986,7 +2986,7 @@ _bfd_riscv_relax_tls_le (bfd *abfd,
 
 static bfd_boolean
 _bfd_riscv_relax_align (bfd *abfd, asection *sec,
-			asection *sym_sec ATTRIBUTE_UNUSED,
+			asection *sym_sec,
 			struct bfd_link_info *link_info ATTRIBUTE_UNUSED,
 			Elf_Internal_Rela *rel,
 			bfd_vma symval,
@@ -3008,7 +3008,14 @@ _bfd_riscv_relax_align (bfd *abfd, asection *sec,
 
   /* Make sure there are enough NOPs to actually achieve the alignment.  */
   if (rel->r_addend < nop_bytes)
-    return FALSE;
+    {
+      (*_bfd_error_handler)
+	(_("%B(%A+0x%lx): %d bytes required for alignment"
+	   "to %d-byte boundary, but only %d present"),
+	   abfd, sym_sec, rel->r_offset, nop_bytes, alignment, rel->r_addend);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
 
   /* Delete the reloc.  */
   rel->r_info = ELFNN_R_INFO (0, R_RISCV_NONE);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]