aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorDenis Chertykov <chertykov@gmail.com>2015-07-08 21:35:19 +0300
committerDenis Chertykov <chertykov@gmail.com>2015-07-08 21:41:52 +0300
commit328e7bfdde7267f5e4b971bc6dca7b82aef77661 (patch)
tree55de9e4f72b35c5e1bbbec78e50812e47198ae8c /gas
parent7c7f93f6e5ce31223acbe871fe0c7e4daf0d8bbc (diff)
downloadgdb-328e7bfdde7267f5e4b971bc6dca7b82aef77661.zip
gdb-328e7bfdde7267f5e4b971bc6dca7b82aef77661.tar.gz
gdb-328e7bfdde7267f5e4b971bc6dca7b82aef77661.tar.bz2
Define DIFF_EXPR_OK for avr target to allow PC relative difference relocation.
When generating relocation (tc_gen_reloc) 32 bit relocation fixup is changed to new 32 bit PC relative relocation if the fixup has pc-relative flag set. bfd/ChangeLog 2015-07-06 Pitchumani Sivanupandi <pitchumani.s@atmel.com> * elf32-avr.c: Add 32 bit PC relative relocation for AVR target. gas/ChangeLog 2015-07-06 Pitchumani Sivanupandi <pitchumani.s@atmel.com> * config/tc-avr.c (tc_gen_reloc): Change 32 bit relocation to 32 bit PC relative and update offset if the fixup is pc-relative. * config/tc-avr.h (DIFF_EXPR_OK): Define to enable PC relative diff relocs. gas/testsuite/ChangeLog 2015-07-06 Pitchumani Sivanupandi <pitchumani.s@atmel.com> * gas/avr/pc-relative-reloc.d: New test for 32 bit pc relative reloc. * gas/avr/per-function-debugline.s: New test source. include/ChangeLog 2015-07-06 Pitchumani Sivanupandi <pitchumani.s@atmel.com> * elf/avr.h: Add new 32 bit PC relative relocation. ld/testsuite/ChangeLog 2015-07-06 Pitchumani Sivanupandi <pitchumani.s@atmel.com> * ld-avr/gc-section-debugline.d: New test. * ld-avr/per-function-debugline.s: Source for new test.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog7
-rw-r--r--gas/config/tc-avr.c18
-rw-r--r--gas/config/tc-avr.h2
-rw-r--r--gas/testsuite/ChangeLog5
-rw-r--r--gas/testsuite/gas/avr/pc-relative-reloc.d19
-rw-r--r--gas/testsuite/gas/avr/per-function-debugline.s35
6 files changed, 84 insertions, 2 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index f9d4892..4439de5 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,10 @@
+2015-07-08 Pitchumani Sivanupandi <pitchumani.s@atmel.com>
+
+ * config/tc-avr.c (tc_gen_reloc): Change 32 bit relocation to
+ 32 bit PC relative and update offset if the fixup is pc-relative.
+ * config/tc-avr.h (DIFF_EXPR_OK): Define to enable PC relative diff
+ relocs.
+
2015-07-03 Alan Modra <amodra@gmail.com>
* config/tc-ppc.c (md_show_usage): Add -m821, -m850, -m860.
diff --git a/gas/config/tc-avr.c b/gas/config/tc-avr.c
index 5c8982c..c69a91c 100644
--- a/gas/config/tc-avr.c
+++ b/gas/config/tc-avr.c
@@ -1618,6 +1618,7 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED,
fixS *fixp)
{
arelent *reloc;
+ bfd_reloc_code_real_type code = fixp->fx_r_type;
if (fixp->fx_subsy != NULL)
{
@@ -1631,7 +1632,21 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED,
*reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
- reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type);
+
+ if ((fixp->fx_r_type == BFD_RELOC_32) && (fixp->fx_pcrel))
+ {
+ if (seg->use_rela_p)
+ fixp->fx_offset -= md_pcrel_from_section (fixp, seg);
+ else
+ fixp->fx_offset = reloc->address;
+
+ code = BFD_RELOC_32_PCREL;
+ }
+
+ reloc->addend = fixp->fx_offset;
+
+ reloc->howto = bfd_reloc_type_lookup (stdoutput, code);
+
if (reloc->howto == (reloc_howto_type *) NULL)
{
as_bad_where (fixp->fx_file, fixp->fx_line,
@@ -1644,7 +1659,6 @@ tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED,
|| fixp->fx_r_type == BFD_RELOC_VTABLE_ENTRY)
reloc->address = fixp->fx_offset;
- reloc->addend = fixp->fx_offset;
return reloc;
}
diff --git a/gas/config/tc-avr.h b/gas/config/tc-avr.h
index 21471c8..5501ef0 100644
--- a/gas/config/tc-avr.h
+++ b/gas/config/tc-avr.h
@@ -45,6 +45,8 @@
nonstandard escape sequences in a string. */
#define ONLY_STANDARD_ESCAPES
+#define DIFF_EXPR_OK /* .-foo gets turned into PC relative relocs */
+
/* GAS will call this function for any expression that can not be
recognized. When the function is called, `input_line_pointer'
will point to the start of the expression. */
diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog
index a045c85..aecbef6 100644
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2015-07-08 Pitchumani Sivanupandi <pitchumani.s@atmel.com>
+
+ * gas/avr/pc-relative-reloc.d: New test for 32 bit pc relative reloc.
+ * gas/avr/per-function-debugline.s: New test source.
+
2015-07-03 Alan Modra <alan@squeak.grove.modra.org>
* gas/ppc/titan.d: Correct mfmcsrr0 disassembly.
diff --git a/gas/testsuite/gas/avr/pc-relative-reloc.d b/gas/testsuite/gas/avr/pc-relative-reloc.d
new file mode 100644
index 0000000..cc22b0b
--- /dev/null
+++ b/gas/testsuite/gas/avr/pc-relative-reloc.d
@@ -0,0 +1,19 @@
+#name: 32 bit PC relative reloc
+#as: -mmcu=avr51 -gdwarf-sections -g
+#objdump: -r
+#source: per-function-debugline.s
+#target: avr-*-*
+
+.*: file format elf32-avr
+
+RELOCATION RECORDS FOR \[.text.main\]:
+#...
+
+
+RELOCATION RECORDS FOR \[.debug_line\]:
+OFFSET TYPE VALUE
+00000000 R_AVR_32_PCREL .debug_line_end-0x00000004
+
+
+RELOCATION RECORDS FOR \[.debug_line.text.main\]:
+#...
diff --git a/gas/testsuite/gas/avr/per-function-debugline.s b/gas/testsuite/gas/avr/per-function-debugline.s
new file mode 100644
index 0000000..4db56e5
--- /dev/null
+++ b/gas/testsuite/gas/avr/per-function-debugline.s
@@ -0,0 +1,35 @@
+ .file "per-function-debugline.s"
+__SP_H__ = 0x3e
+__SP_L__ = 0x3d
+__SREG__ = 0x3f
+__RAMPZ__ = 0x3b
+__tmp_reg__ = 0
+__zero_reg__ = 1
+ .comm g,2,1
+ .section .text.main,"ax",@progbits
+.global main
+ .type main, @function
+main:
+ push r28
+ push r29
+ in r28,__SP_L__
+ in r29,__SP_H__
+/* prologue: function */
+/* frame size = 0 */
+/* stack size = 2 */
+.L__stack_usage = 2
+ call foo
+ lds r24,g
+ lds r25,g+1
+ sbiw r24,1
+ sts g+1,r25
+ sts g,r24
+ lds r24,g
+ lds r25,g+1
+/* epilogue start */
+ pop r29
+ pop r28
+ ret
+ .size main, .-main
+ .ident "GCC: (GNU) 6.0.0 20150630 (experimental)"
+.global __do_clear_bss