This is an archive of the discontinued LLVM Phabricator instance.

[ARC] Prepare the implementation of relocation for lld
ClosedPublic

Authored by xiangzhai on Sep 7 2017, 2:31 AM.

Details

Summary

Hi LLVM developers,

Prepare the implementation of ARC target ELF relocation for lld, so at present it needs ARC GNU toolchain to generate ELF object:

$ cat arc-hello.s
main:
  bl memset
  bl strncpy
  bl puts

$ /opt/arc-gnu/bin/arc-elf32-gcc -mcpu=arc600 -o arc-hello.o -c arc-hello.s

Relocation:

$ /opt/arc-gnu/bin/arc-elf32-readelf -r arc-hello.o

Relocation section '.rela.text' at offset 0x108 contains 3 entries:
 Offset     Info    Type            Sym.Value  Sym. Name + Addend
00000000  00000611 R_ARC_S25W_PCREL  00000000   memset + 0
00000004  00000711 R_ARC_S25W_PCREL  00000000   strncpy + 0
00000008  00000811 R_ARC_S25W_PCREL  00000000   puts + 0

LLD:

$ /opt/llvm-svn/bin/ld.lld -o arc-hello-lld arc-hello.o -L/opt/arc-gnu/lib/gcc/arc-elf32/7.1.1/arc600 -L/opt/arc-gnu/lib/gcc/arc-elf32/7.1.1/../../../../arc-elf32/lib/arc600 -L/opt/arc-gnu/lib/gcc/arc-elf32/7.1.1 -L/opt/arc-gnu/lib/gcc/arc-elf32/7.1.1/../../../../arc-elf32/lib --start-group -lgcc -lc -lnosys --end-group -Ttext=0

Please review it, thanks a lot!

Regards,
Leslie Zhai

Diff Detail

Repository
rL LLVM

Event Timeline

xiangzhai created this revision.Sep 7 2017, 2:31 AM
kparzysz edited edge metadata.Sep 8 2017, 10:50 AM

Should you also change lib/ObjectYAML/ELFYAML.cpp?

kparzysz accepted this revision.Sep 8 2017, 11:24 AM

If you decide that the YAML file doesn't need to be modified in this patch, the rest LGTM.

This revision is now accepted and ready to land.Sep 8 2017, 11:24 AM
xiangzhai updated this revision to Diff 114531.Sep 10 2017, 7:16 PM

Hi Krzysztof,

Thanks for your review!

I updated my patch as your suggestion, but at present there is *no* ARC Specific e_flags defined.

Regards,
Leslie Zhai

kparzysz added inline comments.Sep 11 2017, 8:03 AM
include/llvm/BinaryFormat/ELF.h
440

If this doesn't add any flags, it shouldn't be here. Otherwise LGTM.

xiangzhai updated this revision to Diff 114756.Sep 11 2017, 7:57 PM

Add ARC Specific e_flags.

xiangzhai marked an inline comment as done.Sep 11 2017, 7:57 PM
kparzysz accepted this revision.Sep 12 2017, 5:32 AM
This revision was automatically updated to reflect the committed changes.