[PATCH] D37615: [AVR] implement the relocation of LDI and other Instructions for LLD

Leslie Zhai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 12 01:46:44 PDT 2017


xiangzhai updated this revision to Diff 114781.
xiangzhai added a comment.

Add `R_AVR_LO8_LDI_GS` and `R_AVR_HI8_LDI_GS` testcase:

  $ avr-readelf -r basic-avr.o 
  
  ...
  00000034  00000118 R_AVR_LO8_LDI_GS  00000000   .text + 26
  00000036  00000119 R_AVR_HI8_LDI_GS  00000000   .text + 26
  ...

relocated by avr-ld:

  $ avr-objdump -d basic-avr   
  
  basic-avr:     file format elf32-avr
  
  
  Disassembly of section .text:
  
  00000000 <__ctors_end>:
     0:   0e 94 13 00     call    0x26    ; 0x26 <foo>
     4:   06 e2           ldi     r16, 0x26       ; 38
     6:   10 e0           ldi     r17, 0x00       ; 0
     8:   20 e0           ldi     r18, 0x00       ; 0
     a:   30 e0           ldi     r19, 0x00       ; 0
     c:   46 e2           ldi     r20, 0x26       ; 38
     e:   5a ed           ldi     r21, 0xDA       ; 218
    10:   6f ef           ldi     r22, 0xFF       ; 255
    12:   7f ef           ldi     r23, 0xFF       ; 255
    14:   8f ef           ldi     r24, 0xFF       ; 255
    16:   93 e1           ldi     r25, 0x13       ; 19
    18:   a0 e0           ldi     r26, 0x00       ; 0
    1a:   b0 e0           ldi     r27, 0x00       ; 0
    1c:   cd ee           ldi     r28, 0xED       ; 237
    1e:   df ef           ldi     r29, 0xFF       ; 255
    20:   ef ef           ldi     r30, 0xFF       ; 255
    22:   09 f4           brne    .+2             ; 0x26 <foo>
    24:   00 c0           rjmp    .+0             ; 0x26 <foo>
  
  00000026 <foo>:
    26:   2a 80           ldd     r2, Y+2 ; 0x02
    28:   08 80           ld      r0, Y
    2a:   94 84           ldd     r9, Z+12        ; 0x0c
    2c:   76 8c           ldd     r7, Z+30        ; 0x1e
    2e:   96 a0           ldd     r9, Z+38        ; 0x26
    30:   00 91 26 00     lds     r16, 0x0026     ; 0x800026 <__EEPROM_REGION_LENGTH__+0x7f0026>
    34:   13 e1           ldi     r17, 0x13       ; 19
    36:   20 e0           ldi     r18, 0x00       ; 0
    38:   47 b5           in      r20, 0x27       ; 39
    3a:   00 9a           sbi     0x00, 0 ; 0
    3c:   b6 96           adiw    r30, 0x26       ; 38

it equals to LLD:

  $ avr-objdump -d basic-avr-lld 
  
  basic-avr-lld:     file format elf32-avr
  
  
  Disassembly of section .text:
  
  00000000 <main>:
     0:   0e 94 13 00     call    0x26    ; 0x26 <foo>
     4:   06 e2           ldi     r16, 0x26       ; 38
     6:   10 e0           ldi     r17, 0x00       ; 0
     8:   20 e0           ldi     r18, 0x00       ; 0
     a:   30 e0           ldi     r19, 0x00       ; 0
     c:   46 e2           ldi     r20, 0x26       ; 38
     e:   5a ed           ldi     r21, 0xDA       ; 218
    10:   6f ef           ldi     r22, 0xFF       ; 255
    12:   7f ef           ldi     r23, 0xFF       ; 255
    14:   8f ef           ldi     r24, 0xFF       ; 255
    16:   93 e1           ldi     r25, 0x13       ; 19
    18:   a0 e0           ldi     r26, 0x00       ; 0
    1a:   b0 e0           ldi     r27, 0x00       ; 0
    1c:   cd ee           ldi     r28, 0xED       ; 237
    1e:   df ef           ldi     r29, 0xFF       ; 255
    20:   ef ef           ldi     r30, 0xFF       ; 255
    22:   09 f4           brne    .+2             ; 0x26 <foo>
    24:   00 c0           rjmp    .+0             ; 0x26 <foo>
  
  00000026 <foo>:
    26:   2a 80           ldd     r2, Y+2 ; 0x02
    28:   08 80           ld      r0, Y
    2a:   94 84           ldd     r9, Z+12        ; 0x0c
    2c:   76 8c           ldd     r7, Z+30        ; 0x1e
    2e:   96 a0           ldd     r9, Z+38        ; 0x26
    30:   00 91 26 00     lds     r16, 0x0026     ; 0x800026 <foo+0x800000>
    34:   13 e1           ldi     r17, 0x13       ; 19
    36:   20 e0           ldi     r18, 0x00       ; 0
    38:   47 b5           in      r20, 0x27       ; 39
    3a:   00 9a           sbi     0x00, 0 ; 0
    3c:   b6 96           adiw    r30, 0x26       ; 38


Repository:
  rL LLVM

https://reviews.llvm.org/D37615

Files:
  ELF/Arch/AVR.cpp
  test/ELF/basic-avr.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37615.114781.patch
Type: text/x-patch
Size: 7974 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170912/e28b5ec3/attachment.bin>


More information about the llvm-commits mailing list