[Bug ld/13812] Suboptimal default linker script cause "internal error: out of range error"

2013-03-12 Thread senthil.thecoder at gmail dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=13812

Senthil Kumar Selvaraj  changed:

   What|Removed |Added

 CC||senthil.thecoder at gmail
   ||dot com

--- Comment #4 from Senthil Kumar Selvaraj  
2013-03-12 17:53:02 UTC ---
Actually, the linker relaxation code already considers cases where deletion of
the ret in call/ret or jmp/ret might be unsafe - just that it missed this
specific case.

The case being that GCC puts the array containing the addresses of the labels
in a separate section (.rodata). The safe ret deletion logic assumes that only
relocations in the local section (containing the ret) could potentially have
symbols whose values evaluate to the address containing the ret, but that is
not true in this case.

Looping over all sections in the BFD, and repeating the check for each section
fixes the problem (see attached patch).

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/13812] Suboptimal default linker script cause "internal error: out of range error"

2013-03-12 Thread senthil.thecoder at gmail dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=13812

Senthil Kumar Selvaraj  changed:

   What|Removed |Added

 Status|ASSIGNED|NEW

--- Comment #6 from Senthil Kumar Selvaraj  
2013-03-12 17:57:33 UTC ---
Oops - Disregard my previous comments - they were meant for bug #12494

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/13812] Suboptimal default linker script cause "internal error: out of range error"

2013-03-12 Thread senthil.thecoder at gmail dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=13812

Senthil Kumar Selvaraj  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 AssignedTo|unassigned at sourceware|senthil.thecoder at gmail
   |dot org |dot com

--- Comment #5 from Senthil Kumar Selvaraj  
2013-03-12 17:54:26 UTC ---
Created attachment 6931
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6931
Patch that loops over all sections

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/12494] Relaxation leads to wrong code optimization (computed goto)

2013-03-12 Thread senthil.thecoder at gmail dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=12494

Senthil Kumar Selvaraj  changed:

   What|Removed |Added

 AssignedTo|unassigned at sources dot   |senthil.thecoder at gmail
   |redhat.com  |dot com

--- Comment #10 from Senthil Kumar Selvaraj  
2013-03-12 18:03:45 UTC ---
Created attachment 6932
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6932
Patch that loops over all sections

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/12494] Relaxation leads to wrong code optimization (computed goto)

2013-03-12 Thread senthil.thecoder at gmail dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=12494

Senthil Kumar Selvaraj  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
 CC||senthil.thecoder at gmail
   ||dot com

--- Comment #9 from Senthil Kumar Selvaraj  
2013-03-12 18:02:51 UTC ---
Actually, the linker relaxation code already considers cases where deletion of
the ret in call/ret or jmp/ret might be unsafe - just that it missed this
specific case.

The case being that GCC puts the array containing the addresses of the labels
in a separate section (.rodata). The safe ret deletion logic assumes that only
relocations in the local section (containing the ret) could potentially have
symbols whose values evaluate to the address containing the ret, but that is
not true in this case.

Looping over all sections in the BFD, and repeating the check for each section
fixes the problem (see attached patch).

Changelog

2013-03-12  Senthil Kumar Selvaraj  

* bfd/elf32-avr.c: Consider all sections to determine if linker
  relaxation can safely delete a ret after a call/jmp

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gas/15281] New: [avr] DWARF CIE DW_CFA_def_cfa offset incorrect for xmega devices with >128 KB flash

2013-03-15 Thread senthil.thecoder at gmail dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=15281



 Bug #: 15281

   Summary: [avr] DWARF CIE DW_CFA_def_cfa offset incorrect for

xmega devices with >128 KB flash

   Product: binutils

   Version: 2.24 (HEAD)

Status: NEW

  Severity: normal

  Priority: P2

 Component: gas

AssignedTo: unassig...@sourceware.org

ReportedBy: senthil.theco...@gmail.com

Classification: Unclassified





The cfa offset definition in the DWARF CIE for xmegas with flash greater th
an

128 KB is 2, instead of 3. For devices with > 128 KB flash, 3 bytes are pus
hed

on the stack as the return address, and hence the value of SP at the call s
ite

(CFA) will be at an offset of 3.



