This is the mail archive of the binutils@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]

[PATCH] gas/avr: Prevent incorrect overflow errors for diff fixups.


The following fixes an issue that can arrise in the assembler where
spurious value too large errors can occur for *_DIFF fixups.  I
noticed this when trying to assembler a large function with debug
information, the .debug_line table could not be assembled.

OK to apply?

Thanks,
Andrew

--
When fixups are converted to a difference type within md_apply_fix, we
previously left the contents of VALP (the value that was initially
computed within write.c:fixup_segment) unchanged.  This is harmless,
except that this value is used within write.c:fixup_segment once we
return from md_apply_fix to perform an overflow check.

In some cases, the value computed in write.c:fixup_segment is so wrong
that an overflow error can be triggered.  These errors are incorrect.

This patch avoids the overflow errors by adjusting the value in
write.c:fixup_segment using the VALP pointer in md_apply_fix.

A test for this issue is included.

gas/ChangeLog:

	* config/tc-avr.c (md_apply_fix): Update the contents of VALP for
	diff fixups.

gas/testsuite/ChangeLog:

	* gas/avr/large-debug-line-table.d: New file.
	* gas/avr/large-debug-line-table.s: New file.
---
 gas/ChangeLog                                  |  5 +++++
 gas/config/tc-avr.c                            |  1 +
 gas/testsuite/ChangeLog                        |  5 +++++
 gas/testsuite/gas/avr/large-debug-line-table.d | 15 +++++++++++++++
 gas/testsuite/gas/avr/large-debug-line-table.s | 16 ++++++++++++++++
 5 files changed, 42 insertions(+)
 create mode 100644 gas/testsuite/gas/avr/large-debug-line-table.d
 create mode 100644 gas/testsuite/gas/avr/large-debug-line-table.s

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 17b1671..474026a 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,8 @@
+2015-01-03  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+	* config/tc-avr.c (md_apply_fix): Update the contents of VALP for
+	diff fixups.
+
 2015-01-01  Alan Modra  <amodra@gmail.com>
 
 	* as.c (parse_args): Just print current year.
diff --git a/gas/config/tc-avr.c b/gas/config/tc-avr.c
index 19326a1..5a0b405 100644
--- a/gas/config/tc-avr.c
+++ b/gas/config/tc-avr.c
@@ -1344,6 +1344,7 @@ md_apply_fix (fixS *fixP, valueT * valP, segT seg)
 
       value = S_GET_VALUE (fixP->fx_addsy) +
           fixP->fx_offset - S_GET_VALUE (fixP->fx_subsy);
+      *valP = value;
 
       fixP->fx_subsy = NULL;
   }
diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog
index 541c329..2d19bc6 100644
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2015-01-03  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+	* gas/avr/large-debug-line-table.d: New file.
+	* gas/avr/large-debug-line-table.s: New file.
+
 2015-01-01  Alan Modra  <amodra@gmail.com>
 
 	Update year range in copyright notice of all files.
diff --git a/gas/testsuite/gas/avr/large-debug-line-table.d b/gas/testsuite/gas/avr/large-debug-line-table.d
new file mode 100644
index 0000000..31ca7ed
--- /dev/null
+++ b/gas/testsuite/gas/avr/large-debug-line-table.d
@@ -0,0 +1,15 @@
+#name: AVR, large .debug_line table
+#as: -mlink-relax -mmcu=avrxmega2
+#objdump: --dwarf=decodedline
+#source: large-debug-line-table.s
+#target: avr-*-*
+
+.*:     file format elf32-avr
+
+Decoded dump of debug contents of section \.debug_line:
+
+CU: large-debug-line-table\.c:
+File name                            Line number    Starting address
+large-debug-line-table\.c                       1                   0
+
+#...
diff --git a/gas/testsuite/gas/avr/large-debug-line-table.s b/gas/testsuite/gas/avr/large-debug-line-table.s
new file mode 100644
index 0000000..8e19ba7
--- /dev/null
+++ b/gas/testsuite/gas/avr/large-debug-line-table.s
@@ -0,0 +1,16 @@
+        .file 1 "large-debug-line-table.c"
+        .text
+        .global _start
+_start:
+        .rept 4000
+        .loc 1 1
+        nop
+	nop
+	nop
+	nop
+	nop
+	nop
+	nop
+	nop
+	nop
+        .endr
-- 
1.9.3


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