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] avr: Fix bugs in org/align tracking.


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

commit 431ff0756ac64c33f6cfbfa8f1cc21c739b7e601
Author: Andrew Burgess <andrew.burgess@embecosm.com>
Date:   Wed Oct 7 20:47:38 2015 +0100

    avr: Fix bugs in org/align tracking.
    
    This commit fixes a few issues in the mechanism for passing information
    about ".org" and ".align" directives from the assembler to the linker,
    used by the avr target.
    
    In the original commit fdd410ac7a07dfb47dcb992201000582a280d8b2, there
    were some mistakes when writing out information about ".align"
    directives:
      - An align with fill does not write out its information correctly, the
        fill data overwrites the alignment data.
      - Each alignment directive is recorded at the location where the
        previous alignment directive should be recorded, the first alignment
        directive is discarded.
    
    In commit 137c83d69fad77677cc818593f9399caa777a0c5, the data produced by
    objdump is not correct:
       - It's miss-aligned due to a missing whitespace.
       - The fill data for align with fill records is not displayed
         correctly.
    
    All of the above issues are addressed in this commit, and the test is
    improved to cover these cases.
    
    binutils/ChangeLog:
    
    	* od-elf32_avr.c (elf32_avr_dump_avr_prop): Fix printing of align
    	specific data, fix formatting for align and org data.
    
    gas/ChangeLog:
    
    	* config/tc-avr.c (avr_output_property_record): Fix overwrite bug
    	for align and fill records.
    	(avr_handle_align): Record fill information for align frags.
    	(create_record_for_frag): Add next frag assertion, use correct
    	address for align records.
    
    gas/testsuite/ChangeLog:
    
    	* gas/avr/avr-prop-1.s: Use fill in some cases.
    	* gas/avr/avr-prop-1.d: Update expected results.

Diff:
---
 binutils/ChangeLog                 |  5 +++++
 binutils/od-elf32_avr.c            |  6 +++---
 gas/ChangeLog                      |  8 ++++++++
 gas/config/tc-avr.c                | 10 +++++++---
 gas/testsuite/ChangeLog            |  5 +++++
 gas/testsuite/gas/avr/avr-prop-1.d | 19 +++++++++++--------
 gas/testsuite/gas/avr/avr-prop-1.s |  4 ++--
 7 files changed, 41 insertions(+), 16 deletions(-)

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index e40926b..ce3ac62 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,8 @@
+2015-10-12  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+	* od-elf32_avr.c (elf32_avr_dump_avr_prop): Fix printing of align
+	specific data, fix formatting for align and org data.
+
 2015-09-01  Claudiu Zissulescu  <claziss@synopsys.com>
 	    Cupertino Miranda  <cmiranda@synopsys.com>
 
diff --git a/binutils/od-elf32_avr.c b/binutils/od-elf32_avr.c
index 5635964..1abbc1f 100644
--- a/binutils/od-elf32_avr.c
+++ b/binutils/od-elf32_avr.c
@@ -271,13 +271,13 @@ elf32_avr_dump_avr_prop (bfd *abfd)
                   r_list->records [i].data.org.fill);
           break;
         case RECORD_ALIGN:
-          printf ("    Align: %#08lx\n",
+          printf ("     Align: %#08lx\n",
                   r_list->records [i].data.align.bytes);
           break;
         case RECORD_ALIGN_AND_FILL:
-          printf ("    Align: %#08lx, Fill: %#08lx\n",
+          printf ("     Align: %#08lx, Fill: %#08lx\n",
                   r_list->records [i].data.align.bytes,
-                  r_list->records [i].data.org.fill);
+                  r_list->records [i].data.align.fill);
           break;
         }
     }
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 90b358b..e81117a 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,11 @@
+2015-10-12  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+	* config/tc-avr.c (avr_output_property_record): Fix overwrite bug
+	for align and fill records.
+	(avr_handle_align): Record fill information for align frags.
+	(create_record_for_frag): Add next frag assertion, use correct
+	address for align records.
+
 2015-10-10  Alan Modra  <amodra@gmail.com>
 
 	PR gas/19113
diff --git a/gas/config/tc-avr.c b/gas/config/tc-avr.c
index 09eea48..252b1a2 100644
--- a/gas/config/tc-avr.c
+++ b/gas/config/tc-avr.c
@@ -1993,7 +1993,7 @@ avr_output_property_record (char * const frag_base, char *frag_ptr,
 
     case RECORD_ALIGN_AND_FILL:
       md_number_to_chars (frag_ptr, record->data.align.bytes, 4);
-      md_number_to_chars (frag_ptr, record->data.align.fill, 4);
+      md_number_to_chars (frag_ptr + 4, record->data.align.fill, 4);
       frag_ptr += 8;
       break;
 
@@ -2038,11 +2038,14 @@ avr_handle_align (fragS *fragP)
          alignment mechanism.  */
       if ((fragP->fr_type == rs_align
            || fragP->fr_type == rs_align_code)
-          && fragP->fr_address > 0
           && fragP->fr_offset > 0)
         {
+          char *p = fragP->fr_literal + fragP->fr_fix;
+
           fragP->tc_frag_data.is_align = TRUE;
           fragP->tc_frag_data.alignment = fragP->fr_offset;
+          fragP->tc_frag_data.fill = *p;
+          fragP->tc_frag_data.has_fill = (fragP->tc_frag_data.fill != 0);
         }
 
       if (fragP->fr_type == rs_org && fragP->fr_offset > 0)
@@ -2078,6 +2081,7 @@ create_record_for_frag (segT sec, fragS *fragP)
 
   prop_rec_link = xmalloc (sizeof (struct avr_property_record_link));
   memset (prop_rec_link, 0, sizeof (*prop_rec_link));
+  gas_assert (fragP->fr_next != NULL);
 
   if (fragP->tc_frag_data.is_org)
     {
@@ -2094,7 +2098,7 @@ create_record_for_frag (segT sec, fragS *fragP)
     }
   else
     {
-      prop_rec_link->record.offset = fragP->fr_address;
+      prop_rec_link->record.offset = fragP->fr_next->fr_address;
       prop_rec_link->record.section = sec;
 
       gas_assert (fragP->tc_frag_data.is_align);
diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog
index 814d0a6..54bb989 100644
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2015-10-12  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+	* gas/avr/avr-prop-1.s: Use fill in some cases.
+	* gas/avr/avr-prop-1.d: Update expected results.
+
 2015-10-07  Claudiu Zissulescu  <claziss@synopsys.com>
 
 	* gas/arc/adc.s: Update test for ARCv1/ARCv2.
diff --git a/gas/testsuite/gas/avr/avr-prop-1.d b/gas/testsuite/gas/avr/avr-prop-1.d
index b140ae6..9cbbd96 100644
--- a/gas/testsuite/gas/avr/avr-prop-1.d
+++ b/gas/testsuite/gas/avr/avr-prop-1.d
@@ -12,15 +12,18 @@ Contents of `\.avr\.prop' section:
   Flags:   0
 
    0 ORG @ \.text\.1 \+ 0x000020 \(0x000020\)
-   1 ORG @ \.text\.1 \+ 0x000044 \(0x000044\)
+   1 ORG\+FILL @ \.text\.1 \+ 0x000044 \(0x000044\)
+     Fill: 0x000005
    2 ORG @ \.text\.2 \+ 0x000020 \(0x000020\)
-   3 ALIGN @ \.text\.2 \+ 0x000020 \(0x000020\)
-    Align: 0x000004
-   4 ALIGN @ \.text\.2 \+ 0x000030 \(0x000030\)
-    Align: 0x000004
+   3 ALIGN @ \.text\.2 \+ 0x000030 \(0x000030\)
+     Align: 0x000004
+   4 ALIGN\+FILL @ \.text\.2 \+ 0x000040 \(0x000040\)
+     Align: 0x000004, Fill: 0x000003
    5 ORG @ \.text\.2 \+ 0x000200 \(0x000200\)
-   6 ALIGN @ \.text\.2 \+ 0x000200 \(0x000200\)
-    Align: 0x000004
+   6 ALIGN @ \.text\.2 \+ 0x000210 \(0x000210\)
+     Align: 0x000004
    7 ALIGN @ \.text\.3 \+ 0x000100 \(0x000100\)
-    Align: 0x000008
+     Align: 0x000008
+   8 ALIGN @ \.text\.3 \+ 0x000200 \(0x000200\)
+     Align: 0x000008
 
diff --git a/gas/testsuite/gas/avr/avr-prop-1.s b/gas/testsuite/gas/avr/avr-prop-1.s
index 6e50cf1..1949216 100644
--- a/gas/testsuite/gas/avr/avr-prop-1.s
+++ b/gas/testsuite/gas/avr/avr-prop-1.s
@@ -3,7 +3,7 @@
 _start:
         .org 0x20
         nop
-        .org 0x44
+        .org 0x44,5
         nop
 
 
@@ -14,7 +14,7 @@ text2:
         nop
         .align 4
         nop
-        .align 4
+        .align 4,3
         nop
         .org 0x200
         nop


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