Most of the AVR's 8k memorydevices have only rjmp instruction, not jmp.
So, it
is important to wrap around jump destination to check if it can reach
backwards.
Currently link specs passes --pmem-wrap-around=xxK when mrelax and
mpmem-wrap-around options are enabled. Attached patch changes the specs
so that
option --pmem-wrap-around=8K is passed for 8k memory devices if
-mno-pmem-wrap-around is not enabled.
If OK, could someone commit please?
Note: Currently 8k devices are identified based on name prefix. We are
working
on alternative method to incorporate flash memory size.
Regards,
Pitchumani
gcc/ChangeLog
2016-11-03 Pitchumani Sivanupandi <pitchuman...@atmel.com>
* config/avr/gen-avr-mmcu-specs.c (print_mcu): Update
link_pmem_wrap spec
string to add linker option --pmem-wrap-around=8k.
* config/avr/specs.h: Add link_pmem_wrap to linker specs (LINK_SPEC).
diff --git a/gcc/config/avr/gen-avr-mmcu-specs.c b/gcc/config/avr/gen-avr-mmcu-specs.c
index 7fca756..41dbd80 100644
--- a/gcc/config/avr/gen-avr-mmcu-specs.c
+++ b/gcc/config/avr/gen-avr-mmcu-specs.c
@@ -220,7 +220,9 @@ print_mcu (const avr_mcu_t *mcu)
: 0;
fprintf (f, "*link_pmem_wrap:\n");
- if (wrap_k)
+ if (wrap_k == 8)
+ fprintf (f, "\t%%{!mno-pmem-wrap-around: --pmem-wrap-around=8k}");
+ else if (wrap_k > 8)
fprintf (f, "\t%%{mpmem-wrap-around: --pmem-wrap-around=%dk}", wrap_k);
fprintf (f, "\n\n");
diff --git a/gcc/config/avr/specs.h b/gcc/config/avr/specs.h
index 52763cc..fbf0ce6 100644
--- a/gcc/config/avr/specs.h
+++ b/gcc/config/avr/specs.h
@@ -65,6 +65,7 @@ along with GCC; see the file COPYING3. If not see
"%(link_data_start) " \
"%(link_text_start) " \
"%(link_relax) " \
+ "%(link_pmem_wrap) " \
"%{shared:%eshared is not supported} "
#undef LIB_SPEC