This works correctly for megas with flash >128 KB, as shown below (note the

value of ofs for DW_CFA_def_cfa



➜  scratch  cat test.c

int main()

{

return 0;

}



➜  scratch  ~/avr/install/bin/avr-gcc -mmcu=atxmega192a3 -c -g3 t
est.c

➜  scratch  ~/avr/install/bin/avr-objdump -Wf test.o 
 



test.o: file format elf32-avr



Contents of the .debug_frame section:



 0010  CIE

  Version:   1

  Augmentation:  ""

  Code alignment factor: 2

  Data alignment factor: -1

  Return address column: 36



  DW_CFA_def_cfa: r32 ofs 2

  DW_CFA_offset: r36 at cfa-1

  DW_CFA_nop

  DW_CFA_nop

...



➜  scratch  ~/avr/install/bin/avr-gcc -mmcu=atmega2560 -c -g3 tes
t.c 

➜  scratch  ~/avr/install/bin/avr-objdump -Wf test.o 
   



test.o: file format elf32-avr



Contents of the .debug_frame section:



 0010  CIE

  Version:   1

  Augmentation:  ""

  Code alignment factor: 2

  Data alignment factor: -1

  Return address column: 36



  DW_CFA_def_cfa: r32 ofs 3

  DW_CFA_offset: r36 at cfa-2

  DW_CFA_nop

  DW_CFA_nop



-- 

Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email

--- You are receiving this mail because: ---

You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gas/15281] [avr] DWARF CIE DW_CFA_def_cfa offset incorrect for xmega devices with >128 KB flash

2013-03-15 Thread senthil.thecoder at gmail dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=15281

Senthil Kumar Selvaraj  changed:

   What|Removed |Added

 Target||avr
   Host||linux x86_64

--- Comment #1 from Senthil Kumar Selvaraj  
2013-03-15 13:34:42 UTC ---
The root cause is that tc_cfi_frame_initial_instructions assumes only devices
under bfd_mach_avr6 push 3 bytes on the stack as the return address for a
function call. bfd_mach_avrxmega6 and bfd_mach_avrxmega7 also have > 128 KB
flash and therefore push 3 bytes too.

Attaching patch that fixes the problem.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gas/15281] [avr] DWARF CIE DW_CFA_def_cfa offset incorrect for xmega devices with >128 KB flash

2013-03-15 Thread senthil.thecoder at gmail dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=15281

--- Comment #2 from Senthil Kumar Selvaraj  
2013-03-15 13:35:55 UTC ---
Created attachment 6935
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6935
Fix for dwarf cie cfa offset for xmega6 and xmega7

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- You are receiving this mail because: ---
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/20221] New: [avr] Wrong code generated with linker relaxation for source with alignment directives

2016-06-08 Thread senthil.thecoder at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=20221

Bug ID: 20221
   Summary: [avr] Wrong code generated with linker relaxation for
source with alignment directives
   Product: binutils
   Version: 2.27 (HEAD)
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: ld
  Assignee: unassigned at sourceware dot org
  Reporter: senthil.thecoder at gmail dot com
  Target Milestone: ---

$ cat avr-prop-5.s
.text
.global _start, dest
_start:
CALLdest
.align  1
dest:
NOP

when assembled with -mlink-relax and linked with --relax

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


a.out: file format elf32-avr


Disassembly of section .text:

 <__ctors_end>:
   0:   ff df   rcall   .-2 ; 0x0 <__ctors_end>

0002 :
...

Note that the rcall offset is wrong - it's calling 0x0 rather than calling dest
(0x2). Disabling relaxation results in correct code

$ avr-gcc -mno-relax -mmcu=atmega1280 -Os avr-prop-5.s -nostartfiles
$ avr-objdump -S a.out

a.out: file format elf32-avr


Disassembly of section .text:

 <__ctors_end>:
   0:   0e 94 02 00 call0x4 ; 0x4 

0004 :
...

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/20221] [avr] Wrong code generated with linker relaxation for source with alignment directives

2016-06-10 Thread senthil.thecoder at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=20221

--- Comment #2 from Senthil Kumar Selvaraj  
---
There's another related testcase that fails even with or without the current
fix in master. It fails on binutils-2_26 branch too.

.text
.global _start, dest
_start: 
  jmp dest
  .align1
dest:
  nop
  rjmp dest


With 

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

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

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

which is obviously wrong.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/20254] New: [avr] Relocations at end of a section are not processed in the presence of alignment directives

2016-06-14 Thread senthil.thecoder at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=20254

Bug ID: 20254
   Summary: [avr] Relocations at end of a section are not
processed in the presence of alignment directives
   Product: binutils
   Version: 2.27 (HEAD)
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: ld
  Assignee: unassigned at sourceware dot org
  Reporter: senthil.thecoder at gmail dot com
  Target Milestone: ---

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
  .align1
dest:
  nop
  rjmp dest


With 

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

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

0002 :
   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).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/20254] [avr] Relocations at end of a section are not processed in the presence of alignment directives

2016-06-14 Thread senthil.thecoder at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=20254

Senthil Kumar Selvaraj  changed:

   What|Removed |Added

 Target||avr

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/20221] [avr] Wrong code generated with linker relaxation for source with alignment directives

2016-06-15 Thread senthil.thecoder at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=20221

Senthil Kumar Selvaraj  changed:

   What|Removed |Added

 Target||avr

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils