1 /*
   2  * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package jdk.tools.jaotc.jnilibelf;
  25 
  26 /**
  27  * Class that abstracts ELF relocations.
  28  *
  29  */
  30 public interface JNIELFRelocation {
  31     int R_UNDEF = -1;
  32 
  33     /**
  34      * x86-specific relocation types.
  35      *
  36      */
  37     public interface I386 {
  38         /* i386 relocs. */
  39 
  40         int R_386_NONE = 0; /* No reloc */
  41         int R_386_32 = 1; /* Direct 32 bit */
  42         int R_386_PC32 = 2; /* PC relative 32 bit */
  43         int R_386_GOT32 = 3; /* 32 bit GOT entry */
  44         int R_386_PLT32 = 4; /* 32 bit PLT address */
  45         int R_386_COPY = 5; /* Copy symbol at runtime */
  46         int R_386_GLOB_DAT = 6; /* Create GOT entry */
  47         int R_386_JMP_SLOT = 7; /* Create PLT entry */
  48         int R_386_RELATIVE = 8; /* Adjust by program base */
  49         int R_386_GOTOFF = 9; /* 32 bit offset to GOT */
  50         int R_386_GOTPC = 10; /* 32 bit PC relative offset to GOT */
  51         int R_386_32PLT = 11;
  52         int R_386_TLS_TPOFF = 14; /* Offset in static TLS block */
  53         int R_386_TLS_IE = 15; /* Address of GOT entry for static TLS block offset */
  54         int R_386_TLS_GOTIE = 16; /* GOT entry for static TLS block offset */
  55         int R_386_TLS_LE = 17; /* Offset relative to static TLS block */
  56         int R_386_TLS_GD = 18; /* Direct 32 bit for GNU version of general dynamic thread local data */
  57         int R_386_TLS_LDM = 19; /*
  58                                  * Direct 32 bit for GNU version of local dynamic thread local data
  59                                  * in LE code
  60                                  */
  61         int R_386_16 = 20;
  62         int R_386_PC16 = 21;
  63         int R_386_8 = 22;
  64         int R_386_PC8 = 23;
  65         int R_386_TLS_GD_32 = 24; /* Direct 32 bit for general dynamic thread local data */
  66         int R_386_TLS_GD_PUSH = 25; /* Tag for pushl in GD TLS code */
  67         int R_386_TLS_GD_CALL = 26; /* Relocation for call to __tls_get_addr() */
  68         int R_386_TLS_GD_POP = 27; /* Tag for popl in GD TLS code */
  69         int R_386_TLS_LDM_32 = 28; /* Direct 32 bit for local dynamic thread local data in LE code */
  70         int R_386_TLS_LDM_PUSH = 29; /* Tag for pushl in LDM TLS code */
  71         int R_386_TLS_LDM_CALL = 30; /* Relocation for call to __tls_get_addr() in LDM code */
  72         int R_386_TLS_LDM_POP = 31; /* Tag for popl in LDM TLS code */
  73         int R_386_TLS_LDO_32 = 32; /* Offset relative to TLS block */
  74         int R_386_TLS_IE_32 = 33; /* GOT entry for negated static TLS block offset */
  75         int R_386_TLS_LE_32 = 34; /* Negated offset relative to static TLS block */
  76         int R_386_TLS_DTPMOD32 = 35; /* ID of module containing symbol */
  77         int R_386_TLS_DTPOFF32 = 36; /* Offset in TLS block */
  78         int R_386_TLS_TPOFF32 = 37; /* Negated offset in static TLS block */
  79         int R_386_SIZE32 = 38; /* 32-bit symbol size */
  80         int R_386_TLS_GOTDESC = 39; /* GOT offset for TLS descriptor. */
  81         int R_386_TLS_DESC_CALL = 40; /* Marker of call through TLS descriptor for relaxation. */
  82         int R_386_TLS_DESC = 41; /*
  83                                   * TLS descriptor containing pointer to code and to argument,
  84                                   * returning the TLS offset for the symbol.
  85                                   */
  86         int R_386_IRELATIVE = 42; /* Adjust indirectly by program base */
  87         /* Keep this the last entry. */
  88         int R_386_NUM = 43;
  89     }
  90 
  91     /**
  92      * x86_64-specific relocation types.
  93      */
  94     public interface X86_64 {
  95         /* AMD x86-64 relocations. */
  96         int R_X86_64_NONE = 0; /* No reloc */
  97         int R_X86_64_64 = 1; /* Direct 64 bit */
  98         int R_X86_64_PC32 = 2; /* PC relative 32 bit signed */
  99         int R_X86_64_GOT32 = 3; /* 32 bit GOT entry */
 100         int R_X86_64_PLT32 = 4; /* 32 bit PLT address */
 101         int R_X86_64_COPY = 5; /* Copy symbol at runtime */
 102         int R_X86_64_GLOB_DAT = 6; /* Create GOT entry */
 103         int R_X86_64_JUMP_SLOT = 7; /* Create PLT entry */
 104         int R_X86_64_RELATIVE = 8; /* Adjust by program base */
 105         int R_X86_64_GOTPCREL = 9; /* 32 bit signed PC relative offset to GOT */
 106         int R_X86_64_32 = 10; /* Direct 32 bit zero extended */
 107         int R_X86_64_32S = 11; /* Direct 32 bit sign extended */
 108         int R_X86_64_16 = 12; /* Direct 16 bit zero extended */
 109         int R_X86_64_PC16 = 13; /* 16 bit sign extended pc relative */
 110         int R_X86_64_8 = 14; /* Direct 8 bit sign extended */
 111         int R_X86_64_PC8 = 15; /* 8 bit sign extended pc relative */
 112         int R_X86_64_DTPMOD64 = 16; /* ID of module containing symbol */
 113         int R_X86_64_DTPOFF64 = 17; /* Offset in module's TLS block */
 114         int R_X86_64_TPOFF64 = 18; /* Offset in initial TLS block */
 115         int R_X86_64_TLSGD = 19; /*
 116                                   * 32 bit signed PC relative offset to two GOT entries for GD
 117                                   * symbol
 118                                   */
 119         int R_X86_64_TLSLD = 20; /*
 120                                   * 32 bit signed PC relative offset to two GOT entries for LD
 121                                   * symbol
 122                                   */
 123         int R_X86_64_DTPOFF32 = 21; /* Offset in TLS block */
 124         int R_X86_64_GOTTPOFF = 22; /*
 125                                      * 32 bit signed PC relative offset to GOT entry for IE symbol
 126                                      */
 127         int R_X86_64_TPOFF32 = 23; /* Offset in initial TLS block */
 128         int R_X86_64_PC64 = 24; /* PC relative 64 bit */
 129         int R_X86_64_GOTOFF64 = 25; /* 64 bit offset to GOT */
 130         int R_X86_64_GOTPC32 = 26; /* 32 bit signed pc relative offset to GOT */
 131         int R_X86_64_GOT64 = 27; /* 64-bit GOT entry offset */
 132         int R_X86_64_GOTPCREL64 = 28; /* 64-bit PC relative offset to GOT entry */
 133         int R_X86_64_GOTPC64 = 29; /* 64-bit PC relative offset to GOT */
 134         int R_X86_64_GOTPLT64 = 30; /* like GOT64, says PLT entry needed */
 135         int R_X86_64_PLTOFF64 = 31; /* 64-bit GOT relative offset to PLT entry */
 136         int R_X86_64_SIZE32 = 32; /* Size of symbol plus 32-bit addend */
 137         int R_X86_64_SIZE64 = 33; /* Size of symbol plus 64-bit addend */
 138         int R_X86_64_GOTPC32_TLSDESC = 34; /* GOT offset for TLS descriptor. */
 139         int R_X86_64_TLSDESC_CALL = 35; /*
 140                                          * Marker for call through TLS descriptor.
 141                                          */
 142         int R_X86_64_TLSDESC = 36; /* TLS descriptor. */
 143         int R_X86_64_IRELATIVE = 37; /* Adjust indirectly by program base */
 144         int R_X86_64_RELATIVE64 = 38; /* 64-bit adjust by program base */
 145 
 146         int R_X86_64_NUM = 39;
 147     }
 148 }