Module: ELFTools::Constants::R

Defined in:
lib/elftools/constants.rb,
lib/elftools/constants/relocation.rb,
lib/elftools/constants/relocation/h8.rb,
lib/elftools/constants/relocation/mt.rb,
lib/elftools/constants/relocation/pj.rb,
lib/elftools/constants/relocation/rx.rb,
lib/elftools/constants/relocation/sh.rb,
lib/elftools/constants/relocation/arm.rb,
lib/elftools/constants/relocation/avr.rb,
lib/elftools/constants/relocation/bpf.rb,
lib/elftools/constants/relocation/crx.rb,
lib/elftools/constants/relocation/dlx.rb,
lib/elftools/constants/relocation/frv.rb,
lib/elftools/constants/relocation/kvx.rb,
lib/elftools/constants/relocation/mep.rb,
lib/elftools/constants/relocation/nfp.rb,
lib/elftools/constants/relocation/ppc.rb,
lib/elftools/constants/relocation/pru.rb,
lib/elftools/constants/relocation/spu.rb,
lib/elftools/constants/relocation/vax.rb,
lib/elftools/constants/relocation/z80.rb,
lib/elftools/constants/relocation/bfin.rb,
lib/elftools/constants/relocation/cr16.rb,
lib/elftools/constants/relocation/cris.rb,
lib/elftools/constants/relocation/csky.rb,
lib/elftools/constants/relocation/d10v.rb,
lib/elftools/constants/relocation/d30v.rb,
lib/elftools/constants/relocation/fr30.rb,
lib/elftools/constants/relocation/ft32.rb,
lib/elftools/constants/relocation/hppa.rb,
lib/elftools/constants/relocation/i370.rb,
lib/elftools/constants/relocation/i386.rb,
lib/elftools/constants/relocation/i860.rb,
lib/elftools/constants/relocation/i960.rb,
lib/elftools/constants/relocation/ia64.rb,
lib/elftools/constants/relocation/ip2k.rb,
lib/elftools/constants/relocation/lm32.rb,
lib/elftools/constants/relocation/m32c.rb,
lib/elftools/constants/relocation/m32r.rb,
lib/elftools/constants/relocation/m68k.rb,
lib/elftools/constants/relocation/mips.rb,
lib/elftools/constants/relocation/mmix.rb,
lib/elftools/constants/relocation/or1k.rb,
lib/elftools/constants/relocation/rl78.rb,
lib/elftools/constants/relocation/s12z.rb,
lib/elftools/constants/relocation/s390.rb,
lib/elftools/constants/relocation/v800.rb,
lib/elftools/constants/relocation/v850.rb,
lib/elftools/constants/relocation/alpha.rb,
lib/elftools/constants/relocation/mcore.rb,
lib/elftools/constants/relocation/metag.rb,
lib/elftools/constants/relocation/moxie.rb,
lib/elftools/constants/relocation/nds32.rb,
lib/elftools/constants/relocation/nios2.rb,
lib/elftools/constants/relocation/ppc64.rb,
lib/elftools/constants/relocation/riscv.rb,
lib/elftools/constants/relocation/score.rb,
lib/elftools/constants/relocation/sparc.rb,
lib/elftools/constants/relocation/tic6x.rb,
lib/elftools/constants/relocation/xgate.rb,
lib/elftools/constants/relocation/amdgpu.rb,
lib/elftools/constants/relocation/iq2000.rb,
lib/elftools/constants/relocation/msp430.rb,
lib/elftools/constants/relocation/tilegx.rb,
lib/elftools/constants/relocation/visium.rb,
lib/elftools/constants/relocation/wasm32.rb,
lib/elftools/constants/relocation/x86_64.rb,
lib/elftools/constants/relocation/xtensa.rb,
lib/elftools/constants/relocation/aarch64.rb,
lib/elftools/constants/relocation/m68hc11.rb,
lib/elftools/constants/relocation/mn10200.rb,
lib/elftools/constants/relocation/mn10300.rb,
lib/elftools/constants/relocation/msp430x.rb,
lib/elftools/constants/relocation/nfp3200.rb,
lib/elftools/constants/relocation/tilepro.rb,
lib/elftools/constants/relocation/epiphany.rb,
lib/elftools/constants/relocation/loongarch.rb,
lib/elftools/constants/relocation/xstormy16.rb,
lib/elftools/constants/relocation/microblaze.rb

Overview

Relocation types, recorded in the r_info of a relocation.

Every architecture numbers them on its own, so they are grouped by architecture and only loaded once one of the groups is asked for.

Defined Under Namespace

Modules: AARCH64, ALPHA, AMDGPU, ARM, AVR, BFIN, BPF, CR16, CRIS, CRX, CSKY, D10V, D30V, DLX, EPIPHANY, FR30, FRV, FT32, H8, HPPA, I370, I386, I860, I960, IA64, IP2K, IQ2000, KVX, LM32, LOONGARCH, M32C, M32R, M68HC11, M68K, MCORE, MEP, METAG, MICROBLAZE, MIPS, MMIX, MN10200, MN10300, MOXIE, MSP430, MSP430X, MT, NDS32, NFP, NFP3200, NIOS2, OR1K, PJ, PPC, PPC64, PRU, RISCV, RL78, RX, S12Z, S390, SCORE, SH, SPARC, SPU, TIC6X, TILEGX, TILEPRO, V800, V850, VAX, VISIUM, WASM32, X86_64, XGATE, XSTORMY16, XTENSA, Z80

