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.
{ 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
-
.mapping(machine, type) ⇒ String
Return the name of a relocation type.
-
.names_of(architecture) ⇒ Hash{Integer => String}
Names of every relocation type an architecture defines.
-
.relative(machine) ⇒ Integer?
The type a machine calls a relocation that only adds the load bias, which every architecture defining one spells
R_<arch>_RELATIVE.
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.
324 325 326 327 328 |
# File 'lib/elftools/constants.rb', line 324 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.
359 360 361 362 |
# File 'lib/elftools/constants.rb', line 359 def self.names_of(architecture) @names_of ||= {} @names_of[architecture] ||= architecture.constants.to_h { |name| [architecture.const_get(name), name.to_s] } end |
.relative(machine) ⇒ Integer?
The type a machine calls a relocation that only adds the load bias,
which every architecture defining one spells R_<arch>_RELATIVE.
A table of them recorded as DT_RELR names no type, because the
format holds nothing but addresses and every one of them relocates
this way, so the type is asked of the machine instead.
344 345 346 347 348 349 350 351 352 353 354 355 |
# File 'lib/elftools/constants.rb', line 344 def self.relative(machine) architecture = MACHINES[machine] return if architecture.nil? @relative ||= {} @relative.fetch(architecture) do names = const_get(architecture).constants.grep(/_RELATIVE\z/) # An architecture naming more than one names the other for a second # data model, which spells it out in the name and so is longer. @relative[architecture] = names.min_by(&:length)&.then { |name| const_get(architecture).const_get(name) } end end |