Bug 20254 - [avr] Relocations at end of a section are not processed in the presence of alignment directives
Summary: [avr] Relocations at end of a section are not processed in the presence of al...
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.27
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-14 09:49 UTC by Senthil Kumar Selvaraj
Modified: 2016-10-11 10:02 UTC (History)
1 user (show)

See Also:
Host:
Target: avr
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Senthil Kumar Selvaraj 2016-06-14 09:49:54 UTC
This fails on binutils-2_26 branch. The fix to PR 20221 does not fix this.

$ cat test.s
.text
.global _start, dest
_start: 
  jmp dest
  .align	1
dest:
  nop
  rjmp dest


With 

$ avr-gcc -mmcu=atmega1280 -Os -mrelax test.s -nostartfiles
$ avr-objdump -S a.out

00000000 <__ctors_end>:
   0:	00 c0       	rjmp	.+0      	; 0x2 <dest>

00000002 <dest>:
   2:	00 00       	nop
   4:	00 c0       	rjmp	.+0      	; 0x6 <_etext>


The rjmp at address 4 jumps to 0x6, instead of 0x2 (which is where dest is).
Comment 1 Sourceware Commits 2016-06-15 07:20:04 UTC
The master branch has been updated by Senthil Kumar Selvaraj <saaadhu@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=31eef93e717c59975b3e6f37619ab956302ca37a

commit 31eef93e717c59975b3e6f37619ab956302ca37a
Author: Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
Date:   Wed Jun 15 12:25:30 2016 +0530

    Fix PR ld/20254
    
    This patch fixes another edge case related to alignment property
    records - reloc offsets adjacent to property record offsets were not
    getting adjusted during relaxation.
    
    bfd/
    
    	PR ld/20254
    	* elf32-avr.c (elf32_avr_relax_delete_bytes): Adjust reloc
    	offsets until reloc_toaddr.
    
    ld/
    
    	PR ld/20254
    	* testsuite/ld-avr/avr-prop-6.d: New test.
    	* testsuite/ld-avr/avr-prop-6.s: New test.
Comment 2 Sourceware Commits 2016-06-15 07:29:40 UTC
The binutils-2_26-branch branch has been updated by Senthil Kumar Selvaraj <saaadhu@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=30d923a46a5b6536a2a670be3b4c8209745b308d

commit 30d923a46a5b6536a2a670be3b4c8209745b308d
Author: Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
Date:   Wed Jun 15 12:25:30 2016 +0530

    Fix PR ld/20254
    
    This patch fixes another edge case related to alignment property
    records - reloc offsets adjacent to property record offsets were not
    getting adjusted during relaxation.
    
    bfd/
    
    	PR ld/20254
    	* elf32-avr.c (elf32_avr_relax_delete_bytes): Adjust reloc
    	offsets until reloc_toaddr.
    
    ld/
    
    	PR ld/20254
    	* testsuite/ld-avr/avr-prop-6.d: New test.
    	* testsuite/ld-avr/avr-prop-6.s: New test.
Comment 3 Senthil Kumar Selvaraj 2016-10-11 10:02:11 UTC
Fixed in trunk and backported to 2.26 a while back.