[PATCH] D32991: [ELF] Initial migration of AVR target

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 12 02:27:08 PDT 2017


grimar added a comment.

In https://reviews.llvm.org/D32991#752982, @xiangzhai wrote:

> Dear George,
>
> Thanks for your reply!
>
> > This needs testcase.
>
> I haven't written it under test or unittests directories


When we write patches we always use testcases. You can find them in llvm\tools\lld\test\ELF\*.
Things like new target always needs some, because testcase is a proof of work.

> readelf -r avr-gcc-BareMinimum.o
> 
> Relocation section '.rela.text' at offset 0x1d0 contains 2 entries:
> 
>   Offset     Info    Type            Sym.Value  Sym. Name + Addend
> 
> 00000000  00000d03 R_AVR_13_PCREL    00000000   bar + 0
>  00000002  00000e03 R_AVR_13_PCREL    00000000   foo + 0
> 
>   with
>   
> 
> 
> readelf -r clang-BareMinimum.o
> 
> Relocation section '.rela.text' at offset 0xb8 contains 2 entries:
> 
>   Offset     Info    Type            Sym.Value  Sym. Name + Addend
> 
> 00000000  00000212 R_AVR_CALL        00000000   bar + 0
>  00000004  00000312 R_AVR_CALL        00000000   foo + 0
> 
>   

So according to output you provide, there are R_AVR_13_PCREL and R_AVR_CALL relocations in objects
that you probably need to implement to link them.
Though I think minimal possible runnable code would not have calls to bar() or foo() and you would not have these
relocations. I would suggest to link and run minimal possible example with just empty setup() and loop() for start.

>> I doubt that I might drove in the wrong direction? it should not be simple as my illusion?
> 
> The relocation of R_AVR_32 in my patch might be wrong! so I am reading the source code of binutils <https://sourceware.org/git/?p=binutils.git;a=blob;f=bfd/elf32-avr.c;h=43100cd20fc0f48e26bdbd8c841c661f9c37c33f;hb=HEAD#l116> and also Dylan's fork <https://github.com/avr-llvm/lld/blob/avr-support/lib/ReaderWriter/ELF/AVR/AVRRelocationHandler.cpp#L51>. but I have to look after my little kid in the weekend :) miss you, see you next week.
> 
> Regards,
>  Leslie Zhai




Repository:
  rL LLVM

https://reviews.llvm.org/D32991





More information about the llvm-commits mailing list