elftools 1.3.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +193 -7
  3. data/lib/elftools/constants/machine.rb +248 -0
  4. data/lib/elftools/constants/machine_names.rb +246 -0
  5. data/lib/elftools/constants/relocation/aarch64.rb +213 -0
  6. data/lib/elftools/constants/relocation/alpha.rb +47 -0
  7. data/lib/elftools/constants/relocation/amdgpu.rb +28 -0
  8. data/lib/elftools/constants/relocation/arm.rb +150 -0
  9. data/lib/elftools/constants/relocation/avr.rb +51 -0
  10. data/lib/elftools/constants/relocation/bfin.rb +72 -0
  11. data/lib/elftools/constants/relocation/bpf.rb +21 -0
  12. data/lib/elftools/constants/relocation/cr16.rb +46 -0
  13. data/lib/elftools/constants/relocation/cris.rb +46 -0
  14. data/lib/elftools/constants/relocation/crx.rb +35 -0
  15. data/lib/elftools/constants/relocation/csky.rb +79 -0
  16. data/lib/elftools/constants/relocation/d10v.rb +23 -0
  17. data/lib/elftools/constants/relocation/d30v.rb +27 -0
  18. data/lib/elftools/constants/relocation/dlx.rb +24 -0
  19. data/lib/elftools/constants/relocation/epiphany.rb +28 -0
  20. data/lib/elftools/constants/relocation/fr30.rb +27 -0
  21. data/lib/elftools/constants/relocation/frv.rb +57 -0
  22. data/lib/elftools/constants/relocation/ft32.rb +27 -0
  23. data/lib/elftools/constants/relocation/h8.rb +69 -0
  24. data/lib/elftools/constants/relocation/hppa.rb +135 -0
  25. data/lib/elftools/constants/relocation/i370.rb +26 -0
  26. data/lib/elftools/constants/relocation/i386.rb +59 -0
  27. data/lib/elftools/constants/relocation/i860.rb +48 -0
  28. data/lib/elftools/constants/relocation/i960.rb +22 -0
  29. data/lib/elftools/constants/relocation/ia64.rb +117 -0
  30. data/lib/elftools/constants/relocation/ip2k.rb +29 -0
  31. data/lib/elftools/constants/relocation/iq2000.rb +27 -0
  32. data/lib/elftools/constants/relocation/kvx.rb +97 -0
  33. data/lib/elftools/constants/relocation/lm32.rb +32 -0
  34. data/lib/elftools/constants/relocation/loongarch.rb +144 -0
  35. data/lib/elftools/constants/relocation/m32c.rb +27 -0
  36. data/lib/elftools/constants/relocation/m32r.rb +57 -0
  37. data/lib/elftools/constants/relocation/m68hc11.rb +35 -0
  38. data/lib/elftools/constants/relocation/m68k.rb +57 -0
  39. data/lib/elftools/constants/relocation/mcore.rb +27 -0
  40. data/lib/elftools/constants/relocation/mep.rb +36 -0
  41. data/lib/elftools/constants/relocation/metag.rb +63 -0
  42. data/lib/elftools/constants/relocation/microblaze.rb +48 -0
  43. data/lib/elftools/constants/relocation/mips.rb +125 -0
  44. data/lib/elftools/constants/relocation/mmix.rb +51 -0
  45. data/lib/elftools/constants/relocation/mn10200.rb +22 -0
  46. data/lib/elftools/constants/relocation/mn10300.rb +49 -0
  47. data/lib/elftools/constants/relocation/moxie.rb +17 -0
  48. data/lib/elftools/constants/relocation/msp430.rb +27 -0
  49. data/lib/elftools/constants/relocation/msp430x.rb +37 -0
  50. data/lib/elftools/constants/relocation/mt.rb +21 -0
  51. data/lib/elftools/constants/relocation/nds32.rb +167 -0
  52. data/lib/elftools/constants/relocation/nfp.rb +41 -0
  53. data/lib/elftools/constants/relocation/nfp3200.rb +46 -0
  54. data/lib/elftools/constants/relocation/nios2.rb +74 -0
  55. data/lib/elftools/constants/relocation/or1k.rb +69 -0
  56. data/lib/elftools/constants/relocation/pj.rb +24 -0
  57. data/lib/elftools/constants/relocation/ppc.rb +131 -0
  58. data/lib/elftools/constants/relocation/ppc64.rb +177 -0
  59. data/lib/elftools/constants/relocation/pru.rb +31 -0
  60. data/lib/elftools/constants/relocation/riscv.rb +74 -0
  61. data/lib/elftools/constants/relocation/rl78.rb +70 -0
  62. data/lib/elftools/constants/relocation/rx.rb +81 -0
  63. data/lib/elftools/constants/relocation/s12z.rb +22 -0
  64. data/lib/elftools/constants/relocation/s390.rb +82 -0
  65. data/lib/elftools/constants/relocation/score.rb +36 -0
  66. data/lib/elftools/constants/relocation/sh.rb +124 -0
  67. data/lib/elftools/constants/relocation/sparc.rb +108 -0
  68. data/lib/elftools/constants/relocation/spu.rb +32 -0
  69. data/lib/elftools/constants/relocation/tic6x.rb +48 -0
  70. data/lib/elftools/constants/relocation/tilegx.rb +134 -0
  71. data/lib/elftools/constants/relocation/tilepro.rb +105 -0
  72. data/lib/elftools/constants/relocation/v800.rb +101 -0
  73. data/lib/elftools/constants/relocation/v850.rb +66 -0
  74. data/lib/elftools/constants/relocation/vax.rb +29 -0
  75. data/lib/elftools/constants/relocation/visium.rb +30 -0
  76. data/lib/elftools/constants/relocation/wasm32.rb +16 -0
  77. data/lib/elftools/constants/relocation/x86_64.rb +68 -0
  78. data/lib/elftools/constants/relocation/xgate.rb +34 -0
  79. data/lib/elftools/constants/relocation/xstormy16.rb +29 -0
  80. data/lib/elftools/constants/relocation/xtensa.rb +75 -0
  81. data/lib/elftools/constants/relocation/z80.rb +28 -0
  82. data/lib/elftools/constants/relocation.rb +181 -0
  83. data/lib/elftools/constants.rb +168 -231
  84. data/lib/elftools/dynamic/hash_table.rb +232 -0
  85. data/lib/elftools/dynamic/string_table.rb +30 -0
  86. data/lib/elftools/dynamic/symbols.rb +174 -0
  87. data/lib/elftools/dynamic/tag.rb +66 -0
  88. data/lib/elftools/dynamic/versions.rb +87 -0
  89. data/lib/elftools/dynamic.rb +119 -62
  90. data/lib/elftools/elf_file.rb +74 -22
  91. data/lib/elftools/lazy_array.rb +42 -4
  92. data/lib/elftools/note.rb +6 -3
  93. data/lib/elftools/relative_relocations.rb +88 -0
  94. data/lib/elftools/relocation.rb +144 -0
  95. data/lib/elftools/sections/dynamic_section.rb +13 -0
  96. data/lib/elftools/sections/relative_relocation_section.rb +46 -0
  97. data/lib/elftools/sections/relocation_section.rb +24 -43
  98. data/lib/elftools/sections/section.rb +35 -4
  99. data/lib/elftools/sections/sections.rb +8 -0
  100. data/lib/elftools/sections/sym_tab_section.rb +47 -35
  101. data/lib/elftools/sections/symbol.rb +202 -0
  102. data/lib/elftools/sections/version_definition_section.rb +40 -0
  103. data/lib/elftools/sections/version_need_section.rb +40 -0
  104. data/lib/elftools/sections/version_section.rb +44 -0
  105. data/lib/elftools/segments/dynamic_segment.rb +1 -0
  106. data/lib/elftools/segments/load_segment.rb +33 -5
  107. data/lib/elftools/segments/segment.rb +8 -4
  108. data/lib/elftools/structs.rb +132 -18
  109. data/lib/elftools/util.rb +69 -12
  110. data/lib/elftools/version.rb +1 -1
  111. data/lib/elftools/version_tables.rb +155 -0
  112. metadata +108 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: baf5180fcccc876442fd65581828e91f8a362657f788a64c36ea7e2fbcd20c5a