Constant Summary collapse

MACHINES =

The architecture that relocates each machine.

Returns:

  • (Hash{Integer => Symbol})
{
  EM::EM_386 => :I386,
  EM::EM_68HC11 => :M68HC11,
  EM::EM_68HC12 => :M68HC11,
  EM::EM_68K => :M68K,
  EM::EM_860 => :I860,
  EM::EM_960 => :I960,
  EM::EM_AARCH64 => :AARCH64,
  EM::EM_ADAPTEVA_EPIPHANY => :EPIPHANY,
  EM::EM_ALPHA => :ALPHA,
  EM::EM_ALTERA_NIOS2 => :NIOS2,
  EM::EM_AMDGPU => :AMDGPU,
  EM::EM_ARM => :ARM,
  EM::EM_AVR => :AVR,
  EM::EM_BLACKFIN => :BFIN,
  EM::EM_BPF => :BPF,
  EM::EM_CR16 => :CR16,
  EM::EM_CRIS => :CRIS,
  EM::EM_CRX => :CRX,
  EM::EM_CSKY => :CSKY,
  EM::EM_CYGNUS_FRV => :FRV,
  EM::EM_CYGNUS_MEP => :MEP,
  EM::EM_D10V => :D10V,
  EM::EM_D30V => :D30V,
  EM::EM_DLX => :DLX,
  EM::EM_FR30 => :FR30,
  EM::EM_FT32 => :FT32,
  EM::EM_H8S => :H8,
  EM::EM_H8_300 => :H8,
  EM::EM_H8_300H => :H8,
  EM::EM_IAMCU => :I386,
  EM::EM_IA_64 => :IA64,
  EM::EM_IP2K => :IP2K,
  EM::EM_IQ2000 => :IQ2000,
  EM::EM_KVX => :KVX,
  EM::EM_LATTICEMICO32 => :LM32,
  EM::EM_LOONGARCH => :LOONGARCH,
  EM::EM_M32C => :M32C,
  EM::EM_M32R => :M32R,
  EM::EM_MCORE => :MCORE,
  EM::EM_METAG => :METAG,
  EM::EM_MICROBLAZE => :MICROBLAZE,
  EM::EM_MIPS => :MIPS,
  EM::EM_MMIX => :MMIX,
  EM::EM_MN10200 => :MN10200,
  EM::EM_MN10300 => :MN10300,
  EM::EM_MOXIE => :MOXIE,
  EM::EM_MSP430 => :MSP430,
  EM::EM_MT => :MT,
  EM::EM_NDS32 => :NDS32,
  EM::EM_NFP => :NFP,
  EM::EM_OR1K => :OR1K,
  EM::EM_PARISC => :HPPA,
  EM::EM_PJ => :PJ,
  EM::EM_PPC => :PPC,
  EM::EM_PPC64 => :PPC64,
  EM::EM_RISCV => :RISCV,
  EM::EM_RL78 => :RL78,
  EM::EM_RX => :RX,
  EM::EM_S12Z => :S12Z,
  EM::EM_S370 => :I370,
  EM::EM_S390 => :S390,
  EM::EM_S390_OLD => :S390,
  EM::EM_SCORE => :SCORE,
  EM::EM_SH => :SH,
  EM::EM_SPARC => :SPARC,
  EM::EM_SPARC32PLUS => :SPARC,
  EM::EM_SPARCV9 => :SPARC,
  EM::EM_SPU => :SPU,
  EM::EM_TILEGX => :TILEGX,
  EM::EM_TILEPRO => :TILEPRO,
  EM::EM_TI_C6000 => :TIC6X,
  EM::EM_TI_PRU => :PRU,
  EM::EM_V800 => :V800,
  EM::EM_V850 => :V850,
  EM::EM_VAX => :VAX,
  EM::EM_VISIUM => :VISIUM,
  EM::EM_WEBASSEMBLY => :WASM32,
  EM::EM_X86_64 => :X86_64,
  EM::EM_XGATE => :XGATE,
  EM::EM_XSTORMY16 => :XSTORMY16,
  EM::EM_XTENSA => :XTENSA,
  EM::EM_Z80 => :Z80
}.freeze

Class Method Summary collapse

Class Method Details

.mapping(machine, type) ⇒ String

Return the name of a relocation type.

A type only means something together with the machine that recorded it, both of them are needed to name it.

Examples:

mapping(Constants::EM_X86_64, 7)
#=> 'R_X86_64_JUMP_SLOT'
mapping(Constants::EM_ARM, 7)
#=> 'R_ARM_THM_ABS5'
mapping(Constants::EM_X86_64, 1337)
#=> '<unknown>: 0x539'

Parameters:

  • machine (Integer?)

    Value of e_machine.

  • type (Integer)

    The relocation type.

Returns:

  • (String)

    Name of the relocation type.



307
308
309
310
311
# File 'lib/elftools/constants.rb', line 307

def self.mapping(machine, type)
  architecture = MACHINES[machine]
  names = architecture && names_of(const_get(architecture))
  names&.fetch(type, nil) || format('<unknown>: 0x%x', type)
end

.names_of(architecture) ⇒ Hash{Integer => String}

Names of every relocation type an architecture defines.

Returns:

  • (Hash{Integer => String})


315
316
317
318
# File 'lib/elftools/constants.rb', line 315

def self.names_of(architecture)
  @names_of ||= {}
  @names_of[architecture] ||= architecture.constants.to_h { |name| [architecture.const_get(name), name.to_s] }
end