[llvm] r221639 - [yaml2obj] Support AArch64 relocations.
Hal Finkel
hfinkel at anl.gov
Tue Nov 11 16:15:13 PST 2014
----- Original Message -----
> From: "Sean Silva" <chisophugis at gmail.com>
> To: "Hal Finkel" <hfinkel at anl.gov>
> Cc: "Chad Rosier" <mcrosier at codeaurora.org>, llvm-commits at cs.uiuc.edu
> Sent: Tuesday, November 11, 2014 6:03:10 PM
> Subject: Re: [llvm] r221639 - [yaml2obj] Support AArch64 relocations.
>
> On Mon, Nov 10, 2014 at 10:42 PM, Hal Finkel < hfinkel at anl.gov >
> wrote:
>
>
>
>
> ----- Original Message -----
> > From: "Chad Rosier" < mcrosier at codeaurora.org >
> > To: llvm-commits at cs.uiuc.edu
> > Sent: Monday, November 10, 2014 5:02:04 PM
> > Subject: [llvm] r221639 - [yaml2obj] Support AArch64 relocations.
> >
> > Author: mcrosier
> > Date: Mon Nov 10 17:02:03 2014
> > New Revision: 221639
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=221639&view=rev
> > Log:
> > [yaml2obj] Support AArch64 relocations.
> >
> > Patch by Daniel Stewart < stewartd at codeaurora.org >!
> > Phabricator Revision: http://reviews.llvm.org/D6192
> >
> > Added:
> > llvm/trunk/test/Object/AArch64/
> > llvm/trunk/test/Object/AArch64/yaml2obj-elf-aarch64-rel.yaml
> > Modified:
> > llvm/trunk/lib/Object/ELFYAML.cpp
> >
> > Modified: llvm/trunk/lib/Object/ELFYAML.cpp
> > URL:
> > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ELFYAML.cpp?rev=221639&r1=221638&r2=221639&view=diff
> > ==============================================================================
> > --- llvm/trunk/lib/Object/ELFYAML.cpp (original)
> > +++ llvm/trunk/lib/Object/ELFYAML.cpp Mon Nov 10 17:02:03 2014
> > @@ -672,6 +672,92 @@ void ScalarEnumerationTraits<ELFYAML::EL
> > ECase(R_386_IRELATIVE)
> > ECase(R_386_NUM)
> > break;
>
> 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?
>
>
>
> 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).
>
>
> 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.
>
>
> 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.
I think that an even easier method is to use the preprocessor -- just as Clang does with its .def files (see include/clang/Basic/*.def for examples). If we put these into a .def file, then that file can be included multiple times, and each time the relevant macro can be defined appropriately to do the right thing.
-Hal
>
>
> -- Sean Silva
>
>
>
>
>
> Thanks again,
> Hal
>
>
>
> > + case ELF::EM_AARCH64:
> > + ECase(R_AARCH64_NONE)
> > + ECase(R_AARCH64_ABS64)
> > + ECase(R_AARCH64_ABS32)
> > + ECase(R_AARCH64_ABS16)
> > + ECase(R_AARCH64_PREL64)
> > + ECase(R_AARCH64_PREL32)
> > + ECase(R_AARCH64_PREL16)
> > + ECase(R_AARCH64_MOVW_UABS_G0)
> > + ECase(R_AARCH64_MOVW_UABS_G0_NC)
> > + ECase(R_AARCH64_MOVW_UABS_G1)
> > + ECase(R_AARCH64_MOVW_UABS_G1_NC)
> > + ECase(R_AARCH64_MOVW_UABS_G2)
> > + ECase(R_AARCH64_MOVW_UABS_G2_NC)
> > + ECase(R_AARCH64_MOVW_UABS_G3)
> > + ECase(R_AARCH64_MOVW_SABS_G0)
> > + ECase(R_AARCH64_MOVW_SABS_G1)
> > + ECase(R_AARCH64_MOVW_SABS_G2)
> > + ECase(R_AARCH64_LD_PREL_LO19)
> > + ECase(R_AARCH64_ADR_PREL_LO21)
> > + ECase(R_AARCH64_ADR_PREL_PG_HI21)
> > + ECase(R_AARCH64_ADD_ABS_LO12_NC)
> > + ECase(R_AARCH64_LDST8_ABS_LO12_NC)
> > + ECase(R_AARCH64_TSTBR14)
> > + ECase(R_AARCH64_CONDBR19)
> > + ECase(R_AARCH64_JUMP26)
> > + ECase(R_AARCH64_CALL26)
> > + ECase(R_AARCH64_LDST16_ABS_LO12_NC)
> > + ECase(R_AARCH64_LDST32_ABS_LO12_NC)
> > + ECase(R_AARCH64_LDST64_ABS_LO12_NC)
> > + ECase(R_AARCH64_LDST128_ABS_LO12_NC)
> > + ECase(R_AARCH64_GOTREL64)
> > + ECase(R_AARCH64_GOTREL32)
> > + ECase(R_AARCH64_ADR_GOT_PAGE)
> > + ECase(R_AARCH64_LD64_GOT_LO12_NC)
> > + ECase(R_AARCH64_TLSLD_MOVW_DTPREL_G2)
> > + ECase(R_AARCH64_TLSLD_MOVW_DTPREL_G1)
> > + ECase(R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC)
> > + ECase(R_AARCH64_TLSLD_MOVW_DTPREL_G0)
> > + ECase(R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC)
> > + ECase(R_AARCH64_TLSLD_ADD_DTPREL_HI12)
> > + ECase(R_AARCH64_TLSLD_ADD_DTPREL_LO12)
> > + ECase(R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC)
> > + ECase(R_AARCH64_TLSLD_LDST8_DTPREL_LO12)
> > + ECase(R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC)
> > + ECase(R_AARCH64_TLSLD_LDST16_DTPREL_LO12)
> > + ECase(R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC)
> > + ECase(R_AARCH64_TLSLD_LDST32_DTPREL_LO12)
> > + ECase(R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC)
> > + ECase(R_AARCH64_TLSLD_LDST64_DTPREL_LO12)
> > + ECase(R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC)
> > + ECase(R_AARCH64_TLSIE_MOVW_GOTTPREL_G1)
> > + ECase(R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC)
> > + ECase(R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21)
> > + ECase(R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC)
> > + ECase(R_AARCH64_TLSIE_LD_GOTTPREL_PREL19)
> > + ECase(R_AARCH64_TLSLE_MOVW_TPREL_G2)
> > + ECase(R_AARCH64_TLSLE_MOVW_TPREL_G1)
> > + ECase(R_AARCH64_TLSLE_MOVW_TPREL_G1_NC)
> > + ECase(R_AARCH64_TLSLE_MOVW_TPREL_G0)
> > + ECase(R_AARCH64_TLSLE_MOVW_TPREL_G0_NC)
> > + ECase(R_AARCH64_TLSLE_ADD_TPREL_HI12)
> > + ECase(R_AARCH64_TLSLE_ADD_TPREL_LO12)
> > + ECase(R_AARCH64_TLSLE_ADD_TPREL_LO12_NC)
> > + ECase(R_AARCH64_TLSLE_LDST8_TPREL_LO12)
> > + ECase(R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC)
> > + ECase(R_AARCH64_TLSLE_LDST16_TPREL_LO12)
> > + ECase(R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC)
> > + ECase(R_AARCH64_TLSLE_LDST32_TPREL_LO12)
> > + ECase(R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC)
> > + ECase(R_AARCH64_TLSLE_LDST64_TPREL_LO12)
> > + ECase(R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC)
> > + ECase(R_AARCH64_TLSDESC_ADR_PAGE)
> > + ECase(R_AARCH64_TLSDESC_LD64_LO12_NC)
> > + ECase(R_AARCH64_TLSDESC_ADD_LO12_NC)
> > + ECase(R_AARCH64_TLSDESC_CALL)
> > + ECase(R_AARCH64_COPY)
> > + ECase(R_AARCH64_GLOB_DAT)
> > + ECase(R_AARCH64_JUMP_SLOT)
> > + ECase(R_AARCH64_RELATIVE)
> > + ECase(R_AARCH64_TLS_DTPREL64)
> > + ECase(R_AARCH64_TLS_DTPMOD64)
> > + ECase(R_AARCH64_TLS_TPREL64)
> > + ECase(R_AARCH64_TLSDESC)
> > + ECase(R_AARCH64_IRELATIVE)
> > + break;
> > default:
> > llvm_unreachable("Unsupported architecture");
> > }
> >
> > Added: llvm/trunk/test/Object/AArch64/yaml2obj-elf-aarch64-rel.yaml
> > URL:
> > http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/AArch64/yaml2obj-elf-aarch64-rel.yaml?rev=221639&view=auto
> > ==============================================================================
> > --- llvm/trunk/test/Object/AArch64/yaml2obj-elf-aarch64-rel.yaml
> > (added)
> > +++ llvm/trunk/test/Object/AArch64/yaml2obj-elf-aarch64-rel.yaml
> > Mon
> > Nov 10 17:02:03 2014
> > @@ -0,0 +1,47 @@
> > +# RUN: yaml2obj -format=elf %s > %t
> > +# RUN: obj2yaml %t | FileCheck %s
> > +
> > +# CHECK: - Name: .rela.text
> > +# CHECK-NEXT: Type: SHT_RELA
> > +# CHECK-NEXT: Link: .symtab
> > +# CHECK-NEXT: AddressAlign: 0x0000000000000008
> > +# CHECK-NEXT: Info: .text
> > +# CHECK-NEXT: Relocations:
> > +# CHECK-NEXT: - Offset: 0x0000000000000000
> > +# CHECK-NEXT: Symbol: main
> > +# CHECK-NEXT: Type: R_AARCH64_ABS64
> > +# CHECK-NEXT: Addend: 0
> > +
> > +FileHeader:
> > + Class: ELFCLASS64
> > + Data: ELFDATA2LSB
> > + Type: ET_REL
> > + Machine: EM_AARCH64
> > +Sections:
> > + - Type: SHT_PROGBITS
> > + Name: .text
> > + Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
> > + AddressAlign: 0x04
> > + Content: 0000000000000000
> > + - Type: SHT_RELA
> > + Name: .rela.text
> > + Link: .symtab
> > + Info: .text
> > + AddressAlign: 0x08
> > + Relocations:
> > + - Offset: 0
> > + Symbol: main
> > + Type: R_AARCH64_ABS64
> > + Addend: 0
> > +
> > +Symbols:
> > + Local:
> > + - Name: .text
> > + Type: STT_SECTION
> > + Section: .text
> > +
> > + Global:
> > + - Name: main
> > + Type: STT_FUNC
> > + Section: .text
> > + Size: 0x08
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> >
>
> --
> Hal Finkel
> Assistant Computational Scientist
> Leadership Computing Facility
> Argonne National Laboratory
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
--
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory
More information about the llvm-commits
mailing list