binutils-gdb/ld/testsuite/ld-avr
Senthil Kumar Selvaraj 6806377956 Fix PR 13402
Fix incorrect adjustment of diff relocs when relaxing, and thus the
resulting source line to address mismatch.

Fix two issues when adjusting diff relocs to account for
deleted bytes.

1. Don't adjust the difference if the end address is the shrinked
insn's address i.e. use < instead of <=. The relaxation code deletes
count bytes from or after shrinked_insn_address, so the difference
between start_address and end_address should remain unchanged in this
case.

2. Adjust the reloc addend if the difference is to be adjusted and
symval + reloc addend is past the shrinked insn address. This is
because for a typical sym1 - sym2 diff reloc, sym1 is .text +
irel->r_addend, and the addend should be reduced to account for the
shrinked insn.

For example, assume the reloc value is .text + 0x8 with .text = 0, the
diff value in the object file = 0x4, and shrinked_insn_address = 0x4
with count = 0x2. Then the existing code writes 0x2 into the object
file to account for the deleted bytes, as shrinked_insn_address lies
between 0x8 and 0x8 - 0x4 = 0x4, but leaves the addend as is. The next
time the reloc is looked at, the code sees if a shrinked_insn_address
lies between 0x8 and 0x8 - 0x2 = 0x6, instead of 0x6 and 0x4. If there
happens to be one, then the diff value in the object file ends up
getting reduced again.

bfd/

2017-06-27  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>

	PR ld/13402
	* elf32-avr.c (elf32_avr_adjust_diff_reloc_value): Adjust
	reloc addend if necessary. Adjust diff only if
	shrinked_insn_address < end_address.

ld/

2017-06-27  Senthil Kumar Selvaraj  <senthil_kumar.selvaraj@atmel.com>

	PR ld/13402
	* testsuite/ld-avr/pr13402.d: New test.
	* testsuite/ld-avr/pr13402.s: New test.
2017-06-27 14:47:02 +05:30
..
avr-prop-1.d
avr-prop-1.s
avr-prop-2.d
avr-prop-2.s
avr-prop-3.d
avr-prop-3.s
avr-prop-4.d
avr-prop-4.s
avr-prop-5.d
avr-prop-5.s
avr-prop-6.d
avr-prop-6.s
avr-prop-7.d
avr-prop-7.s
avr-prop-8.d
avr-prop-8.s
avr.exp
gc-section-debugline.d
lds-mega.d
lds-mega.s
lds-tiny.d
lds-tiny.s
norelax_diff.d
per-function-debugline.s
pr13402.d
pr13402.s
pr20789.d
pr20789.s
pr21404-1.d
pr21404-1.s
pr21404-2.d
pr21404-2.s
pr21404-3.d
pr21404-3.s
pr21404-4.d
pr21404-4.s
pr21404-5.d
pr21404-5.s
pr21404-6.d
pr21404-6.s
pr21404-7.d
pr21404-7.s
pr21404-8.d
pr21404-8.s
region_overflow.d
region_overflow.s
relax_diff.d
relax-02.d
relax-02.s
relax-03.d
relax-03.s
relax-elf-flags-01.d
relax-elf-flags-02.d
relax-elf-flags-03.d
relax-elf-flags-04.d
relax-elf-flags-05.d
relax-elf-flags-06.d
relax-elf-flags-07.d
relax-elf-flags-08.d
relax-elf-flags-a.s
relax-elf-flags-b.s
relax.s