On Thursday 03 November 2016 06:19 PM, Georg-Johann Lay wrote: > On 03.11.2016 08:58, Pitchumani Sivanupandi wrote: >> 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. > > Currently, "at90usb8" this the only prefix that results in wrap_k = 8, > so without adding knowledge about flash sizes to the compiler, the > change makes not much sense... (but does not do harm either). There are ~40 devices with 8K flash. Current checks are out-dated. > > The right place for flash size info would be avr-mcus.def together > with a new command option to specify the flash size and draw > conclusions from it. When I asked Atmel about a mapping of Device to > flash size, the support told me to check the data sheets -- not really > practical for ~300 devices in avr-mcus.def :-) Atmel *must* have > information about this... I have updated patch to include the flash size as well. Took that info from device headers (it was fed into crt's device information note section also). > > The new option would render -mn-flash superfluous, but we should keep > it for backward compatibility. Ok. > Shouldn't link_pmem_wrap then be removed from link_relax, i.e. from > LINK_RELAX_SPEC? And what happens if relaxation is off? Yes. Removed link_pmem_wrap from link_relax. Disabling relaxation doesn't change -mpmem-wrap-around behavior. Now, wrap around behavior is changed as follows: For 8K flash devices: Device specs adds --pmem-wrap-around=8k linker option if -mno-pmem-wrap-around is NOT enabled. It makes the --pmem-wrap-around=8k linker option default for 8k flash devices. For 16/32/64K flash devices: Spec string 'link_pmem_wrap' added to all 16/32/64k flash devices specs. Other wise no changes i.e. It adds --pmem-wrap-around=16/32/64k option if -mpmem-wrap-around option is enabled. For other devices, no changes in device specs. Reg tested with default and -mrelax options enabled. No issues. If OK, could someone commit please? Regards, Pitchumani gcc/ChangeLog 2016-11-08 Pitchumani Sivanupandi * config/avr/avr-arch.h (avr_mcu_t): Add flash_size member. * config/avr/avr-devices.c(avr_mcu_types): Add flash size info. * config/avr/avr-mcu.def: Likewise. * config/avr/gen-avr-mmcu-specs.c (print_mcu): Remove hard-coded prefix check to find wrap-around value, instead use MCU flash size. For 8k flash devices, update link_pmem_wrap spec string to add --pmem-wrap-around=8k. * config/avr/specs.h: Remove link_pmem_wrap from LINK_RELAX_SPEC and add to linker specs (LINK_SPEC) directly.