4
- data.tar.gz: 4372260ec8fc5ca97b96e14f6413ca5126c79f716446f804974f946ee06bd09f
3
+ metadata.gz: 0213b757f8eab7a9a4806fdca95e68e8ac3f64fc226c69cf272d071def187172
4
+ data.tar.gz: 891db5a15bc0b44c09d0135a0c5b8f95633fa49b07d18e8e2a563f8384842f90
5
5
  SHA512:
6
- metadata.gz: 1c5ab262e05127590f9cf1e28cc787e63db35a8fce1a9be86a55ce2e1ec813a6044a0f68d26149ad222a1cc67ef763afdf3df219b9bf8de28095f5ac4b7e9500
7
- data.tar.gz: fea4f806def364feca723f04490f80541466d39ef7ac24fa6eb491a463baa90839d2b0bc6e1234027959abe3ec7ef6ac6874afbe8cda915570ddf6f5527e2f70
6
+ metadata.gz: 7a10ccb7a4d7b4b7c9bdc30aca01a330848ea0c9aa9a34b310e315acd5823312f413b84b9ddc72c479d3363494960abfd41b10857a34c6402fec2958ee039e64
7
+ data.tar.gz: 57902a64f1450d229bff599d7a3fac08f3f8e1f80490924a2d1b959404e90aa68880d92437a5d1a55e2d19c88ea8028c954fa209c51f6037117b4f1057e1eabb
data/README.md CHANGED
@@ -1,9 +1,10 @@
1
+ [![Downloads](https://img.shields.io/gem/dt/elftools)](https://rubygems.org/gems/elftools)
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/elftools.svg)](https://badge.fury.io/rb/elftools)
1
4
  [![Build Status](https://github.com/david942j/rbelftools/workflows/build/badge.svg)](https://github.com/david942j/rbelftools/actions)
2
- [![Code Climate](https://codeclimate.com/github/david942j/rbelftools/badges/gpa.svg)](https://codeclimate.com/github/david942j/rbelftools)
3
- [![Issue Count](https://codeclimate.com/github/david942j/rbelftools/badges/issue_count.svg)](https://codeclimate.com/github/david942j/rbelftools)
4
- [![Test Coverage](https://codeclimate.com/github/david942j/rbelftools/badges/coverage.svg)](https://codeclimate.com/github/david942j/rbelftools/coverage)
5
- [![Inline docs](https://inch-ci.org/github/david942j/rbelftools.svg?branch=master)](https://inch-ci.org/github/david942j/rbelftools)
6
- [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](https://www.rubydoc.info/github/david942j/rbelftools/)
5
+ [![Maintainability](https://qlty.sh/gh/david942j/projects/rbelftools/maintainability.svg)](https://qlty.sh/gh/david942j/projects/rbelftools)
6
+ [![Code Coverage](https://qlty.sh/gh/david942j/projects/rbelftools/coverage.svg)](https://qlty.sh/gh/david942j/projects/rbelftools)
7
+ [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](https://www.rubydoc.info/github/david942j/rbelftools/master)
7
8
  [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](http://choosealicense.com/licenses/mit/)
8
9
 
9
10
  # rbelftools
@@ -44,7 +45,7 @@ elf = ELFTools::ELFFile.new(File.open('spec/files/amd64.elf'))
44
45
  #=> #<ELFTools::ELFFile:0x00560b147f8328 @elf_class=64, @endian=:little, @stream=#<File:spec/files/amd64>>
45
46
 
46
47
  elf.machine
47
- #=> 'Advanced Micro Devices X86-64'
48
+ #=> 'Advanced Micro Devices X86-64 processor'
48
49
 
49
50
  elf.build_id
50
51
  #=> '73ab62cb7bc9959ce053c2b711322158708cdc07'
@@ -96,6 +97,117 @@ symbols.map(&:name).reject(&:empty?).first(5).join(' ')
96
97
  #=> "crtstuff.c __JCR_LIST__ deregister_tm_clones register_tm_clones __do_global_dtors_aux"
97
98
  ```
98
99
 
100
+ Where a symbol is and how large it is:
101
+ ```ruby
102
+ main = symtab_section.symbol_by_name('main')
103
+ '%#x' % main.value
104
+ #=> "0x4006dd"
105
+ main.size
106
+ #=> 142
107
+ ```
108
+
109
+ What a symbol refers to and how it is linked are recorded in `st_info` and `st_other`,
110
+ values are defined in `ELFTools::Constants::STT`, `STB`, and `STV` respectively.
111
+ ```ruby
112
+ main = symtab_section.symbol_by_name('main')
113
+ main.type == ELFTools::Constants::STT_FUNC
114
+ #=> true
115
+ main.bind == ELFTools::Constants::STB_GLOBAL
116
+ #=> true
117
+ main.visibility == ELFTools::Constants::STV_DEFAULT
118
+ #=> true
119
+
120
+ # Symbols to be resolved at runtime are not defined in any section.
121
+ symtab_section.symbol_by_name('puts@@GLIBC_2.2.5').section_index == ELFTools::Constants::SHN_UNDEF
122
+ #=> true
123
+ ```
124
+
125
+ Each of those has a name. Several constants may define one value, so naming it takes
126
+ the machine of the file, which names some of them for itself.
127
+ ```ruby
128
+ [main.type_name, main.bind_name, main.visibility_name]
129
+ #=> ["STT_FUNC", "STB_GLOBAL", "STV_DEFAULT"]
130
+
131
+ # 13 is a symbol type ARM and SPARC each define, and no one else names.
132
+ ELFTools::Constants::STT.mapping(ELFTools::Constants::EM_ARM, 13)
133
+ #=> "STT_ARM_TFUNC"
134
+ ELFTools::Constants::STT.mapping(ELFTools::Constants::EM_X86_64, 13)
135
+ #=> "<unknown>: 0xd"
136
+ ```
137
+
138
+ The symbols a file is loaded by are recorded twice, and the tags are the copy the loader
139
+ reads, so they answer even when the sections have been stripped away. Naming the symbol a
140
+ relocation points at takes nothing but the tags.
141
+ ```ruby
142
+ dynamic = elf.dynamic
143
+ dynamic.symbols.map(&:name).reject(&:empty?).first(4).join(' ')
144
+ #=> "puts __stack_chk_fail printf __libc_start_main"
145
+ dynamic.symbol_by_name('printf').type_name
146
+ #=> "STT_FUNC"
147
+ dynamic.relocations.map { |rel| dynamic.symbol_at(rel.symbol_index).name }.first(3)
148
+ #=> ["__gmon_start__", "stdin", "puts"]
149
+ ```
150
+
151
+ A symbol of a file that is loaded binds to a version of the name, which is how one file
152
+ offers `memcpy` twice and each caller keeps the one it was built against. The name is left
153
+ as the file records it.
154
+ ```ruby
155
+ dynamic.symbol_by_name('printf').version
156
+ #=> "GLIBC_2.2.5"
157
+ dynamic.symbol_by_name('__stack_chk_fail').version
158
+ #=> "GLIBC_2.4"
159
+
160
+ # What the file needs, without walking a symbol at all.
161
+ dynamic.version_requirements.map { |need| [need.file, need.versions.map(&:name)] }
162
+ #=> [["libc.so.6", ["GLIBC_2.4", "GLIBC_2.2.5"]]]
163
+
164
+ # The sections record the same, for a file that still has them.
165
+ elf.sections_by_type(:gnu_verneed).first.requirements.first.file
166
+ #=> "libc.so.6"
167
+ elf.section_by_name('.dynsym').symbol_by_name('printf').version
168
+ #=> "GLIBC_2.2.5"
169
+
170
+ # What a library defines, the first naming the library rather than a version of it.
171
+ libc = ELFTools::ELFFile.new(File.open('spec/files/libc.so.6'))
172
+ libc.dynamic.version_definitions.map(&:name).first(3)
173
+ #=> ["libc.so.6", "GLIBC_2.2.5", "GLIBC_2.2.6"]
174
+ libc.dynamic.version_definitions[2].parents
175
+ #=> ["GLIBC_2.2.5"]
176
+ ```
177
+
178
+ Nothing a file is loaded by records how large its symbol table is, because the loader
179
+ looks a name up through a hash table and jumps straight to an index rather than ever
180
+ enumerating it. `num_symbols` is therefore how far the hash table and the relocations
181
+ reach between them, which is a lower bound, while `symbol_at` is exact for any index.
182
+ ```ruby
183
+ dynamic.num_symbols
184
+ #=> 9
185
+ ```
186
+
187
+ Looking a name up is what the loader does through a hash table, rather than searching the
188
+ symbol table for it, and `symbol_by_name` does the same wherever the file records one. A
189
+ table only indexes the names a file exports, so a name it does not lead to, and a file
190
+ that records no table at all, are searched for instead.
191
+ ```ruby
192
+ libc = ELFTools::ELFFile.new(File.open('spec/files/libc.so.6'))
193
+ # Reached through DT_HASH, without reading any of the other 2244 symbols.
194
+ libc.dynamic.symbol_by_name('malloc').type_name
195
+ #=> "STT_FUNC"
196
+ ```
197
+
198
+ What a section is for is recorded in `sh_flags`, as a segment records it in `p_flags`.
199
+ ```ruby
200
+ [elf.section_by_name('.text').executable?, elf.section_by_name('.text').writable?]
201
+ #=> [true, false]
202
+
203
+ # Only some of the sections take memory while the file runs, the rest being what is
204
+ # recorded about it.
205
+ elf.sections.select(&:allocated?).map(&:name).first(5).join(' ')
206
+ #=> ".interp .note.ABI-tag .note.gnu.build-id .gnu.hash .dynsym"
207
+ elf.sections.reject(&:allocated?).map(&:name).reject(&:empty?).join(' ')
208
+ #=> ".comment .shstrtab .symtab .strtab"
209
+ ```
210
+
99
211
  ## Segments
100
212
 
101
213
  ```ruby
@@ -131,6 +243,53 @@ relocations.map { |r| symtab.symbol_at(r.symbol_index).name }
131
243
  #=> ["puts", "__stack_chk_fail", "printf", "__libc_start_main", "fgets", "scanf"]
132
244
  ```
133
245
 
246
+ Each architecture numbers relocation types on its own, so a type is named after the
247
+ machine of the file it was read from.
248
+ ```ruby
249
+ relocations.map(&:type).uniq
250
+ #=> [7]
251
+ relocations.map(&:type_name).uniq
252
+ #=> ["R_X86_64_JUMP_SLOT"]
253
+
254
+ # The very same number means something else elsewhere.
255
+ ELFTools::Constants::R::ARM::R_ARM_THM_ABS5
256
+ #=> 7
257
+ ```
258
+
259
+ A machine may also lay `r_info` out its own way. Knowing the machine is what tells
260
+ those layouts apart, so such a file reads like any other.
261
+ ```ruby
262
+ mips = ELFTools::ELFFile.new(File.open('spec/files/mips64.o'))
263
+ relocation = mips.sections_by_type(:rela).first.relocations.first
264
+ # The 64-bit MIPS ABI packs three types and a second symbol index in there.
265
+ '%x' % relocation.header.r_info
266
+ #=> "800051807"
267
+ [relocation.symbol_index, relocation.type_name]
268
+ #=> [8, "R_MIPS_GPREL16"]
269
+ ```
270
+
271
+ A relocation is recorded twice in a file that is loaded, and the tags are the copy the
272
+ loader reads, so they answer even when the sections have been stripped away.
273
+ ```ruby
274
+ elf.dynamic.relocations.size
275
+ #=> 8
276
+ elf.dynamic.relocations.map(&:type_name).uniq
277
+ #=> ["R_X86_64_GLOB_DAT", "R_X86_64_COPY", "R_X86_64_JUMP_SLOT"]
278
+ ```
279
+
280
+ Nearly every relocation of a file that is loaded only adds the load bias to a word, so a
281
+ file may pack them into a bitmap instead of spending an entry on each. They are read with
282
+ the rest, from the tags or from the section holding them, and are named after the machine
283
+ because the bitmap records no type of its own.
284
+ ```ruby
285
+ packed = ELFTools::ELFFile.new(File.open('spec/files/aarch64.relr.elf'))
286
+ packed.dynamic.relocations.count { |rel| rel.type_name == 'R_AARCH64_RELATIVE' }
287
+ #=> 132
288
+ section = packed.sections_by_type(:relr).first
289
+ [section.name, section.header.sh_size, section.num_relocations]
290
+ #=> [".relr.dyn", 48, 132]
291
+ ```
292
+
134
293
  ## Patch
135
294
 
136
295
  Patch ELF is so easy!
@@ -142,7 +301,7 @@ Invoke `elf.save(filename)` to save the patched ELF into `filename`.
142
301
  ```ruby
143
302
  elf = ELFTools::ELFFile.new(File.open('spec/files/amd64.elf'))
144
303
  elf.machine
145
- #=> "Advanced Micro Devices X86-64"
304
+ #=> "Advanced Micro Devices X86-64 processor"
146
305
  elf.header.e_machine = 40
147
306
  elf.machine
148
307
  #=> "ARM"
@@ -159,6 +318,26 @@ interp_segment.interp_name
159
318
  # save the patched ELF
160
319
  elf.save('elf.patched')
161
320
 
321
+ Values that share a byte with others, which a symbol and a relocation both record, are
322
+ assigned as what they mean rather than as the bits holding them. A value too large for
323
+ its bits is reported instead of being written over its neighbours.
324
+ ```ruby
325
+ elf = ELFTools::ELFFile.new(File.open('spec/files/amd64.elf'))
326
+ symbol = elf.section_by_name('.symtab').symbol_by_name('main')
327
+ symbol.type = ELFTools::Constants::STT_OBJECT
328
+ symbol.bind = ELFTools::Constants::STB_WEAK
329
+ [symbol.type_name, symbol.bind_name]
330
+ #=> ["STT_OBJECT", "STB_WEAK"]
331
+ symbol.bind = 16
332
+ #=> ArgumentError: Symbol binding must be in 0..15, got 16
333
+
334
+ relocation = elf.dynamic.relocations.first
335
+ relocation.symbol_index = 3
336
+ relocation.type = ELFTools::Constants::R::X86_64::R_X86_64_JUMP_SLOT
337
+ [relocation.symbol_index, relocation.type_name]
338
+ #=> [3, "R_X86_64_JUMP_SLOT"]
339
+ ```
340
+
162
341
  # in bash
163
342
  # $ file elf.patched
164
343
  # elf.patched: ELF 64-bit LSB executable, ARM, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86, for GNU...
@@ -191,6 +370,13 @@ cd rbelftools
191
370
  bundle
192
371
  bundle exec rake
193
372
  ```
373
+
374
+ Constant tables are generated from [binutils](https://sourceware.org/cgit/binutils-gdb/tree/include/elf/common.h),
375
+ regenerate them against the latest revision by
376
+ ```bash
377
+ bundle exec rake gen:constants
378
+ ```
379
+
194
380
  Any comments or suggestions are welcome!
195
381
 
196
382
  # Cross Platform
@@ -0,0 +1,248 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This file is generated by `bundle exec rake gen:constants`, do not edit it.
4
+ # Source: https://sourceware.org/cgit/binutils-gdb/tree/include/elf
5
+
6
+ module ELFTools
7
+ module Constants
8
+ # Machine architectures, records in +e_machine+.
9
+ module EM
10
+ EM_NONE = 0 # No machine
11
+ EM_M32 = 1 # AT&T WE 32100
12
+ EM_SPARC = 2 # SUN SPARC
13
+ EM_386 = 3 # Intel 80386
14
+ EM_68K = 4 # Motorola m68k family
15
+ EM_88K = 5 # Motorola m88k family
16
+ EM_IAMCU = 6 # Intel MCU
17
+ EM_860 = 7 # Intel 80860
18
+ EM_MIPS = 8 # MIPS R3000
19
+ EM_S370 = 9 # IBM System/370
20
+ EM_MIPS_RS3_LE = 10 # MIPS R3000 little-endian (Oct 4 1999 Draft). Deprecated
21
+ EM_PARISC = 15 # HPPA
22
+ EM_PPC_OLD = 17 # Old version of PowerPC. Deprecated
23
+ EM_VPP550 = 17 # Fujitsu VPP500
24
+ EM_SPARC32PLUS = 18 # Sun's "v8plus"
25
+ EM_960 = 19 # Intel 80960
26
+ EM_PPC = 20 # PowerPC
27
+ EM_PPC64 = 21 # 64-bit PowerPC
28
+ EM_S390 = 22 # IBM S/390
29
+ EM_SPU = 23 # Sony/Toshiba/IBM SPU
30
+ EM_V800 = 36 # NEC V800 series
31
+ EM_FR20 = 37 # Fujitsu FR20
32
+ EM_RH32 = 38 # TRW RH32
33
+ EM_MCORE = 39 # Motorola M*Core
34
+ EM_RCE = 39 # Old name for MCore
35
+ EM_ARM = 40 # ARM
36
+ EM_OLD_ALPHA = 41 # Digital Alpha
37
+ EM_SH = 42 # Renesas (formerly Hitachi) / SuperH SH
38
+ EM_SPARCV9 = 43 # SPARC v9 64-bit
39
+ EM_TRICORE = 44 # Siemens Tricore embedded processor
40
+ EM_ARC = 45 # ARC Cores
41
+ EM_H8_300 = 46 # Renesas (formerly Hitachi) H8/300
42
+ EM_H8_300H = 47 # Renesas (formerly Hitachi) H8/300H
43
+ EM_H8S = 48 # Renesas (formerly Hitachi) H8S
44
+ EM_H8_500 = 49 # Renesas (formerly Hitachi) H8/500
45
+ EM_IA_64 = 50 # Intel IA-64 Processor
46
+ EM_MIPS_X = 51 # Stanford MIPS-X
47
+ EM_COLDFIRE = 52 # Motorola Coldfire
48
+ EM_68HC12 = 53 # Motorola M68HC12
49
+ EM_MMA = 54 # Fujitsu Multimedia Accelerator
50
+ EM_PCP = 55 # Siemens PCP
51
+ EM_NCPU = 56 # Sony nCPU embedded RISC processor
52
+ EM_NDR1 = 57 # Denso NDR1 microprocessor
53
+ EM_STARCORE = 58 # Motorola Star*Core processor
54
+ EM_ME16 = 59 # Toyota ME16 processor
55
+ EM_ST100 = 60 # STMicroelectronics ST100 processor
56
+ EM_TINYJ = 61 # Advanced Logic Corp. TinyJ embedded processor
57
+ EM_X86_64 = 62 # Advanced Micro Devices X86-64 processor
58
+ EM_PDSP = 63 # Sony DSP Processor
59
+ EM_PDP10 = 64 # Digital Equipment Corp. PDP-10
60
+ EM_PDP11 = 65 # Digital Equipment Corp. PDP-11
61
+ EM_FX66 = 66 # Siemens FX66 microcontroller
62
+ EM_ST9PLUS = 67 # STMicroelectronics ST9+ 8/16 bit microcontroller
63
+ EM_ST7 = 68 # STMicroelectronics ST7 8-bit microcontroller
64
+ EM_68HC16 = 69 # Motorola MC68HC16 Microcontroller
65
+ EM_68HC11 = 70 # Motorola MC68HC11 Microcontroller
66
+ EM_68HC08 = 71 # Motorola MC68HC08 Microcontroller
67
+ EM_68HC05 = 72 # Motorola MC68HC05 Microcontroller
68
+ EM_SVX = 73 # Silicon Graphics SVx
69
+ EM_ST19 = 74 # STMicroelectronics ST19 8-bit cpu
70
+ EM_VAX = 75 # Digital VAX
71
+ EM_CRIS = 76 # Axis Communications 32-bit embedded processor
72
+ EM_JAVELIN = 77 # Infineon Technologies 32-bit embedded cpu
73
+ EM_FIREPATH = 78 # Element 14 64-bit DSP processor
74
+ EM_ZSP = 79 # LSI Logic's 16-bit DSP processor
75
+ EM_MMIX = 80 # Donald Knuth's educational 64-bit processor
76
+ EM_HUANY = 81 # Harvard's machine-independent format
77
+ EM_PRISM = 82 # SiTera Prism
78
+ EM_AVR = 83 # Atmel AVR 8-bit microcontroller
79
+ EM_FR30 = 84 # Fujitsu FR30
80
+ EM_D10V = 85 # Mitsubishi D10V
81
+ EM_D30V = 86 # Mitsubishi D30V
82
+ EM_V850 = 87 # Renesas V850 (formerly NEC V850)
83
+ EM_M32R = 88 # Renesas M32R (formerly Mitsubishi M32R)
84
+ EM_MN10300 = 89 # Matsushita MN10300
85
+ EM_MN10200 = 90 # Matsushita MN10200
86
+ EM_PJ = 91 # picoJava
87
+ EM_OR1K = 92 # OpenRISC 1000 32-bit embedded processor
88
+ EM_ARC_COMPACT = 93 # ARC International ARCompact processor
89
+ EM_XTENSA = 94 # Tensilica Xtensa Architecture
90
+ EM_SCORE_OLD = 95 # Old Sunplus S+core7 backend magic number. Written in the absence of an ABI
91
+ EM_VIDEOCORE = 95 # Alphamosaic VideoCore processor
92
+ EM_TMM_GPP = 96 # Thompson Multimedia General Purpose Processor
93
+ EM_NS32K = 97 # National Semiconductor 32000 series
94
+ EM_TPC = 98 # Tenor Network TPC processor
95
+ EM_PJ_OLD = 99 # Old value for picoJava. Deprecated
96
+ EM_SNP1K = 99 # Trebia SNP 1000 processor
97
+ EM_ST200 = 100 # STMicroelectronics ST200 microcontroller
98
+ EM_IP2K = 101 # Ubicom IP2022 micro controller
99
+ EM_MAX = 102 # MAX Processor
100
+ EM_CR = 103 # National Semiconductor CompactRISC
101
+ EM_F2MC16 = 104 # Fujitsu F2MC16
102
+ EM_MSP430 = 105 # TI msp430 micro controller
103
+ EM_BLACKFIN = 106 # ADI Blackfin
104
+ EM_SE_C33 = 107 # S1C33 Family of Seiko Epson processors
105
+ EM_SEP = 108 # Sharp embedded microprocessor
106
+ EM_ARCA = 109 # Arca RISC Microprocessor
107
+ EM_UNICORE = 110 # Microprocessor series from PKU-Unity Ltd. and MPRC of Peking University
108
+ EM_EXCESS = 111 # eXcess: 16/32/64-bit configurable embedded CPU
109
+ EM_DXP = 112 # Icera Semiconductor Inc. Deep Execution Processor
110
+ EM_ALTERA_NIOS2 = 113 # Altera Nios II soft-core processor
111
+ EM_CRX = 114 # National Semiconductor CRX
112
+ EM_CR16_OLD = 115 # Old, value for National Semiconductor CompactRISC. Deprecated
113
+ EM_XGATE = 115 # Motorola XGATE embedded processor
114
+ EM_C166 = 116 # Infineon C16x/XC16x processor
115
+ EM_M16C = 117 # Renesas M16C series microprocessors
116
+ EM_DSPIC30F = 118 # Microchip Technology dsPIC30F Digital Signal Controller
117
+ EM_CE = 119 # Freescale Communication Engine RISC core
118
+ EM_M32C = 120 # Renesas M32C series microprocessors
119
+ EM_TSK3000 = 131 # Altium TSK3000 core
120
+ EM_RS08 = 132 # Freescale RS08 embedded processor
121
+ EM_ECOG2 = 134 # Cyan Technology eCOG2 microprocessor
122
+ EM_SCORE = 135 # Sunplus Score
123
+ EM_SCORE7 = 135 # Sunplus S+core7 RISC processor
124
+ EM_DSP24 = 136 # New Japan Radio (NJR) 24-bit DSP Processor
125
+ EM_VIDEOCORE3 = 137 # Broadcom VideoCore III processor
126
+ EM_LATTICEMICO32 = 138 # RISC processor for Lattice FPGA architecture
127
+ EM_SE_C17 = 139 # Seiko Epson C17 family
128
+ EM_TI_C6000 = 140 # Texas Instruments TMS320C6000 DSP family
129
+ EM_TI_C2000 = 141 # Texas Instruments TMS320C2000 DSP family
130
+ EM_TI_C5500 = 142 # Texas Instruments TMS320C55x DSP family
131
+ EM_TI_PRU = 144 # Texas Instruments Programmable Realtime Unit
132
+ EM_MMDSP_PLUS = 160 # STMicroelectronics 64bit VLIW Data Signal Processor
133
+ EM_CYPRESS_M8C = 161 # Cypress M8C microprocessor
134
+ EM_R32C = 162 # Renesas R32C series microprocessors
135
+ EM_TRIMEDIA = 163 # NXP Semiconductors TriMedia architecture family
136
+ EM_QDSP6 = 164 # QUALCOMM DSP6 Processor
137
+ EM_8051 = 165 # Intel 8051 and variants
138
+ EM_STXP7X = 166 # STMicroelectronics STxP7x family
139
+ EM_NDS32 = 167 # Andes Technology compact code size embedded RISC processor family
140
+ EM_ECOG1 = 168 # Cyan Technology eCOG1X family
141
+ EM_ECOG1X = 168 # Cyan Technology eCOG1X family
142
+ EM_MAXQ30 = 169 # Dallas Semiconductor MAXQ30 Core Micro-controllers
143
+ EM_XIMO16 = 170 # New Japan Radio (NJR) 16-bit DSP Processor
144
+ EM_MANIK = 171 # M2000 Reconfigurable RISC Microprocessor
145
+ EM_CRAYNV2 = 172 # Cray Inc. NV2 vector architecture
146
+ EM_RX = 173 # Renesas RX family
147
+ EM_METAG = 174 # Imagination Technologies Meta processor architecture
148
+ EM_MCST_ELBRUS = 175 # MCST Elbrus general purpose hardware architecture
149
+ EM_ECOG16 = 176 # Cyan Technology eCOG16 family
150
+ EM_CR16 = 177 # National Semiconductor CompactRISC 16-bit processor
151
+ EM_ETPU = 178 # Freescale Extended Time Processing Unit
152
+ EM_SLE9X = 179 # Infineon Technologies SLE9X core
153
+ EM_L1OM = 180 # Intel L1OM
154
+ EM_K1OM = 181 # Intel K1OM
155
+ EM_INTEL182 = 182 # Reserved by Intel
156
+ EM_AARCH64 = 183 # ARM 64-bit architecture
157
+ EM_ARM184 = 184 # Reserved by ARM
158
+ EM_AVR32 = 185 # Atmel Corporation 32-bit microprocessor family
159
+ EM_STM8 = 186 # STMicroeletronics STM8 8-bit microcontroller
160
+ EM_TILE64 = 187 # Tilera TILE64 multicore architecture family
161
+ EM_TILEPRO = 188 # Tilera TILEPro multicore architecture family
162
+ EM_MICROBLAZE = 189 # Xilinx MicroBlaze 32-bit RISC soft processor core
163
+ EM_CUDA = 190 # NVIDIA CUDA architecture
164
+ EM_TILEGX = 191 # Tilera TILE-Gx multicore architecture family
165
+ EM_CLOUDSHIELD = 192 # CloudShield architecture family
166
+ EM_COREA_1ST = 193 # KIPO-KAIST Core-A 1st generation processor family
167
+ EM_COREA_2ND = 194 # KIPO-KAIST Core-A 2nd generation processor family
168
+ EM_ARC_COMPACT2 = 195 # Synopsys ARCompact V2
169
+ EM_OPEN8 = 196 # Open8 8-bit RISC soft processor core
170
+ EM_RL78 = 197 # Renesas RL78 family
171
+ EM_VIDEOCORE5 = 198 # Broadcom VideoCore V processor
172
+ EM_78K0R = 199 # Renesas 78K0R
173
+ EM_56800EX = 200 # Freescale 56800EX Digital Signal Controller (DSC)
174
+ EM_BA1 = 201 # Beyond BA1 CPU architecture
175
+ EM_BA2 = 202 # Beyond BA2 CPU architecture
176
+ EM_XCORE = 203 # XMOS xCORE processor family
177
+ EM_MCHP_PIC = 204 # Microchip 8-bit PIC(r) family
178
+ EM_INTELGT = 205 # Intel Graphics Technology
179
+ EM_INTEL206 = 206 # Reserved by Intel
180
+ EM_INTEL207 = 207 # Reserved by Intel
181
+ EM_INTEL208 = 208 # Reserved by Intel
182
+ EM_INTEL209 = 209 # Reserved by Intel
183
+ EM_KM32 = 210 # KM211 KM32 32-bit processor
184
+ EM_KMX32 = 211 # KM211 KMX32 32-bit processor
185
+ EM_KMX16 = 212 # KM211 KMX16 16-bit processor
186
+ EM_KMX8 = 213 # KM211 KMX8 8-bit processor
187
+ EM_KVARC = 214 # KM211 KVARC processor
188
+ EM_CDP = 215 # Paneve CDP architecture family
189
+ EM_COGE = 216 # Cognitive Smart Memory Processor
190
+ EM_COOL = 217 # Bluechip Systems CoolEngine
191
+ EM_NORC = 218 # Nanoradio Optimized RISC
192
+ EM_CSR_KALIMBA = 219 # CSR Kalimba architecture family
193
+ EM_Z80 = 220 # Zilog Z80
194
+ EM_VISIUM = 221 # Controls and Data Services VISIUMcore processor
195
+ EM_FT32 = 222 # FTDI Chip FT32 high performance 32-bit RISC architecture
196
+ EM_MOXIE = 223 # Moxie processor family
197
+ EM_AMDGPU = 224 # AMD GPU architecture
198
+ EM_RISCV = 243 # RISC-V
199
+ EM_LANAI = 244 # Lanai 32-bit processor
200
+ EM_CEVA = 245 # CEVA Processor Architecture Family
201
+ EM_CEVA_X2 = 246 # CEVA X2 Processor Family
202
+ EM_BPF = 247 # Linux BPF - in-kernel virtual machine
203
+ EM_GRAPHCORE_IPU = 248 # Graphcore Intelligent Processing Unit
204
+ EM_IMG1 = 249 # Imagination Technologies
205
+ EM_NFP = 250 # Netronome Flow Processor
206
+ EM_VE = 251 # NEC Vector Engine
207
+ EM_CSKY = 252 # C-SKY processor family
208
+ EM_ARC_COMPACT3_64 = 253 # Synopsys ARCv2.3 64-bit
209
+ EM_MCS6502 = 254 # MOS Technology MCS 6502 processor
210
+ EM_ARC_COMPACT3 = 255 # Synopsys ARCv2.3 32-bit
211
+ EM_KVX = 256 # Kalray VLIW core of the MPPA processor family
212
+ EM_65816 = 257 # WDC 65816/65C816
213
+ EM_LOONGARCH = 258 # LoongArch
214
+ EM_KF32 = 259 # ChipON KungFu32
215
+ EM_U16_U8CORE = 260 # LAPIS nX-U16/U8
216
+ EM_TACHYUM = 261 # Tachyum
217
+ EM_56800EF = 262 # NXP 56800EF Digital Signal Controller (DSC)
218
+ EM_AVR_OLD = 4183 # AVR magic number. Written in the absense of an ABI
219
+ EM_MSP430_OLD = 4185 # MSP430 magic number. Written in the absense of everything
220
+ EM_ADAPTEVA_EPIPHANY = 4643 # Adapteva's Epiphany architecture
221
+ EM_MT = 9520 # Morpho MT. Written in the absense of an ABI
222
+ EM_CYGNUS_FR30 = 13_104 # FR30 magic number - no EABI available
223
+ EM_WEBASSEMBLY = 16_727 # Unofficial value for Web Assembly binaries, as used by LLVM
224
+ EM_XC16X = 18_056 # Infineon Technologies 16-bit microcontroller with C166-V2 core
225
+ EM_S12Z = 19_951 # Freescale S12Z. The Freescale toolchain generates elf files with this value
226
+ EM_CYGNUS_FRV = 21_569 # FRV magic number - no EABI available??
227
+ EM_DLX = 23_205 # DLX magic number. Written in the absense of an ABI
228
+ EM_CYGNUS_D10V = 30_288 # D10V backend magic number. Written in the absence of an ABI
229
+ EM_CYGNUS_D30V = 30_326 # D30V backend magic number. Written in the absence of an ABI
230
+ EM_IP2K_OLD = 33_303 # Ubicom IP2xxx; Written in the absense of an ABI
231
+ EM_CYGNUS_POWERPC = 36_901 # Cygnus PowerPC ELF backend. Written in the absence of an ABI
232
+ EM_ALPHA = 36_902 # Alpha backend magic number. Written in the absence of an ABI
233
+ EM_CYGNUS_M32R = 36_929 # Cygnus M32R ELF backend. Written in the absence of an ABI
234
+ EM_CYGNUS_V850 = 36_992 # V850 backend magic number. Written in the absense of an ABI
235
+ EM_S390_OLD = 41_872 # old S/390 backend magic number. Written in the absence of an ABI
236
+ EM_XTENSA_OLD = 43_975 # Old, unofficial value for Xtensa
237
+ EM_XSTORMY16 = 44_357 # Sanyo XStormy16 CPU core
238
+ EM_MICROBLAZE_OLD = 47_787 # Old MicroBlaze
239
+ EM_CYGNUS_MN10300 = 48_879 # mn10200 and mn10300 backend magic numbers. Written in the absense of an ABI
240
+ EM_CYGNUS_MN10200 = 57_005 # mn10200 and mn10300 backend magic numbers. Written in the absense of an ABI
241
+ EM_CYGNUS_MEP = 61_453 # Toshiba MeP
242
+ EM_M32C_OLD = 65_200 # Renesas M32C and M16C
243
+ EM_IQ2000 = 65_210 # Vitesse IQ2000
244
+ EM_NIOS32 = 65_211 # NIOS magic number - no EABI available
245
+ EM_MOXIE_OLD = 65_261 # Old, unofficial value for Moxie
246
+ end
247
+ end
248
+ end