<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 10, 2014 at 10:42 PM, Hal Finkel <span dir="ltr"><<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5">----- Original Message -----<br>
> From: "Chad Rosier" <<a href="mailto:mcrosier@codeaurora.org">mcrosier@codeaurora.org</a>><br>
> To: <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> Sent: Monday, November 10, 2014 5:02:04 PM<br>
> Subject: [llvm] r221639 - [yaml2obj] Support AArch64 relocations.<br>
><br>
> Author: mcrosier<br>
> Date: Mon Nov 10 17:02:03 2014<br>
> New Revision: 221639<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=221639&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=221639&view=rev</a><br>
> Log:<br>
> [yaml2obj] Support AArch64 relocations.<br>
><br>
> Patch by Daniel Stewart <<a href="mailto:stewartd@codeaurora.org">stewartd@codeaurora.org</a>>!<br>
> Phabricator Revision: <a href="http://reviews.llvm.org/D6192" target="_blank">http://reviews.llvm.org/D6192</a><br>
><br>
> Added:<br>
>     llvm/trunk/test/Object/AArch64/<br>
>     llvm/trunk/test/Object/AArch64/yaml2obj-elf-aarch64-rel.yaml<br>
> Modified:<br>
>     llvm/trunk/lib/Object/ELFYAML.cpp<br>
><br>
> Modified: llvm/trunk/lib/Object/ELFYAML.cpp<br>
> URL:<br>
> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ELFYAML.cpp?rev=221639&r1=221638&r2=221639&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ELFYAML.cpp?rev=221639&r1=221638&r2=221639&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/Object/ELFYAML.cpp (original)<br>
> +++ llvm/trunk/lib/Object/ELFYAML.cpp Mon Nov 10 17:02:03 2014<br>
> @@ -672,6 +672,92 @@ void ScalarEnumerationTraits<ELFYAML::EL<br>
>      ECase(R_386_IRELATIVE)<br>
>      ECase(R_386_NUM)<br>
>      break;<br>
<br>
</div></div>Is this function supposed to be synchronized with lib/Object/ELF.cpp (which has one function: getELFRelocationTypeName). Keeping these in synch manually seems error-prone (and somewhat silly). Can we refactor this so that we don't have two essentially-identical lists of relocation names in the two files?<br></blockquote><div><br></div><div>Hi Hal, I'm the one that originally wrote the yaml2obj ELF support (although Simon did the relocation support). There is a lot of duplication with llvm-readobj as well (not just of the relocations, but basically everything else; including another whole copy of all relocations in test/tools/llvm-readobj/Inputs/relocs.py).</div><div><br></div><div>We could improve the state of things by putting stuff in tables of `struct { Integer Val; const char *Str; }` static data. That at least leaves just one place to update when the header changes.</div><div><br></div><div>It might be practical to write a 20-30 line python script to parse through ELF.h and generate the tables (might require some changes to ELF.h to make it easy to generate, e.g. giving each enum a name from which the table name can be derived, and also an explicit type). That way we we can instantly refresh all of them with little effort. I would suggest using Clang's parser, but I'm not sure we have quite gotten to the ease-of-use/ease-of-deployability point where we can expect every LLVM developer to run a clang-(AST-)based tool on a whim as part of the development process.</div><div><br></div><div>-- Sean Silva</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
Thanks again,<br>
Hal<br>
<div class=""><div class="h5"><br>
> +  case ELF::EM_AARCH64:<br>
> +    ECase(R_AARCH64_NONE)<br>
> +    ECase(R_AARCH64_ABS64)<br>
> +    ECase(R_AARCH64_ABS32)<br>
> +    ECase(R_AARCH64_ABS16)<br>
> +    ECase(R_AARCH64_PREL64)<br>
> +    ECase(R_AARCH64_PREL32)<br>
> +    ECase(R_AARCH64_PREL16)<br>
> +    ECase(R_AARCH64_MOVW_UABS_G0)<br>
> +    ECase(R_AARCH64_MOVW_UABS_G0_NC)<br>
> +    ECase(R_AARCH64_MOVW_UABS_G1)<br>
> +    ECase(R_AARCH64_MOVW_UABS_G1_NC)<br>
> +    ECase(R_AARCH64_MOVW_UABS_G2)<br>
> +    ECase(R_AARCH64_MOVW_UABS_G2_NC)<br>
> +    ECase(R_AARCH64_MOVW_UABS_G3)<br>
> +    ECase(R_AARCH64_MOVW_SABS_G0)<br>
> +    ECase(R_AARCH64_MOVW_SABS_G1)<br>
> +    ECase(R_AARCH64_MOVW_SABS_G2)<br>
> +    ECase(R_AARCH64_LD_PREL_LO19)<br>
> +    ECase(R_AARCH64_ADR_PREL_LO21)<br>
> +    ECase(R_AARCH64_ADR_PREL_PG_HI21)<br>
> +    ECase(R_AARCH64_ADD_ABS_LO12_NC)<br>
> +    ECase(R_AARCH64_LDST8_ABS_LO12_NC)<br>
> +    ECase(R_AARCH64_TSTBR14)<br>
> +    ECase(R_AARCH64_CONDBR19)<br>
> +    ECase(R_AARCH64_JUMP26)<br>
> +    ECase(R_AARCH64_CALL26)<br>
> +    ECase(R_AARCH64_LDST16_ABS_LO12_NC)<br>
> +    ECase(R_AARCH64_LDST32_ABS_LO12_NC)<br>
> +    ECase(R_AARCH64_LDST64_ABS_LO12_NC)<br>
> +    ECase(R_AARCH64_LDST128_ABS_LO12_NC)<br>
> +    ECase(R_AARCH64_GOTREL64)<br>
> +    ECase(R_AARCH64_GOTREL32)<br>
> +    ECase(R_AARCH64_ADR_GOT_PAGE)<br>
> +    ECase(R_AARCH64_LD64_GOT_LO12_NC)<br>
> +    ECase(R_AARCH64_TLSLD_MOVW_DTPREL_G2)<br>
> +    ECase(R_AARCH64_TLSLD_MOVW_DTPREL_G1)<br>
> +    ECase(R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC)<br>
> +    ECase(R_AARCH64_TLSLD_MOVW_DTPREL_G0)<br>
> +    ECase(R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC)<br>
> +    ECase(R_AARCH64_TLSLD_ADD_DTPREL_HI12)<br>
> +    ECase(R_AARCH64_TLSLD_ADD_DTPREL_LO12)<br>
> +    ECase(R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC)<br>
> +    ECase(R_AARCH64_TLSLD_LDST8_DTPREL_LO12)<br>
> +    ECase(R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC)<br>
> +    ECase(R_AARCH64_TLSLD_LDST16_DTPREL_LO12)<br>
> +    ECase(R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC)<br>
> +    ECase(R_AARCH64_TLSLD_LDST32_DTPREL_LO12)<br>
> +    ECase(R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC)<br>
> +    ECase(R_AARCH64_TLSLD_LDST64_DTPREL_LO12)<br>
> +    ECase(R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC)<br>
> +    ECase(R_AARCH64_TLSIE_MOVW_GOTTPREL_G1)<br>
> +    ECase(R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC)<br>
> +    ECase(R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21)<br>
> +    ECase(R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC)<br>
> +    ECase(R_AARCH64_TLSIE_LD_GOTTPREL_PREL19)<br>
> +    ECase(R_AARCH64_TLSLE_MOVW_TPREL_G2)<br>
> +    ECase(R_AARCH64_TLSLE_MOVW_TPREL_G1)<br>
> +    ECase(R_AARCH64_TLSLE_MOVW_TPREL_G1_NC)<br>
> +    ECase(R_AARCH64_TLSLE_MOVW_TPREL_G0)<br>
> +    ECase(R_AARCH64_TLSLE_MOVW_TPREL_G0_NC)<br>
> +    ECase(R_AARCH64_TLSLE_ADD_TPREL_HI12)<br>
> +    ECase(R_AARCH64_TLSLE_ADD_TPREL_LO12)<br>
> +    ECase(R_AARCH64_TLSLE_ADD_TPREL_LO12_NC)<br>
> +    ECase(R_AARCH64_TLSLE_LDST8_TPREL_LO12)<br>
> +    ECase(R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC)<br>
> +    ECase(R_AARCH64_TLSLE_LDST16_TPREL_LO12)<br>
> +    ECase(R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC)<br>
> +    ECase(R_AARCH64_TLSLE_LDST32_TPREL_LO12)<br>
> +    ECase(R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC)<br>
> +    ECase(R_AARCH64_TLSLE_LDST64_TPREL_LO12)<br>
> +    ECase(R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC)<br>
> +    ECase(R_AARCH64_TLSDESC_ADR_PAGE)<br>
> +    ECase(R_AARCH64_TLSDESC_LD64_LO12_NC)<br>
> +    ECase(R_AARCH64_TLSDESC_ADD_LO12_NC)<br>
> +    ECase(R_AARCH64_TLSDESC_CALL)<br>
> +    ECase(R_AARCH64_COPY)<br>
> +    ECase(R_AARCH64_GLOB_DAT)<br>
> +    ECase(R_AARCH64_JUMP_SLOT)<br>
> +    ECase(R_AARCH64_RELATIVE)<br>
> +    ECase(R_AARCH64_TLS_DTPREL64)<br>
> +    ECase(R_AARCH64_TLS_DTPMOD64)<br>
> +    ECase(R_AARCH64_TLS_TPREL64)<br>
> +    ECase(R_AARCH64_TLSDESC)<br>
> +    ECase(R_AARCH64_IRELATIVE)<br>
> +    break;<br>
>    default:<br>
>      llvm_unreachable("Unsupported architecture");<br>
>    }<br>
><br>
> Added: llvm/trunk/test/Object/AArch64/yaml2obj-elf-aarch64-rel.yaml<br>
> URL:<br>
> <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/AArch64/yaml2obj-elf-aarch64-rel.yaml?rev=221639&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/AArch64/yaml2obj-elf-aarch64-rel.yaml?rev=221639&view=auto</a><br>
> ==============================================================================<br>
> --- llvm/trunk/test/Object/AArch64/yaml2obj-elf-aarch64-rel.yaml<br>
> (added)<br>
> +++ llvm/trunk/test/Object/AArch64/yaml2obj-elf-aarch64-rel.yaml Mon<br>
> Nov 10 17:02:03 2014<br>
> @@ -0,0 +1,47 @@<br>
> +# RUN: yaml2obj -format=elf %s > %t<br>
> +# RUN: obj2yaml  %t | FileCheck %s<br>
> +<br>
> +# CHECK:      - Name:            .rela.text<br>
> +# CHECK-NEXT:   Type:            SHT_RELA<br>
> +# CHECK-NEXT:    Link:            .symtab<br>
> +# CHECK-NEXT:    AddressAlign:    0x0000000000000008<br>
> +# CHECK-NEXT:    Info:            .text<br>
> +# CHECK-NEXT:    Relocations:<br>
> +# CHECK-NEXT:      - Offset:          0x0000000000000000<br>
> +# CHECK-NEXT:        Symbol:          main<br>
> +# CHECK-NEXT:        Type:            R_AARCH64_ABS64<br>
> +# CHECK-NEXT:        Addend:          0<br>
> +<br>
> +FileHeader:<br>
> +  Class:           ELFCLASS64<br>
> +  Data:            ELFDATA2LSB<br>
> +  Type:            ET_REL<br>
> +  Machine:         EM_AARCH64<br>
> +Sections:<br>
> +  - Type:            SHT_PROGBITS<br>
> +    Name:            .text<br>
> +    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]<br>
> +    AddressAlign:    0x04<br>
> +    Content:         0000000000000000<br>
> +  - Type:            SHT_RELA<br>
> +    Name:            .rela.text<br>
> +    Link:            .symtab<br>
> +    Info:            .text<br>
> +    AddressAlign:    0x08<br>
> +    Relocations:<br>
> +      - Offset:          0<br>
> +        Symbol:          main<br>
> +        Type:            R_AARCH64_ABS64<br>
> +        Addend:          0<br>
> +<br>
> +Symbols:<br>
> +  Local:<br>
> +    - Name:            .text<br>
> +      Type:            STT_SECTION<br>
> +      Section:         .text<br>
> +<br>
> +  Global:<br>
> +    - Name:            main<br>
> +      Type:            STT_FUNC<br>
> +      Section:         .text<br>
> +      Size:            0x08<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
><br>
<br>
</div></div><span class=""><font color="#888888">--<br>
Hal Finkel<br>
Assistant Computational Scientist<br>
Leadership Computing Facility<br>
Argonne National Laboratory<br>
</font></span><div class=""><div class="h5">_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div></div>