1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480(*Generated by Lem from elf_header.lem.*)(** [elf_header] includes types, functions and other definitions for working with
* ELF headers.
*)openLem_basic_classesopenLem_boolopenLem_functionopenLem_listopenLem_maybeopenLem_numopenLem_string(*import Set*)openLem_assert_extraopenDefault_printingopenEndiannessopenElf_types_native_uintopenByte_sequenceopenErroropenMissing_pervasivesopenShow(** Special section header table indices *)(** [shn_undef]: marks an undefined, missing or irrelevant section reference.
* Present here instead of in elf_section_header_table.lem because a calculation
* below requires this constant (i.e. forward reference in the ELF spec).
*)letshn_undef:Nat_big_num.num=((Nat_big_num.of_int0))(** [shn_xindex]: an escape value. It indicates the actual section header index
* is too large to fit in the containing field and is located in another
* location (specific to the structure where it appears). Present here instead
* of in elf_section_header_table.lem because a calculation below requires this
* constant (i.e. forward reference in the ELF spec).
*)letshn_xindex:Nat_big_num.num=((Nat_big_num.of_int65535))(* 0xffff *)(** ELF object file types. Enumerates the ELF object file types specified in the
* System V ABI. Values between [elf_ft_lo_os] and [elf_ft_hi_os] inclusive are
* reserved for operating system specific values typically defined in an
* addendum to the System V ABI for that operating system. Values between
* [elf_ft_lo_proc] and [elf_ft_hi_proc] inclusive are processor specific and
* are typically defined in an addendum to the System V ABI for that processor
* series.
*)(** No file type *)letelf_ft_none:Nat_big_num.num=((Nat_big_num.of_int0))(** Relocatable file *)letelf_ft_rel:Nat_big_num.num=((Nat_big_num.of_int1))(** Executable file *)letelf_ft_exec:Nat_big_num.num=((Nat_big_num.of_int2))(** Shared object file *)letelf_ft_dyn:Nat_big_num.num=((Nat_big_num.of_int3))(** Core file *)letelf_ft_core:Nat_big_num.num=((Nat_big_num.of_int4))(** Operating-system specific *)letelf_ft_lo_os:Nat_big_num.num=((Nat_big_num.of_int65024))(* 0xfe00 *)(** Operating-system specific *)letelf_ft_hi_os:Nat_big_num.num=((Nat_big_num.of_int65279))(* 0xfeff *)(** Processor specific *)letelf_ft_lo_proc:Nat_big_num.num=((Nat_big_num.of_int65280))(* 0xff00 *)(** Processor specific *)letelf_ft_hi_proc:Nat_big_num.num=((Nat_big_num.of_int65535))(* 0xffff *)(** [string_of_elf_file_type os proc m] produces a string representation of the
* numeric encoding [m] of the ELF file type. For values reserved for OS or
* processor specific values, the higher-order functions [os] and [proc] are
* used for printing, respectively.
*)(*val string_of_elf_file_type : (natural -> string) -> (natural -> string) -> natural -> string*)letstring_of_elf_file_typeos_specificproc_specificm:string=(ifNat_big_num.equalmelf_ft_nonethen"No file type"elseifNat_big_num.equalmelf_ft_relthen"REL (Relocatable file)"elseifNat_big_num.equalmelf_ft_execthen"EXEC (Executable file)"elseifNat_big_num.equalmelf_ft_dynthen"DYN (Shared object file)"elseifNat_big_num.equalmelf_ft_corethen"CORE (Core file)"elseifNat_big_num.greater_equalmelf_ft_lo_os&&Nat_big_num.less_equalmelf_ft_hi_osthenos_specificmelseifNat_big_num.greater_equalmelf_ft_lo_proc&&Nat_big_num.less_equalmelf_ft_hi_procthenproc_specificmelse"Invalid file type")(** [is_operating_specific_file_type_value] checks whether a numeric value is
* reserved by the ABI for operating system-specific purposes.
*)(*val is_operating_system_specific_object_file_type_value : natural -> bool*)letis_operating_system_specific_object_file_type_valuev:bool=(Nat_big_num.greater_equalv((Nat_big_num.of_int65024))&&Nat_big_num.less_equalv((Nat_big_num.of_int65279)))(** [is_processor_specific_file_type_value] checks whether a numeric value is
* reserved by the ABI for processor-specific purposes.
*)(*val is_processor_specific_object_file_type_value : natural -> bool*)letis_processor_specific_object_file_type_valuev:bool=(Nat_big_num.greater_equalv((Nat_big_num.of_int65280))&&Nat_big_num.less_equalv((Nat_big_num.of_int65535)))(** ELF machine architectures *)(** RISC-V *)letelf_ma_riscv:Nat_big_num.num=((Nat_big_num.of_int243))(** AMD GPU architecture *)letelf_ma_amdgpu:Nat_big_num.num=((Nat_big_num.of_int224))(** Moxie processor family *)letelf_ma_moxie:Nat_big_num.num=((Nat_big_num.of_int223))(** FTDI Chip FT32 high performance 32-bit RISC architecture *)letelf_ma_ft32:Nat_big_num.num=((Nat_big_num.of_int222))(** Controls and Data Services VISIUMcore processor *)letelf_ma_visium:Nat_big_num.num=((Nat_big_num.of_int221))(** Zilog Z80 *)letelf_ma_z80:Nat_big_num.num=((Nat_big_num.of_int220))(** CSR Kalimba architecture family *)letelf_ma_kalimba:Nat_big_num.num=((Nat_big_num.of_int219))(** Nanoradio optimised RISC *)letelf_ma_norc:Nat_big_num.num=((Nat_big_num.of_int218))(** iCelero CoolEngine *)letelf_ma_cool:Nat_big_num.num=((Nat_big_num.of_int217))(** Cognitive Smart Memory Processor *)letelf_ma_coge:Nat_big_num.num=((Nat_big_num.of_int216))(** Paneve CDP architecture family *)letelf_ma_cdp:Nat_big_num.num=((Nat_big_num.of_int215))(** KM211 KVARC processor *)letelf_ma_kvarc:Nat_big_num.num=((Nat_big_num.of_int214))(** KM211 KMX8 8-bit processor *)letelf_ma_kmx8:Nat_big_num.num=((Nat_big_num.of_int213))(** KM211 KMX16 16-bit processor *)letelf_ma_kmx16:Nat_big_num.num=((Nat_big_num.of_int212))(** KM211 KMX32 32-bit processor *)letelf_ma_kmx32:Nat_big_num.num=((Nat_big_num.of_int211))(** KM211 KM32 32-bit processor *)letelf_ma_km32:Nat_big_num.num=((Nat_big_num.of_int210))(** Microchip 8-bit PIC(r) family *)letelf_ma_mchp_pic:Nat_big_num.num=((Nat_big_num.of_int204))(** XMOS xCORE processor family *)letelf_ma_xcore:Nat_big_num.num=((Nat_big_num.of_int203))(** Beyond BA2 CPU architecture *)letelf_ma_ba2:Nat_big_num.num=((Nat_big_num.of_int202))(** Beyond BA1 CPU architecture *)letelf_ma_ba1:Nat_big_num.num=((Nat_big_num.of_int201))(** Freescale 56800EX Digital Signal Controller (DSC) *)letelf_ma_5600ex:Nat_big_num.num=((Nat_big_num.of_int200))(** 199 Renesas 78KOR family *)letelf_ma_78kor:Nat_big_num.num=((Nat_big_num.of_int199))(** Broadcom VideoCore V processor *)letelf_ma_videocore5:Nat_big_num.num=((Nat_big_num.of_int198))(** Renesas RL78 family *)letelf_ma_rl78:Nat_big_num.num=((Nat_big_num.of_int197))(** Open8 8-bit RISC soft processing core *)letelf_ma_open8:Nat_big_num.num=((Nat_big_num.of_int196))(** Synopsys ARCompact V2 *)letelf_ma_arc_compact2:Nat_big_num.num=((Nat_big_num.of_int195))(** KIPO_KAIST Core-A 2nd generation processor family *)letelf_ma_corea_2nd:Nat_big_num.num=((Nat_big_num.of_int194))(** KIPO_KAIST Core-A 1st generation processor family *)letelf_ma_corea_1st:Nat_big_num.num=((Nat_big_num.of_int193))(** CloudShield architecture family *)letelf_ma_cloudshield:Nat_big_num.num=((Nat_big_num.of_int192))(** Infineon Technologies SLE9X core *)letelf_ma_sle9x:Nat_big_num.num=((Nat_big_num.of_int179))(** Intel L10M *)letelf_ma_l10m:Nat_big_num.num=((Nat_big_num.of_int180))(** Intel K10M *)letelf_ma_k10m:Nat_big_num.num=((Nat_big_num.of_int181))(** ARM 64-bit architecture (AARCH64) *)letelf_ma_aarch64:Nat_big_num.num=((Nat_big_num.of_int183))(** Atmel Corporation 32-bit microprocessor family *)letelf_ma_avr32:Nat_big_num.num=((Nat_big_num.of_int185))(** STMicroelectronics STM8 8-bit microcontroller *)letelf_ma_stm8:Nat_big_num.num=((Nat_big_num.of_int186))(** Tilera TILE64 multicore architecture family *)letelf_ma_tile64:Nat_big_num.num=((Nat_big_num.of_int187))(** Tilera TILEPro multicore architecture family *)letelf_ma_tilepro:Nat_big_num.num=((Nat_big_num.of_int188))(** Xilinix MicroBlaze 32-bit RISC soft processor core *)letelf_ma_microblaze:Nat_big_num.num=((Nat_big_num.of_int189))(** NVIDIA CUDA architecture *)letelf_ma_cuda:Nat_big_num.num=((Nat_big_num.of_int190))(** Tilera TILE-Gx multicore architecture family *)letelf_ma_tilegx:Nat_big_num.num=((Nat_big_num.of_int191))(** Cypress M8C microprocessor *)letelf_ma_cypress:Nat_big_num.num=((Nat_big_num.of_int161))(** Renesas R32C series microprocessors *)letelf_ma_r32c:Nat_big_num.num=((Nat_big_num.of_int162))(** NXP Semiconductors TriMedia architecture family *)letelf_ma_trimedia:Nat_big_num.num=((Nat_big_num.of_int163))(** QUALCOMM DSP6 processor *)letelf_ma_qdsp6:Nat_big_num.num=((Nat_big_num.of_int164))(** Intel 8051 and variants *)letelf_ma_8051:Nat_big_num.num=((Nat_big_num.of_int165))(** STMicroelectronics STxP7x family of configurable and extensible RISC processors *)letelf_ma_stxp7x:Nat_big_num.num=((Nat_big_num.of_int166))(** Andes Technology compact code size embedded RISC processor family *)letelf_ma_nds32:Nat_big_num.num=((Nat_big_num.of_int167))(** Cyan Technology eCOG1X family *)letelf_ma_ecog1x:Nat_big_num.num=((Nat_big_num.of_int168))(** Dallas Semiconductor MAXQ30 Core Micro-controllers *)letelf_ma_maxq30:Nat_big_num.num=((Nat_big_num.of_int169))(** New Japan Radio (NJR) 16-bit DSP Processor *)letelf_ma_ximo16:Nat_big_num.num=((Nat_big_num.of_int170))(** M2000 Reconfigurable RISC Microprocessor *)letelf_ma_manik:Nat_big_num.num=((Nat_big_num.of_int171))(** Cray Inc. NV2 vector architecture *)letelf_ma_craynv2:Nat_big_num.num=((Nat_big_num.of_int172))(** Renesas RX family *)letelf_ma_rx:Nat_big_num.num=((Nat_big_num.of_int173))(** Imagination Technologies META processor architecture *)letelf_ma_metag:Nat_big_num.num=((Nat_big_num.of_int174))(** MCST Elbrus general purpose hardware architecture *)letelf_ma_mcst_elbrus:Nat_big_num.num=((Nat_big_num.of_int175))(** Cyan Technology eCOG16 family *)letelf_ma_ecog16:Nat_big_num.num=((Nat_big_num.of_int176))(** National Semiconductor CompactRISC CR16 16-bit microprocessor *)letelf_ma_cr16:Nat_big_num.num=((Nat_big_num.of_int177))(** Freescale Extended Time Processing Unit *)letelf_ma_etpu:Nat_big_num.num=((Nat_big_num.of_int178))(** Altium TSK3000 core *)letelf_ma_tsk3000:Nat_big_num.num=((Nat_big_num.of_int131))(** Freescale RS08 embedded processor *)letelf_ma_rs08:Nat_big_num.num=((Nat_big_num.of_int132))(** Analog Devices SHARC family of 32-bit DSP processors *)letelf_ma_sharc:Nat_big_num.num=((Nat_big_num.of_int133))(** Cyan Technology eCOG2 microprocessor *)letelf_ma_ecog2:Nat_big_num.num=((Nat_big_num.of_int134))(** Sunplus S+core7 RISC processor *)letelf_ma_ccore7:Nat_big_num.num=((Nat_big_num.of_int135))(** New Japan Radio (NJR) 24-bit DSP Processor *)letelf_ma_dsp24:Nat_big_num.num=((Nat_big_num.of_int136))(** Broadcom VideoCore III processor *)letelf_ma_videocore3:Nat_big_num.num=((Nat_big_num.of_int137))(** RISC processor for Lattice FPGA architecture *)letelf_ma_latticemico32:Nat_big_num.num=((Nat_big_num.of_int138))(** Seiko Epson C17 family *)letelf_ma_c17:Nat_big_num.num=((Nat_big_num.of_int139))(** The Texas Instruments TMS320C6000 DSP family *)letelf_ma_c6000:Nat_big_num.num=((Nat_big_num.of_int140))(** The Texas Instruments TMS320C2000 DSP family *)letelf_ma_c2000:Nat_big_num.num=((Nat_big_num.of_int141))(** The Texas Instruments TMS320C55x DSP family *)letelf_ma_c5500:Nat_big_num.num=((Nat_big_num.of_int142))(** STMicroelectronics 64bit VLIW Data Signal Processor *)letelf_ma_mmdsp_plus:Nat_big_num.num=((Nat_big_num.of_int160))(** LSI Logic 16-bit DSP Processor *)letelf_ma_zsp:Nat_big_num.num=((Nat_big_num.of_int79))(** Donald Knuth's educational 64-bit processor *)letelf_ma_mmix:Nat_big_num.num=((Nat_big_num.of_int80))(** Harvard University machine-independent object files *)letelf_ma_huany:Nat_big_num.num=((Nat_big_num.of_int81))(** SiTera Prism *)letelf_ma_prism:Nat_big_num.num=((Nat_big_num.of_int82))(** Atmel AVR 8-bit microcontroller *)letelf_ma_avr:Nat_big_num.num=((Nat_big_num.of_int83))(** Fujitsu FR30 *)letelf_ma_fr30:Nat_big_num.num=((Nat_big_num.of_int84))(** Mitsubishi D10V *)letelf_ma_d10v:Nat_big_num.num=((Nat_big_num.of_int85))(** Mitsubishi D30V *)letelf_ma_d30v:Nat_big_num.num=((Nat_big_num.of_int86))(** NEC v850 *)letelf_ma_v850:Nat_big_num.num=((Nat_big_num.of_int87))(** Mitsubishi M32R *)letelf_ma_m32r:Nat_big_num.num=((Nat_big_num.of_int88))(** Matsushita MN10300 *)letelf_ma_mn10300:Nat_big_num.num=((Nat_big_num.of_int89))(** Matsushita MN10200 *)letelf_ma_mn10200:Nat_big_num.num=((Nat_big_num.of_int90))(** picoJava *)letelf_ma_pj:Nat_big_num.num=((Nat_big_num.of_int91))(** OpenRISC 32-bit embedded processor *)letelf_ma_openrisc:Nat_big_num.num=((Nat_big_num.of_int92))(** ARC International ARCompact processor (old spelling/synonym: ELF_MA_ARC_A5) *)letelf_ma_arc_compact:Nat_big_num.num=((Nat_big_num.of_int93))(** Tensilica Xtensa Architecture *)letelf_ma_xtensa:Nat_big_num.num=((Nat_big_num.of_int94))(** Alphamosaic VideoCore processor *)letelf_ma_videocore:Nat_big_num.num=((Nat_big_num.of_int95))(** Thompson Multimedia General Purpose Processor *)letelf_ma_tmm_gpp:Nat_big_num.num=((Nat_big_num.of_int96))(** National Semiconductor 32000 series *)letelf_ma_ns32k:Nat_big_num.num=((Nat_big_num.of_int97))(** Tenor Network TPC processor *)letelf_ma_tpc:Nat_big_num.num=((Nat_big_num.of_int98))(** Trebia SNP 1000 processor *)letelf_ma_snp1k:Nat_big_num.num=((Nat_big_num.of_int99))(** STMicroelectronics ST200 microcontroller *)letelf_ma_st200:Nat_big_num.num=((Nat_big_num.of_int100))(** Ubicom IP2xxx microcontroller family *)letelf_ma_ip2k:Nat_big_num.num=((Nat_big_num.of_int101))(** MAX Processor *)letelf_ma_max:Nat_big_num.num=((Nat_big_num.of_int102))(** National Semiconductor CompactRISC microprocessor *)letelf_ma_cr:Nat_big_num.num=((Nat_big_num.of_int103))(** Fujitsu F2MC16 *)letelf_ma_f2mc16:Nat_big_num.num=((Nat_big_num.of_int104))(** Texas Instruments embedded microcontroller msp430 *)letelf_ma_msp430:Nat_big_num.num=((Nat_big_num.of_int105))(** Analog Devices Blackfin (DSP) processor *)letelf_ma_blackfin:Nat_big_num.num=((Nat_big_num.of_int106))(** S1C33 Family of Seiko Epson processors *)letelf_ma_se_c33:Nat_big_num.num=((Nat_big_num.of_int107))(** Sharp embedded microprocessor *)letelf_ma_sep:Nat_big_num.num=((Nat_big_num.of_int108))(** Arca RISC Microprocessor *)letelf_ma_arca:Nat_big_num.num=((Nat_big_num.of_int109))(** Microprocessor series from PKU-Unity Ltd. and MPRC of Peking University *)letelf_ma_unicore:Nat_big_num.num=((Nat_big_num.of_int110))(** eXcess: 16/32/64-bit configurable embedded CPU *)letelf_ma_excess:Nat_big_num.num=((Nat_big_num.of_int111))(** Icera Semiconductor Inc. Deep Execution Processor *)letelf_ma_dxp:Nat_big_num.num=((Nat_big_num.of_int112))(** Altera Nios II soft-core processor *)letelf_ma_altera_nios2:Nat_big_num.num=((Nat_big_num.of_int113))(** National Semiconductor CompactRISC CRX microprocessor *)letelf_ma_crx:Nat_big_num.num=((Nat_big_num.of_int114))(** Motorola XGATE embedded processor *)letelf_ma_xgate:Nat_big_num.num=((Nat_big_num.of_int115))(** Infineon C16x/XC16x processor *)letelf_ma_c166:Nat_big_num.num=((Nat_big_num.of_int116))(** Renesas M16C series microprocessors *)letelf_ma_m16c:Nat_big_num.num=((Nat_big_num.of_int117))(** Microchip Technology dsPIC30F Digital Signal Controller *)letelf_ma_dspic30f:Nat_big_num.num=((Nat_big_num.of_int118))(** Freescale Communication Engine RISC core *)letelf_ma_ce:Nat_big_num.num=((Nat_big_num.of_int119))(** Renesas M32C series microprocessors *)letelf_ma_m32c:Nat_big_num.num=((Nat_big_num.of_int120))(** No machine *)letelf_ma_none:Nat_big_num.num=((Nat_big_num.of_int0))(** AT&T WE 32100 *)letelf_ma_m32:Nat_big_num.num=((Nat_big_num.of_int1))(** SPARC *)letelf_ma_sparc:Nat_big_num.num=((Nat_big_num.of_int2))(** Intel 80386 *)letelf_ma_386:Nat_big_num.num=((Nat_big_num.of_int3))(** Motorola 68000 *)letelf_ma_68k:Nat_big_num.num=((Nat_big_num.of_int4))(** Motorola 88000 *)letelf_ma_88k:Nat_big_num.num=((Nat_big_num.of_int5))(** Intel 80860 *)letelf_ma_860:Nat_big_num.num=((Nat_big_num.of_int7))(** MIPS I Architecture *)letelf_ma_mips:Nat_big_num.num=((Nat_big_num.of_int8))(** IBM System/370 Processor *)letelf_ma_s370:Nat_big_num.num=((Nat_big_num.of_int9))(** MIPS RS3000 Little-endian *)letelf_ma_mips_rs3_le:Nat_big_num.num=((Nat_big_num.of_int10))(** Hewlett-Packard PA-RISC *)letelf_ma_parisc:Nat_big_num.num=((Nat_big_num.of_int15))(** Fujitsu VPP500 *)letelf_ma_vpp500:Nat_big_num.num=((Nat_big_num.of_int17))(** Enhanced instruction set SPARC *)letelf_ma_sparc32plus:Nat_big_num.num=((Nat_big_num.of_int18))(** Intel 80960 *)letelf_ma_960:Nat_big_num.num=((Nat_big_num.of_int19))(** PowerPC *)letelf_ma_ppc:Nat_big_num.num=((Nat_big_num.of_int20))(** 64-bit PowerPC *)letelf_ma_ppc64:Nat_big_num.num=((Nat_big_num.of_int21))(** IBM System/390 Processor *)letelf_ma_s390:Nat_big_num.num=((Nat_big_num.of_int22))(** IBM SPU/SPC *)letelf_ma_spu:Nat_big_num.num=((Nat_big_num.of_int23))(** NEC V800 *)letelf_ma_v800:Nat_big_num.num=((Nat_big_num.of_int36))(** Fujitsu FR20 *)letelf_ma_fr20:Nat_big_num.num=((Nat_big_num.of_int37))(** TRW RH-32 *)letelf_ma_rh32:Nat_big_num.num=((Nat_big_num.of_int38))(** Motorola RCE *)letelf_ma_rce:Nat_big_num.num=((Nat_big_num.of_int39))(** ARM 32-bit architecture (AARCH32) *)letelf_ma_arm:Nat_big_num.num=((Nat_big_num.of_int40))(** Digital Alpha *)letelf_ma_alpha:Nat_big_num.num=((Nat_big_num.of_int41))(** Hitachi SH *)letelf_ma_sh:Nat_big_num.num=((Nat_big_num.of_int42))(** SPARC Version 9 *)letelf_ma_sparcv9:Nat_big_num.num=((Nat_big_num.of_int43))(** Siemens TriCore embedded processor *)letelf_ma_tricore:Nat_big_num.num=((Nat_big_num.of_int44))(** Argonaut RISC Core, Argonaut Technologies Inc. *)letelf_ma_arc:Nat_big_num.num=((Nat_big_num.of_int45))(** Hitachi H8/300 *)letelf_ma_h8_300:Nat_big_num.num=((Nat_big_num.of_int46))(** Hitachi H8/300H *)letelf_ma_h8_300h:Nat_big_num.num=((Nat_big_num.of_int47))(** Hitachi H8S *)letelf_ma_h8s:Nat_big_num.num=((Nat_big_num.of_int48))(** Hitachi H8/500 *)letelf_ma_h8_500:Nat_big_num.num=((Nat_big_num.of_int49))(** Intel IA-64 processor architecture *)letelf_ma_ia_64:Nat_big_num.num=((Nat_big_num.of_int50))(** Stanford MIPS-X *)letelf_ma_mips_x:Nat_big_num.num=((Nat_big_num.of_int51))(** Motorola ColdFire *)letelf_ma_coldfire:Nat_big_num.num=((Nat_big_num.of_int52))(** Motorola M68HC12 *)letelf_ma_68hc12:Nat_big_num.num=((Nat_big_num.of_int53))(** Fujitsu MMA Multimedia Accelerator *)letelf_ma_mma:Nat_big_num.num=((Nat_big_num.of_int54))(** Siemens PCP *)letelf_ma_pcp:Nat_big_num.num=((Nat_big_num.of_int55))(** Sony nCPU embedded RISC processor *)letelf_ma_ncpu:Nat_big_num.num=((Nat_big_num.of_int56))(** Denso NDR1 microprocessor *)letelf_ma_ndr1:Nat_big_num.num=((Nat_big_num.of_int57))(** Motorola Star*Core processor *)letelf_ma_starcore:Nat_big_num.num=((Nat_big_num.of_int58))(** Toyota ME16 processor *)letelf_ma_me16:Nat_big_num.num=((Nat_big_num.of_int59))(** STMicroelectronics ST100 processor *)letelf_ma_st100:Nat_big_num.num=((Nat_big_num.of_int60))(** Advanced Logic Corp. TinyJ embedded processor family *)letelf_ma_tinyj:Nat_big_num.num=((Nat_big_num.of_int61))(** AMD x86-64 architecture *)letelf_ma_x86_64:Nat_big_num.num=((Nat_big_num.of_int62))(** Sony DSP Processor *)letelf_ma_pdsp:Nat_big_num.num=((Nat_big_num.of_int63))(** Digital Equipment Corp. PDP-10 *)letelf_ma_pdp10:Nat_big_num.num=((Nat_big_num.of_int64))(** Digital Equipment Corp. PDP-11 *)letelf_ma_pdp11:Nat_big_num.num=((Nat_big_num.of_int65))(** Siemens FX66 microcontroller *)letelf_ma_fx66:Nat_big_num.num=((Nat_big_num.of_int66))(** STMicroelectronics ST9+ 8/16 bit microcontroller *)letelf_ma_st9plus:Nat_big_num.num=((Nat_big_num.of_int67))(** STMicroelectronics ST7 8-bit microcontroller *)letelf_ma_st7:Nat_big_num.num=((Nat_big_num.of_int68))(** Motorola MC68HC16 Microcontroller *)letelf_ma_68hc16:Nat_big_num.num=((Nat_big_num.of_int69))(** Motorola MC68HC11 Microcontroller *)letelf_ma_68hc11:Nat_big_num.num=((Nat_big_num.of_int70))(** Motorola MC68HC08 Microcontroller *)letelf_ma_68hc08:Nat_big_num.num=((Nat_big_num.of_int71))(** Motorola MC68HC05 Microcontroller *)letelf_ma_68hc05:Nat_big_num.num=((Nat_big_num.of_int72))(** Silicon Graphics SVx *)letelf_ma_svx:Nat_big_num.num=((Nat_big_num.of_int73))(** STMicroelectronics ST19 8-bit microcontroller *)letelf_ma_st19:Nat_big_num.num=((Nat_big_num.of_int74))(** Digital VAX *)letelf_ma_vax:Nat_big_num.num=((Nat_big_num.of_int75))(** Axis Communications 32-bit embedded processor *)letelf_ma_cris:Nat_big_num.num=((Nat_big_num.of_int76))(** Infineon Technologies 32-bit embedded processor *)letelf_ma_javelin:Nat_big_num.num=((Nat_big_num.of_int77))(** Element 14 64-bit DSP Processor *)letelf_ma_firepath:Nat_big_num.num=((Nat_big_num.of_int78))(** Reserved by Intel *)letelf_ma_intel209:Nat_big_num.num=((Nat_big_num.of_int209))(** Reserved by Intel *)letelf_ma_intel208:Nat_big_num.num=((Nat_big_num.of_int208))(** Reserved by Intel *)letelf_ma_intel207:Nat_big_num.num=((Nat_big_num.of_int207))(** Reserved by Intel *)letelf_ma_intel206:Nat_big_num.num=((Nat_big_num.of_int206))(** Reserved by Intel *)letelf_ma_intel205:Nat_big_num.num=((Nat_big_num.of_int205))(** Reserved by Intel *)letelf_ma_intel182:Nat_big_num.num=((Nat_big_num.of_int182))(** Reserved by ARM *)letelf_ma_arm184:Nat_big_num.num=((Nat_big_num.of_int184))(** Reserved for future use *)letelf_ma_reserved6:Nat_big_num.num=((Nat_big_num.of_int6))(** Reserved for future use *)letelf_ma_reserved11:Nat_big_num.num=((Nat_big_num.of_int11))(** Reserved for future use *)letelf_ma_reserved12:Nat_big_num.num=((Nat_big_num.of_int12))(** Reserved for future use *)letelf_ma_reserved13:Nat_big_num.num=((Nat_big_num.of_int13))(** Reserved for future use *)letelf_ma_reserved14:Nat_big_num.num=((Nat_big_num.of_int14))(** Reserved for future use *)letelf_ma_reserved16:Nat_big_num.num=((Nat_big_num.of_int16))(** Reserved for future use *)letelf_ma_reserved24:Nat_big_num.num=((Nat_big_num.of_int24))(** Reserved for future use *)letelf_ma_reserved25:Nat_big_num.num=((Nat_big_num.of_int25))(** Reserved for future use *)letelf_ma_reserved26:Nat_big_num.num=((Nat_big_num.of_int26))(** Reserved for future use *)letelf_ma_reserved27:Nat_big_num.num=((Nat_big_num.of_int27))(** Reserved for future use *)letelf_ma_reserved28:Nat_big_num.num=((Nat_big_num.of_int28))(** Reserved for future use *)letelf_ma_reserved29:Nat_big_num.num=((Nat_big_num.of_int29))(** Reserved for future use *)letelf_ma_reserved30:Nat_big_num.num=((Nat_big_num.of_int30))(** Reserved for future use *)letelf_ma_reserved31:Nat_big_num.num=((Nat_big_num.of_int31))(** Reserved for future use *)letelf_ma_reserved32:Nat_big_num.num=((Nat_big_num.of_int32))(** Reserved for future use *)letelf_ma_reserved33:Nat_big_num.num=((Nat_big_num.of_int33))(** Reserved for future use *)letelf_ma_reserved34:Nat_big_num.num=((Nat_big_num.of_int34))(** Reserved for future use *)letelf_ma_reserved35:Nat_big_num.num=((Nat_big_num.of_int35))(** Reserved for future use *)letelf_ma_reserved121:Nat_big_num.num=((Nat_big_num.of_int121))(** Reserved for future use *)letelf_ma_reserved122:Nat_big_num.num=((Nat_big_num.of_int122))(** Reserved for future use *)letelf_ma_reserved123:Nat_big_num.num=((Nat_big_num.of_int123))(** Reserved for future use *)letelf_ma_reserved124:Nat_big_num.num=((Nat_big_num.of_int124))(** Reserved for future use *)letelf_ma_reserved125:Nat_big_num.num=((Nat_big_num.of_int125))(** Reserved for future use *)letelf_ma_reserved126:Nat_big_num.num=((Nat_big_num.of_int126))(** Reserved for future use *)letelf_ma_reserved127:Nat_big_num.num=((Nat_big_num.of_int127))(** Reserved for future use *)letelf_ma_reserved128:Nat_big_num.num=((Nat_big_num.of_int128))(** Reserved for future use *)letelf_ma_reserved129:Nat_big_num.num=((Nat_big_num.of_int129))(** Reserved for future use *)letelf_ma_reserved130:Nat_big_num.num=((Nat_big_num.of_int130))(** Reserved for future use *)letelf_ma_reserved143:Nat_big_num.num=((Nat_big_num.of_int143))(** Reserved for future use *)letelf_ma_reserved144:Nat_big_num.num=((Nat_big_num.of_int144))(** Reserved for future use *)letelf_ma_reserved145:Nat_big_num.num=((Nat_big_num.of_int145))(** Reserved for future use *)letelf_ma_reserved146:Nat_big_num.num=((Nat_big_num.of_int146))(** Reserved for future use *)letelf_ma_reserved147:Nat_big_num.num=((Nat_big_num.of_int147))(** Reserved for future use *)letelf_ma_reserved148:Nat_big_num.num=((Nat_big_num.of_int148))(** Reserved for future use *)letelf_ma_reserved149:Nat_big_num.num=((Nat_big_num.of_int149))(** Reserved for future use *)letelf_ma_reserved150:Nat_big_num.num=((Nat_big_num.of_int150))(** Reserved for future use *)letelf_ma_reserved151:Nat_big_num.num=((Nat_big_num.of_int151))(** Reserved for future use *)letelf_ma_reserved152:Nat_big_num.num=((Nat_big_num.of_int152))(** Reserved for future use *)letelf_ma_reserved153:Nat_big_num.num=((Nat_big_num.of_int153))(** Reserved for future use *)letelf_ma_reserved154:Nat_big_num.num=((Nat_big_num.of_int154))(** Reserved for future use *)letelf_ma_reserved155:Nat_big_num.num=((Nat_big_num.of_int155))(** Reserved for future use *)letelf_ma_reserved156:Nat_big_num.num=((Nat_big_num.of_int156))(** Reserved for future use *)letelf_ma_reserved157:Nat_big_num.num=((Nat_big_num.of_int157))(** Reserved for future use *)letelf_ma_reserved158:Nat_big_num.num=((Nat_big_num.of_int158))(** Reserved for future use *)letelf_ma_reserved159:Nat_big_num.num=((Nat_big_num.of_int159))(** [string_of_elf_machine_architecture m] produces a string representation of
* the numeric encoding [m] of the ELF machine architecture.
* TODO: finish this .
*)(*val string_of_elf_machine_architecture : natural -> string*)letstring_of_elf_machine_architecturem:string=(ifNat_big_num.equalmelf_ma_386then"Intel 80386"elseifNat_big_num.equalmelf_ma_ppcthen"PowerPC"elseifNat_big_num.equalmelf_ma_ppc64then"PowerPC64"elseifNat_big_num.equalmelf_ma_armthen"AArch"elseifNat_big_num.equalmelf_ma_x86_64then"Advanced Micro Devices X86-64"elseifNat_big_num.equalmelf_ma_aarch64then"AArch64"else"Other architecture")(** ELF version numbers. Denotes the ELF version number of an ELF file. Current is
* defined to have a value of 1 with the present specification. Extensions
* may create versions of ELF with higher version numbers.
*)(** Invalid version *)letelf_ev_none:Nat_big_num.num=((Nat_big_num.of_int0))(** Current version *)letelf_ev_current:Nat_big_num.num=((Nat_big_num.of_int1))(** [string_of_elf_version_number m] produces a string representation of the
* numeric encoding [m] of the ELF version number.
*)(*val string_of_elf_version_number : natural -> string*)letstring_of_elf_version_numberm:string=(ifNat_big_num.equalmelf_ev_nonethen"Invalid ELF version"elseifNat_big_num.equalmelf_ev_currentthen"1 (current)"else"Extended ELF version")(** Check that an extended version number is correct (i.e. greater than 1). *)letis_valid_extended_version_number(n:Nat_big_num.num):bool=(Nat_big_num.greatern((Nat_big_num.of_int1)))(** Identification indices. The initial bytes of an ELF header (and an object
* file) correspond to the e_ident member.
*)(** File identification *)letelf_ii_mag0:Nat_big_num.num=((Nat_big_num.of_int0))(** File identification *)letelf_ii_mag1:Nat_big_num.num=((Nat_big_num.of_int1))(** File identification *)letelf_ii_mag2:Nat_big_num.num=((Nat_big_num.of_int2))(** File identification *)letelf_ii_mag3:Nat_big_num.num=((Nat_big_num.of_int3))(** File class *)letelf_ii_class:Nat_big_num.num=((Nat_big_num.of_int4))(** Data encoding *)letelf_ii_data:Nat_big_num.num=((Nat_big_num.of_int5))(** File version *)letelf_ii_version:Nat_big_num.num=((Nat_big_num.of_int6))(** Operating system/ABI identification *)letelf_ii_osabi:Nat_big_num.num=((Nat_big_num.of_int7))(** ABI version *)letelf_ii_abiversion:Nat_big_num.num=((Nat_big_num.of_int8))(** Start of padding bytes *)letelf_ii_pad:Nat_big_num.num=((Nat_big_num.of_int9))(** Size of e*_ident[] *)letelf_ii_nident:Nat_big_num.num=((Nat_big_num.of_int16))(** Magic number indices. A file's first 4 bytes hold a ``magic number,''
* identifying the file as an ELF object file.
*)(** Position: e*_ident[elf_ii_mag0], 0x7f magic number *)letelf_mn_mag0:Uint32_wrapper.uint32=(Uint32_wrapper.of_bigint((Nat_big_num.of_int127)))(** Position: e*_ident[elf_ii_mag1], 'E' format identifier *)letelf_mn_mag1:Uint32_wrapper.uint32=(Uint32_wrapper.of_bigint((Nat_big_num.of_int69)))(** Position: e*_ident[elf_ii_mag2], 'L' format identifier *)letelf_mn_mag2:Uint32_wrapper.uint32=(Uint32_wrapper.of_bigint((Nat_big_num.of_int76)))(** Position: e*_ident[elf_ii_mag3], 'F' format identifier *)letelf_mn_mag3:Uint32_wrapper.uint32=(Uint32_wrapper.of_bigint((Nat_big_num.of_int70)))(** ELf file classes. The file format is designed to be portable among machines
* of various sizes, without imposing the sizes of the largest machine on the
* smallest. The class of the file defines the basic types used by the data
* structures of the object file container itself.
*)(** Invalid class *)letelf_class_none:Nat_big_num.num=((Nat_big_num.of_int0))(** 32 bit objects *)letelf_class_32:Nat_big_num.num=((Nat_big_num.of_int1))(** 64 bit objects *)letelf_class_64:Nat_big_num.num=((Nat_big_num.of_int2))(** [string_of_elf_file_class m] produces a string representation of the numeric
* encoding [m] of the ELF file class.
*)(*val string_of_elf_file_class : natural -> string*)letstring_of_elf_file_classm:string=(ifNat_big_num.equalmelf_class_nonethen"Invalid ELF file class"elseifNat_big_num.equalmelf_class_32then"ELF32"elseifNat_big_num.equalmelf_class_64then"ELF64"else"Invalid ELF file class")(** ELF data encodings. Byte e_ident[elf_ei_data] specifies the encoding of both the
* data structures used by object file container and data contained in object
* file sections.
*)(** Invalid data encoding *)letelf_data_none:Nat_big_num.num=((Nat_big_num.of_int0))(** Two's complement values, least significant byte occupying lowest address *)letelf_data_2lsb:Nat_big_num.num=((Nat_big_num.of_int1))(** Two's complement values, most significant byte occupying lowest address *)letelf_data_2msb:Nat_big_num.num=((Nat_big_num.of_int2))(** [string_of_elf_data_encoding m] produces a string representation of the
* numeric encoding [m] of the ELF data encoding.
*)(*val string_of_elf_data_encoding : natural -> string*)letstring_of_elf_data_encodingm:string=(ifNat_big_num.equalmelf_data_nonethen"Invalid data encoding"elseifNat_big_num.equalmelf_data_2lsbthen"2's complement, little endian"elseifNat_big_num.equalmelf_data_2msbthen"2's complement, big endian"else"Invalid data encoding")(** OS and ABI versions. Byte e_ident[elf_ei_osabi] identifies the OS- or
* ABI-specific ELF extensions used by this file. Some fields in other ELF
* structures have flags and values that have operating system and/or ABI
* specific meanings; the interpretation of those fields is determined by the
* value of this byte.
*)(** No extensions or unspecified *)letelf_osabi_none:Nat_big_num.num=((Nat_big_num.of_int0))(** Hewlett-Packard HP-UX *)letelf_osabi_hpux:Nat_big_num.num=((Nat_big_num.of_int1))(** NetBSD *)letelf_osabi_netbsd:Nat_big_num.num=((Nat_big_num.of_int2))(** GNU *)letelf_osabi_gnu:Nat_big_num.num=((Nat_big_num.of_int3))(** Linux, historical alias for GNU *)letelf_osabi_linux:Nat_big_num.num=((Nat_big_num.of_int3))(** Sun Solaris *)letelf_osabi_solaris:Nat_big_num.num=((Nat_big_num.of_int6))(** AIX *)letelf_osabi_aix:Nat_big_num.num=((Nat_big_num.of_int7))(** IRIX *)letelf_osabi_irix:Nat_big_num.num=((Nat_big_num.of_int8))(** FreeBSD *)letelf_osabi_freebsd:Nat_big_num.num=((Nat_big_num.of_int9))(** Compaq Tru64 Unix *)letelf_osabi_tru64:Nat_big_num.num=((Nat_big_num.of_int10))(** Novell Modesto *)letelf_osabi_modesto:Nat_big_num.num=((Nat_big_num.of_int11))(** OpenBSD *)letelf_osabi_openbsd:Nat_big_num.num=((Nat_big_num.of_int12))(** OpenVMS *)letelf_osabi_openvms:Nat_big_num.num=((Nat_big_num.of_int13))(** Hewlett-Packard Non-stop Kernel *)letelf_osabi_nsk:Nat_big_num.num=((Nat_big_num.of_int14))(** Amiga Research OS *)letelf_osabi_aros:Nat_big_num.num=((Nat_big_num.of_int15))(** FenixOS highly-scalable multi-core OS *)letelf_osabi_fenixos:Nat_big_num.num=((Nat_big_num.of_int16))(** Nuxi CloudABI *)letelf_osabi_cloudabi:Nat_big_num.num=((Nat_big_num.of_int17))(** Stratus technologies OpenVOS *)letelf_osabi_openvos:Nat_big_num.num=((Nat_big_num.of_int18))(** Checks an architecture defined OSABI version is correct, i.e. in the range
* 64 to 255 inclusive.
*)letis_valid_architecture_defined_osabi_version(n:Nat_big_num.num):bool=(Nat_big_num.greater_equaln((Nat_big_num.of_int64))&&Nat_big_num.less_equaln((Nat_big_num.of_int255)))(** [string_of_elf_osabi_version m] produces a string representation of the
* numeric encoding [m] of the ELF OSABI version.
*)(*val string_of_elf_osabi_version : (natural -> string) -> natural -> string*)letstring_of_elf_osabi_versionarchm:string=(ifNat_big_num.equalmelf_osabi_nonethen"UNIX - System V"elseifNat_big_num.equalmelf_osabi_netbsdthen"Hewlett-Packard HP-UX"elseifNat_big_num.equalmelf_osabi_netbsdthen"NetBSD"elseifNat_big_num.equalmelf_osabi_gnuthen"UNIX - GNU"elseifNat_big_num.equalmelf_osabi_linuxthen"Linux"elseifNat_big_num.equalmelf_osabi_solaristhen"Sun Solaris"elseifNat_big_num.equalmelf_osabi_aixthen"AIX"elseifNat_big_num.equalmelf_osabi_irixthen"IRIX"elseifNat_big_num.equalmelf_osabi_freebsdthen"FreeBSD"elseifNat_big_num.equalmelf_osabi_tru64then"Compaq Tru64 Unix"elseifNat_big_num.equalmelf_osabi_modestothen"Novell Modesto"elseifNat_big_num.equalmelf_osabi_openbsdthen"OpenBSD"elseifNat_big_num.equalmelf_osabi_openvmsthen"OpenVMS"elseifNat_big_num.equalmelf_osabi_nskthen"Hewlett-Packard Non-stop Kernel"elseifNat_big_num.equalmelf_osabi_arosthen"Amiga Research OS"elseifNat_big_num.equalmelf_osabi_fenixosthen"FenixOS highly-scalable multi-core OS"elseifNat_big_num.equalmelf_osabi_cloudabithen"Nuxi CloudABI"elseifNat_big_num.equalmelf_osabi_openvosthen"Stratus technologies OpenVOS"elseifis_valid_architecture_defined_osabi_versionmthenarchmelse"Invalid OSABI version")(** ELF Header type *)(** [ei_nident] is the fixed length of the identification field in the
* [elf32_ehdr] type.
*)(*val ei_nident : natural*)letei_nident:Nat_big_num.num=((Nat_big_num.of_int16))(** [elf32_header] is the type of headers for 32-bit ELF files.
*)typeelf32_header={elf32_ident:Uint32_wrapper.uint32list(** Identification field *);elf32_type:Uint32_wrapper.uint32(** The object file type *);elf32_machine:Uint32_wrapper.uint32(** Required machine architecture *);elf32_version:Uint32_wrapper.uint32(** Object file version *);elf32_entry:Uint32_wrapper.uint32(** Virtual address for transfer of control *);elf32_phoff:Uint32_wrapper.uint32(** Program header table offset in bytes *);elf32_shoff:Uint32_wrapper.uint32(** Section header table offset in bytes *);elf32_flags:Uint32_wrapper.uint32(** Processor-specific flags *);elf32_ehsize:Uint32_wrapper.uint32(** ELF header size in bytes *);elf32_phentsize:Uint32_wrapper.uint32(** Program header table entry size in bytes *);elf32_phnum:Uint32_wrapper.uint32(** Number of entries in program header table *);elf32_shentsize:Uint32_wrapper.uint32(** Section header table entry size in bytes *);elf32_shnum:Uint32_wrapper.uint32(** Number of entries in section header table *);elf32_shstrndx:Uint32_wrapper.uint32(** Section header table entry for section name string table *)}(** [elf64_header] is the type of headers for 64-bit ELF files.
*)typeelf64_header={elf64_ident:Uint32_wrapper.uint32list(** Identification field *);elf64_type:Uint32_wrapper.uint32(** The object file type *);elf64_machine:Uint32_wrapper.uint32(** Required machine architecture *);elf64_version:Uint32_wrapper.uint32(** Object file version *);elf64_entry:Uint64_wrapper.uint64(** Virtual address for transfer of control *);elf64_phoff:Uint64_wrapper.uint64(** Program header table offset in bytes *);elf64_shoff:Uint64_wrapper.uint64(** Section header table offset in bytes *);elf64_flags:Uint32_wrapper.uint32(** Processor-specific flags *);elf64_ehsize:Uint32_wrapper.uint32(** ELF header size in bytes *);elf64_phentsize:Uint32_wrapper.uint32(** Program header table entry size in bytes *);elf64_phnum:Uint32_wrapper.uint32(** Number of entries in program header table *);elf64_shentsize:Uint32_wrapper.uint32(** Section header table entry size in bytes *);elf64_shnum:Uint32_wrapper.uint32(** Number of entries in section header table *);elf64_shstrndx:Uint32_wrapper.uint32(** Section header table entry for section name string table *)}(** [is_valid_elf32_header hdr] checks whether header [hdr] is valid, i.e. has
* the correct magic numbers.
* TODO: this should be expanded, presumably, or merged with some of the other
* checks.
*)(*val is_valid_elf32_header : elf32_header -> bool*)letis_valid_elf32_headerhdr:bool=(listEqualBy(=)(Lem_list.take4hdr.elf32_ident)[elf_mn_mag0;elf_mn_mag1;elf_mn_mag2;elf_mn_mag3])(** [is_valid_elf64_header hdr] checks whether header [hdr] is valid, i.e. has
* the correct magic numbers.
* TODO: this should be expanded, presumably, or merged with some of the other
* checks.
*)(*val is_valid_elf64_header : elf64_header -> bool*)letis_valid_elf64_headerhdr:bool=(listEqualBy(=)(Lem_list.take4hdr.elf64_ident)[elf_mn_mag0;elf_mn_mag1;elf_mn_mag2;elf_mn_mag3])(** [elf32_header_compare hdr1 hdr2] is an ordering comparison function for
* ELF headers suitable for use in sets, finite maps and other ordered
* data types.
*)(*val elf32_header_compare : elf32_header -> elf32_header -> Basic_classes.ordering*)letelf32_header_compareh1h2:int=(pairCompare(lexicographic_compareNat_big_num.compare)(lexicographic_compareNat_big_num.compare)(Lem_list.mapUint32_wrapper.to_biginth1.elf32_ident,[Uint32_wrapper.to_biginth1.elf32_type;Uint32_wrapper.to_biginth1.elf32_machine;Uint32_wrapper.to_biginth1.elf32_version;Uint32_wrapper.to_biginth1.elf32_entry;Uint32_wrapper.to_biginth1.elf32_phoff;Uint32_wrapper.to_biginth1.elf32_shoff;Uint32_wrapper.to_biginth1.elf32_flags;Uint32_wrapper.to_biginth1.elf32_ehsize;Uint32_wrapper.to_biginth1.elf32_phentsize;Uint32_wrapper.to_biginth1.elf32_phnum;Uint32_wrapper.to_biginth1.elf32_shentsize;Uint32_wrapper.to_biginth1.elf32_shnum;Uint32_wrapper.to_biginth1.elf32_shstrndx])(Lem_list.mapUint32_wrapper.to_biginth2.elf32_ident,[Uint32_wrapper.to_biginth2.elf32_type;Uint32_wrapper.to_biginth2.elf32_machine;Uint32_wrapper.to_biginth2.elf32_version;Uint32_wrapper.to_biginth2.elf32_entry;Uint32_wrapper.to_biginth2.elf32_phoff;Uint32_wrapper.to_biginth2.elf32_shoff;Uint32_wrapper.to_biginth2.elf32_flags;Uint32_wrapper.to_biginth2.elf32_ehsize;Uint32_wrapper.to_biginth2.elf32_phentsize;Uint32_wrapper.to_biginth2.elf32_phnum;Uint32_wrapper.to_biginth2.elf32_shentsize;Uint32_wrapper.to_biginth2.elf32_shnum;Uint32_wrapper.to_biginth2.elf32_shstrndx]))letinstance_Basic_classes_Ord_Elf_header_elf32_header_dict:(elf32_header)ord_class=({compare_method=elf32_header_compare;isLess_method=(funf1->(funf2->(Lem.orderingEqual(elf32_header_comparef1f2)(-1))));isLessEqual_method=(funf1->(funf2->Pset.mem(elf32_header_comparef1f2)(Pset.from_listcompare[(-1);0])));isGreater_method=(funf1->(funf2->(Lem.orderingEqual(elf32_header_comparef1f2)1)));isGreaterEqual_method=(funf1->(funf2->Pset.mem(elf32_header_comparef1f2)(Pset.from_listcompare[1;0])))})(** [elf64_header_compare hdr1 hdr2] is an ordering comparison function for
* ELF headers suitable for use in sets, finite maps and other ordered
* data types.
*)(*val elf64_header_compare : elf64_header -> elf64_header -> Basic_classes.ordering*)letelf64_header_compareh1h2:int=(pairCompare(lexicographic_compareNat_big_num.compare)(lexicographic_compareNat_big_num.compare)(Lem_list.mapUint32_wrapper.to_biginth1.elf64_ident,[Uint32_wrapper.to_biginth1.elf64_type;Uint32_wrapper.to_biginth1.elf64_machine;Uint32_wrapper.to_biginth1.elf64_version;Ml_bindings.nat_big_num_of_uint64h1.elf64_entry;Uint64_wrapper.to_biginth1.elf64_phoff;Uint64_wrapper.to_biginth1.elf64_shoff;Uint32_wrapper.to_biginth1.elf64_flags;Uint32_wrapper.to_biginth1.elf64_ehsize;Uint32_wrapper.to_biginth1.elf64_phentsize;Uint32_wrapper.to_biginth1.elf64_phnum;Uint32_wrapper.to_biginth1.elf64_shentsize;Uint32_wrapper.to_biginth1.elf64_shnum;Uint32_wrapper.to_biginth1.elf64_shstrndx])(Lem_list.mapUint32_wrapper.to_biginth2.elf64_ident,[Uint32_wrapper.to_biginth2.elf64_type;Uint32_wrapper.to_biginth2.elf64_machine;Uint32_wrapper.to_biginth2.elf64_version;Ml_bindings.nat_big_num_of_uint64h2.elf64_entry;Uint64_wrapper.to_biginth2.elf64_phoff;Uint64_wrapper.to_biginth2.elf64_shoff;Uint32_wrapper.to_biginth2.elf64_flags;Uint32_wrapper.to_biginth2.elf64_ehsize;Uint32_wrapper.to_biginth2.elf64_phentsize;Uint32_wrapper.to_biginth2.elf64_phnum;Uint32_wrapper.to_biginth2.elf64_shentsize;Uint32_wrapper.to_biginth2.elf64_shnum;Uint32_wrapper.to_biginth2.elf64_shstrndx]))letinstance_Basic_classes_Ord_Elf_header_elf64_header_dict:(elf64_header)ord_class=({compare_method=elf64_header_compare;isLess_method=(funf1->(funf2->(Lem.orderingEqual(elf64_header_comparef1f2)(-1))));isLessEqual_method=(funf1->(funf2->Pset.mem(elf64_header_comparef1f2)(Pset.from_listcompare[(-1);0])));isGreater_method=(funf1->(funf2->(Lem.orderingEqual(elf64_header_comparef1f2)1)));isGreaterEqual_method=(funf1->(funf2->Pset.mem(elf64_header_comparef1f2)(Pset.from_listcompare[1;0])))})(** [is_elf32_executable_file hdr] checks whether the header [hdr] states if the
* ELF file is of executable type.
*)(*val is_elf32_executable_file : elf32_header -> bool*)letis_elf32_executable_filehdr:bool=(Nat_big_num.equal(Uint32_wrapper.to_biginthdr.elf32_type)elf_ft_exec)(** [is_elf64_executable_file hdr] checks whether the header [hdr] states if the
* ELF file is of executable type.
*)(*val is_elf64_executable_file : elf64_header -> bool*)letis_elf64_executable_filehdr:bool=(* hack *)true(*natural_of_elf64_half hdr.elf64_type = elf_ft_exec*)(** [is_elf32_shared_object_file hdr] checks whether the header [hdr] states if the
* ELF file is of shared object type.
*)(*val is_elf32_shared_object_file : elf32_header -> bool*)letis_elf32_shared_object_filehdr:bool=(Nat_big_num.equal(Uint32_wrapper.to_biginthdr.elf32_type)elf_ft_dyn)(** [is_elf64_shared_object_file hdr] checks whether the header [hdr] states if the
* ELF file is of shared object type.
*)(*val is_elf64_shared_object_file : elf64_header -> bool*)letis_elf64_shared_object_filehdr:bool=(Nat_big_num.equal(Uint32_wrapper.to_biginthdr.elf64_type)elf_ft_dyn)(** [is_elf32_relocatable_file hdr] checks whether the header [hdr] states if the
* ELF file is of relocatable type.
*)(*val is_elf32_relocatable_file : elf32_header -> bool*)letis_elf32_relocatable_filehdr:bool=(Nat_big_num.equal(Uint32_wrapper.to_biginthdr.elf32_type)elf_ft_rel)(** [is_elf64_relocatable_file hdr] checks whether the header [hdr] states if the
* ELF file is of relocatable type.
*)(*val is_elf64_relocatable_file : elf64_header -> bool*)letis_elf64_relocatable_filehdr:bool=(Nat_big_num.equal(Uint32_wrapper.to_biginthdr.elf64_type)elf_ft_rel)(** [is_elf32_linkable_file hdr] checks whether the header [hdr] states if the
* ELF file is of linkable (shared object or relocatable) type.
*)(*val is_elf32_linkable_file : elf32_header -> bool*)letis_elf32_linkable_filehdr:bool=(is_elf32_shared_object_filehdr||is_elf32_relocatable_filehdr)(** [is_elf64_linkable_file hdr] checks whether the header [hdr] states if the
* ELF file is of linkable (shared object or relocatable) type.
*)(*val is_elf64_linkable_file : elf64_header -> bool*)letis_elf64_linkable_filehdr:bool=(is_elf64_shared_object_filehdr||is_elf64_relocatable_filehdr)(** [get_elf32_machine_architecture hdr] returns the ELF file's declared machine
* architecture, extracting the information from header [hdr].
*)(*val get_elf32_machine_architecture : elf32_header -> natural*)letget_elf32_machine_architecturehdr:Nat_big_num.num=(Uint32_wrapper.to_biginthdr.elf32_machine)(** [get_elf64_machine_architecture hdr] returns the ELF file's declared machine
* architecture, extracting the information from header [hdr].
*)(*val get_elf64_machine_architecture : elf64_header -> natural*)letget_elf64_machine_architecturehdr:Nat_big_num.num=(Uint32_wrapper.to_biginthdr.elf64_machine)(** [get_elf32_osabi hdr] returns the ELF file's declared OS/ABI
* architecture, extracting the information from header [hdr].
*)(*val get_elf32_osabi : elf32_header -> natural*)letget_elf32_osabihdr:Nat_big_num.num=((matchLem_list.list_indexhdr.elf32_ident(Nat_big_num.to_intelf_ii_osabi)with|Someosabi->Uint32_wrapper.to_bigintosabi|None->failwith"get_elf32_osabi: lookup in ident failed"))(* Partial: should never return Nothing *)(** [get_elf64_osabi hdr] returns the ELF file's declared OS/ABI
* architecture, extracting the information from header [hdr].
*)(*val get_elf64_osabi : elf64_header -> natural*)letget_elf64_osabihdr:Nat_big_num.num=((matchLem_list.list_indexhdr.elf64_ident(Nat_big_num.to_intelf_ii_osabi)with|Someosabi->Uint32_wrapper.to_bigintosabi|None->failwith"get_elf64_osabi: lookup in ident failed"))(* Partial: should never return Nothing *)(** [get_elf32_data_encoding hdr] returns the ELF file's declared data
* encoding, extracting the information from header [hdr].
*)(*val get_elf32_data_encoding : elf32_header -> natural*)letget_elf32_data_encodinghdr:Nat_big_num.num=((matchLem_list.list_indexhdr.elf32_ident(Nat_big_num.to_intelf_ii_data)with|Somedata->Uint32_wrapper.to_bigintdata|None->failwith"get_elf32_data_encoding: lookup in ident failed"))(* Partial: should never return Nothing *)(** [get_elf64_data_encoding hdr] returns the ELF file's declared data
* encoding, extracting the information from header [hdr].
*)(*val get_elf64_data_encoding : elf64_header -> natural*)letget_elf64_data_encodinghdr:Nat_big_num.num=((matchLem_list.list_indexhdr.elf64_ident(Nat_big_num.to_intelf_ii_data)with|Somedata->Uint32_wrapper.to_bigintdata|None->failwith"get_elf64_data_encoding: lookup in ident failed"))(* Partial: should never return Nothing *)(** [get_elf32_file_class hdr] returns the ELF file's declared file
* class, extracting the information from header [hdr].
*)(*val get_elf32_file_class : elf32_header -> natural*)letget_elf32_file_classhdr:Nat_big_num.num=((matchLem_list.list_indexhdr.elf32_ident(Nat_big_num.to_intelf_ii_class)with|Somecls->Uint32_wrapper.to_bigintcls|None->failwith"get_elf32_file_class: lookup in ident failed"))(* Partial: should never return Nothing *)(** [get_elf64_file_class hdr] returns the ELF file's declared file
* class, extracting the information from header [hdr].
*)(*val get_elf64_file_class : elf64_header -> natural*)letget_elf64_file_classhdr:Nat_big_num.num=((matchLem_list.list_indexhdr.elf64_ident(Nat_big_num.to_intelf_ii_class)with|Somecls->Uint32_wrapper.to_bigintcls|None->failwith"get_elf64_file_class: lookup in ident failed"))(* Partial: should never return Nothing *)(** [get_elf32_version_number hdr] returns the ELF file's declared version
* number, extracting the information from header [hdr].
*)(*val get_elf32_version_number : elf32_header -> natural*)letget_elf32_version_numberhdr:Nat_big_num.num=((matchLem_list.list_indexhdr.elf32_ident(Nat_big_num.to_intelf_ii_version)with|Somever->Uint32_wrapper.to_bigintver|None->failwith"get_elf32_version_number: lookup in ident failed"))(* Partial: should never return Nothing *)(** [get_elf64_version_number hdr] returns the ELF file's declared version
* number, extracting the information from header [hdr].
*)(*val get_elf64_version_number : elf64_header -> natural*)letget_elf64_version_numberhdr:Nat_big_num.num=((matchLem_list.list_indexhdr.elf64_ident(Nat_big_num.to_intelf_ii_version)with|Somever->Uint32_wrapper.to_bigintver|None->failwith"get_elf64_version_number: lookup in ident failed"))(* Partial: should never return Nothing *)(** [is_valid_elf32_version_number hdr] checks whether an ELF file's declared
* version number matches the current, mandatory version number.
* TODO: this should be merged into [is_valid_elf32_header] to create a single
* correctness check.
*)(*val is_valid_elf32_version_number : elf32_header -> bool*)letis_valid_elf32_version_numerhdr:bool=(Nat_big_num.equal(get_elf32_version_numberhdr)elf_ev_current)(** [is_valid_elf64_version_number hdr] checks whether an ELF file's declared
* version number matches the current, mandatory version number.
* TODO: this should be merged into [is_valid_elf64_header] to create a single
* correctness check.
*)(*val is_valid_elf64_version_number : elf64_header -> bool*)letis_valid_elf64_version_numerhdr:bool=(Nat_big_num.equal(get_elf64_version_numberhdr)elf_ev_current)(** [get_elf32_abi_version hdr] returns the ELF file's declared ABI version
* number, extracting the information from header [hdr].
*)(*val get_elf32_abi_version : elf32_header -> natural*)letget_elf32_abi_versionhdr:Nat_big_num.num=((matchLem_list.list_indexhdr.elf32_ident(Nat_big_num.to_intelf_ii_abiversion)with|Somever->Uint32_wrapper.to_bigintver|None->failwith"get_elf32_abi_version: lookup in ident failed"))(* Partial: should never return Nothing *)(** [get_elf64_abi_version hdr] returns the ELF file's declared ABI version
* number, extracting the information from header [hdr].
*)(*val get_elf64_abi_version : elf64_header -> natural*)letget_elf64_abi_versionhdr:Nat_big_num.num=((matchLem_list.list_indexhdr.elf64_ident(Nat_big_num.to_intelf_ii_abiversion)with|Somever->Uint32_wrapper.to_bigintver|None->failwith"get_elf64_abi_version: lookup in ident failed"))(* Partial: should never return Nothing *)(** [deduce_endianness uc] deduces the endianness of an ELF file based on the ELF
* header's magic number [uc].
*)(*val deduce_endianness : list unsigned_char -> endianness*)letdeduce_endiannessid2:endianness=((matchLem_list.list_indexid25with|None->failwith"deduce_endianness: read of magic number has failed"|Somev->ifNat_big_num.equal(Uint32_wrapper.to_bigintv)elf_data_2lsbthenLittleelseifNat_big_num.equal(Uint32_wrapper.to_bigintv)elf_data_2msbthenBigelsefailwith"deduce_endianness: value is not valid"))(** [get_elf32_header_endianness hdr] returns the endianness of the ELF file
* as declared in its header, [hdr].
*)(*val get_elf32_header_endianness : elf32_header -> endianness*)letget_elf32_header_endiannesshdr:endianness=(deduce_endianness(hdr.elf32_ident))(** [get_elf64_header_endianness hdr] returns the endianness of the ELF file
* as declared in its header, [hdr].
*)(*val get_elf64_header_endianness : elf64_header -> endianness*)letget_elf64_header_endiannesshdr:endianness=(deduce_endianness(hdr.elf64_ident))(** [has_elf32_header_associated_entry_point hdr] checks whether the header
* [hdr] declares an entry point for the program.
*)(*val has_elf32_header_associated_entry_point : elf32_header -> bool*)lethas_elf32_header_associated_entry_pointhdr:bool=(not(Nat_big_num.equal(Uint32_wrapper.to_biginthdr.elf32_entry)((Nat_big_num.of_int0))))(** [has_elf64_header_associated_entry_point hdr] checks whether the header
* [hdr] declares an entry point for the program.
*)(*val has_elf64_header_associated_entry_point : elf64_header -> bool*)lethas_elf64_header_associated_entry_pointhdr:bool=(not(Nat_big_num.equal(Ml_bindings.nat_big_num_of_uint64hdr.elf64_entry)((Nat_big_num.of_int0))))(** [has_elf32_header_string_table hdr] checks whether the header
* [hdr] declares whether the program has a string table or not.
*)(*val has_elf32_header_string_table : elf32_header -> bool*)lethas_elf32_header_string_tablehdr:bool=(not(Nat_big_num.equal(Uint32_wrapper.to_biginthdr.elf32_shstrndx)shn_undef))(** [has_elf64_header_string_table hdr] checks whether the header
* [hdr] declares whether the program has a string table or not.
*)(*val has_elf64_header_string_table : elf64_header -> bool*)lethas_elf64_header_string_tablehdr:bool=(not(Nat_big_num.equal(Uint32_wrapper.to_biginthdr.elf64_shstrndx)shn_undef))(** [is_elf32_header_section_size_in_section_header_table hdr] checks whether the header
* [hdr] declares whether the section size is too large to fit in the header
* field and is instead stored in the section header table.
*)(*val is_elf32_header_section_size_in_section_header_table : elf32_header -> bool*)letis_elf32_header_section_size_in_section_header_tablehdr:bool=(Nat_big_num.equal(Uint32_wrapper.to_biginthdr.elf32_shnum)((Nat_big_num.of_int0)))(** [is_elf64_header_section_size_in_section_header_table hdr] checks whether the header
* [hdr] declares whether the section size is too large to fit in the header
* field and is instead stored in the section header table.
*)(*val is_elf64_header_section_size_in_section_header_table : elf64_header -> bool*)letis_elf64_header_section_size_in_section_header_tablehdr:bool=(Nat_big_num.equal(Uint32_wrapper.to_biginthdr.elf64_shnum)((Nat_big_num.of_int0)))(** [is_elf32_header_string_table_index_in_link hdr] checks whether the header
* [hdr] declares whether the string table index is too large to fit in the
* header's field and is instead stored in the link field of an entry in the
* section header table.
*)(*val is_elf32_header_string_table_index_in_link : elf32_header -> bool*)letis_elf32_header_string_table_index_in_linkhdr:bool=(Nat_big_num.equal(Uint32_wrapper.to_biginthdr.elf32_shstrndx)shn_xindex)(** [is_elf64_header_string_table_index_in_link hdr] checks whether the header
* [hdr] declares whether the string table index is too large to fit in the
* header's field and is instead stored in the link field of an entry in the
* section header table.
*)(*val is_elf64_header_string_table_index_in_link : elf64_header -> bool*)letis_elf64_header_string_table_index_in_linkhdr:bool=(Nat_big_num.equal(Uint32_wrapper.to_biginthdr.elf64_shstrndx)shn_xindex)(** The [hdr_print_bundle] type is used to tidy up other type signatures. Some of the
* top-level string_of_ functions require six or more functions passed to them,
* which quickly gets out of hand. This type is used to reduce that complexity.
* The first component of the type is an OS specific print function, the second is
* a processor specific print function.
*)typehdr_print_bundle=(Nat_big_num.num->string)*(Nat_big_num.num->string)(** [string_of_elf32_header hdr_bdl hdr] returns a string-based representation
* of header [hdr] using the ABI-specific print bundle [hdr_bdl].
*)(*val string_of_elf32_header : hdr_print_bundle -> elf32_header -> string*)letstring_of_elf32_header(os,proc)hdr:string=(unlines[("\t"^("Magic number: "^string_of_listinstance_Show_Show_Elf_types_native_uint_unsigned_char_dicthdr.elf32_ident));("\t"^("Endianness: "^string_of_endianness(deduce_endiannesshdr.elf32_ident)));("\t"^("Type: "^string_of_elf_file_typeosproc(Uint32_wrapper.to_biginthdr.elf32_type)));("\t"^("Version: "^string_of_elf_version_number(Uint32_wrapper.to_biginthdr.elf32_version)));("\t"^("Machine: "^string_of_elf_machine_architecture(Uint32_wrapper.to_biginthdr.elf32_machine)));("\t"^("Entry point: "^Uint32_wrapper.to_stringhdr.elf32_entry));("\t"^("Flags: "^Uint32_wrapper.to_stringhdr.elf32_flags));("\t"^("Entries in program header table: "^Uint32_wrapper.to_stringhdr.elf32_phnum));("\t"^("Entries in section header table: "^Uint32_wrapper.to_stringhdr.elf32_shnum))])(** [string_of_elf64_header hdr_bdl hdr] returns a string-based representation
* of header [hdr] using the ABI-specific print bundle [hdr_bdl].
*)(*val string_of_elf64_header : hdr_print_bundle -> elf64_header -> string*)letstring_of_elf64_header(os,proc)hdr:string=(unlines[("\t"^("Magic number: "^string_of_listinstance_Show_Show_Elf_types_native_uint_unsigned_char_dicthdr.elf64_ident));("\t"^("Endianness: "^string_of_endianness(deduce_endiannesshdr.elf64_ident)));("\t"^("Type: "^string_of_elf_file_typeosproc(Uint32_wrapper.to_biginthdr.elf64_type)));("\t"^("Version: "^string_of_elf_version_number(Uint32_wrapper.to_biginthdr.elf64_version)));("\t"^("Machine: "^string_of_elf_machine_architecture(Uint32_wrapper.to_biginthdr.elf64_machine)));("\t"^("Entry point: "^Uint64_wrapper.to_stringhdr.elf64_entry));("\t"^("Flags: "^Uint32_wrapper.to_stringhdr.elf64_flags));("\t"^("Entries in program header table: "^Uint32_wrapper.to_stringhdr.elf64_phnum));("\t"^("Entries in section header table: "^Uint32_wrapper.to_stringhdr.elf64_shnum))])(** The following are thin wrappers around the pretty-printing functions above
* using a default print bundle for the header.
*)(*val string_of_elf32_header_default : elf32_header -> string*)letstring_of_elf32_header_default:elf32_header->string=(string_of_elf32_header(default_os_specific_print,default_proc_specific_print))(*val string_of_elf64_header_default : elf64_header -> string*)letstring_of_elf64_header_default:elf64_header->string=(string_of_elf64_header(default_os_specific_print,default_proc_specific_print))letinstance_Show_Show_Elf_header_elf32_header_dict:(elf32_header)show_class=({show_method=string_of_elf32_header_default})letinstance_Show_Show_Elf_header_elf64_header_dict:(elf64_header)show_class=({show_method=string_of_elf64_header_default})(** [read_elf_ident bs0] reads the initial bytes of an ELF file from byte sequence
* [bs0], returning the remainder of the byte sequence too.
* Fails if transcription fails.
*)(*val read_elf_ident : byte_sequence -> error (list unsigned_char * byte_sequence)*)letread_elf_identbs:((Uint32_wrapper.uint32)list*Byte_sequence_wrapper.byte_sequence)error=(repeatM'ei_nidentbs(read_unsigned_chardefault_endianness))(** [bytes_of_elf32_header hdr] blits an ELF header [hdr] to a byte sequence,
* ready for transcription to a binary file.
*)(*val bytes_of_elf32_header : elf32_header -> byte_sequence*)letbytes_of_elf32_headerhdr:Byte_sequence_wrapper.byte_sequence=(letendian=(deduce_endiannesshdr.elf32_ident)inByte_sequence.from_byte_lists[Lem_list.map(funu->Char.chr(Uint32_wrapper.to_intu))hdr.elf32_ident;bytes_of_elf32_halfendianhdr.elf32_type;bytes_of_elf32_halfendianhdr.elf32_machine;bytes_of_elf32_wordendianhdr.elf32_version;bytes_of_elf32_addrendianhdr.elf32_entry;bytes_of_elf32_offendianhdr.elf32_phoff;bytes_of_elf32_offendianhdr.elf32_shoff;bytes_of_elf32_wordendianhdr.elf32_flags;bytes_of_elf32_halfendianhdr.elf32_ehsize;bytes_of_elf32_halfendianhdr.elf32_phentsize;bytes_of_elf32_halfendianhdr.elf32_phnum;bytes_of_elf32_halfendianhdr.elf32_shentsize;bytes_of_elf32_halfendianhdr.elf32_shnum;bytes_of_elf32_halfendianhdr.elf32_shstrndx])(** [bytes_of_elf64_header hdr] blits an ELF header [hdr] to a byte sequence,
* ready for transcription to a binary file.
*)(*val bytes_of_elf64_header : elf64_header -> byte_sequence*)letbytes_of_elf64_headerhdr:Byte_sequence_wrapper.byte_sequence=(letendian=(deduce_endiannesshdr.elf64_ident)inByte_sequence.from_byte_lists[Lem_list.map(funu->Char.chr(Uint32_wrapper.to_intu))hdr.elf64_ident;bytes_of_elf64_halfendianhdr.elf64_type;bytes_of_elf64_halfendianhdr.elf64_machine;bytes_of_elf64_wordendianhdr.elf64_version;bytes_of_elf64_addrendianhdr.elf64_entry;bytes_of_elf64_offendianhdr.elf64_phoff;bytes_of_elf64_offendianhdr.elf64_shoff;bytes_of_elf64_wordendianhdr.elf64_flags;bytes_of_elf64_halfendianhdr.elf64_ehsize;bytes_of_elf64_halfendianhdr.elf64_phentsize;bytes_of_elf64_halfendianhdr.elf64_phnum;bytes_of_elf64_halfendianhdr.elf64_shentsize;bytes_of_elf64_halfendianhdr.elf64_shnum;bytes_of_elf64_halfendianhdr.elf64_shstrndx])(*val is_elf32_header_padding_correct : elf32_header -> bool*)letis_elf32_header_padding_correctehdr:bool=((Lem.option_equal(=)(Lem_list.list_indexehdr.elf32_ident9)(Some(Uint32_wrapper.of_bigint((Nat_big_num.of_int0)))))&&((Lem.option_equal(=)(Lem_list.list_indexehdr.elf32_ident10)(Some(Uint32_wrapper.of_bigint((Nat_big_num.of_int0)))))&&((Lem.option_equal(=)(Lem_list.list_indexehdr.elf32_ident11)(Some(Uint32_wrapper.of_bigint((Nat_big_num.of_int0)))))&&((Lem.option_equal(=)(Lem_list.list_indexehdr.elf32_ident12)(Some(Uint32_wrapper.of_bigint((Nat_big_num.of_int0)))))&&((Lem.option_equal(=)(Lem_list.list_indexehdr.elf32_ident13)(Some(Uint32_wrapper.of_bigint((Nat_big_num.of_int0)))))&&((Lem.option_equal(=)(Lem_list.list_indexehdr.elf32_ident14)(Some(Uint32_wrapper.of_bigint((Nat_big_num.of_int0)))))&&(Lem.option_equal(=)(Lem_list.list_indexehdr.elf32_ident15)(Some(Uint32_wrapper.of_bigint((Nat_big_num.of_int0)))))))))))(*val is_magic_number_correct : list unsigned_char -> bool*)letis_magic_number_correctident:bool=((Lem.option_equal(=)(Lem_list.list_indexident0)(Some(Uint32_wrapper.of_bigint((Nat_big_num.of_int127)))))&&((Lem.option_equal(=)(Lem_list.list_indexident1)(Some(Uint32_wrapper.of_bigint((Nat_big_num.of_int69)))))&&((Lem.option_equal(=)(Lem_list.list_indexident2)(Some(Uint32_wrapper.of_bigint((Nat_big_num.of_int76)))))&&(Lem.option_equal(=)(Lem_list.list_indexident3)(Some(Uint32_wrapper.of_bigint((Nat_big_num.of_int70))))))))(** [read_elf32_header bs0] reads an ELF header from the byte sequence [bs0].
* Fails if transcription fails.
*)(*val read_elf32_header : byte_sequence -> error (elf32_header * byte_sequence)*)letread_elf32_headerbs:(elf32_header*Byte_sequence_wrapper.byte_sequence)error=(bind(read_elf_identbs)(fun(ident,bs)->ifnot(is_magic_number_correctident)thenfail"read_elf32_header: magic number incorrect"elseletendian=(deduce_endiannessident)inbind(read_elf32_halfendianbs)(fun(typ,bs)->bind(read_elf32_halfendianbs)(fun(machine,bs)->bind(read_elf32_wordendianbs)(fun(version,bs)->bind(read_elf32_addrendianbs)(fun(entry,bs)->bind(read_elf32_offendianbs)(fun(phoff,bs)->bind(read_elf32_offendianbs)(fun(shoff,bs)->bind(read_elf32_wordendianbs)(fun(flags,bs)->bind(read_elf32_halfendianbs)(fun(ehsize,bs)->bind(read_elf32_halfendianbs)(fun(phentsize,bs)->bind(read_elf32_halfendianbs)(fun(phnum,bs)->bind(read_elf32_halfendianbs)(fun(shentsize,bs)->bind(read_elf32_halfendianbs)(fun(shnum,bs)->bind(read_elf32_halfendianbs)(fun(shstrndx,bs)->(matchLem_list.list_indexident4with|None->fail"read_elf32_header: transcription of ELF identifier failed"|Somec->ifNat_big_num.equal(Uint32_wrapper.to_bigintc)elf_class_32thenreturn({elf32_ident=ident;elf32_type=typ;elf32_machine=machine;elf32_version=version;elf32_entry=entry;elf32_phoff=phoff;elf32_shoff=shoff;elf32_flags=flags;elf32_ehsize=ehsize;elf32_phentsize=phentsize;elf32_phnum=phnum;elf32_shentsize=shentsize;elf32_shnum=shnum;elf32_shstrndx=shstrndx},bs)elsefail"read_elf32_header: not a 32-bit ELF file"))))))))))))))))(** [read_elf64_header bs0] reads an ELF header from the byte sequence [bs0].
* Fails if transcription fails.
*)(*val read_elf64_header : byte_sequence -> error (elf64_header * byte_sequence)*)letread_elf64_headerbs:(elf64_header*Byte_sequence_wrapper.byte_sequence)error=(bind(read_elf_identbs)(fun(ident,bs)->ifnot(is_magic_number_correctident)thenfail"read_elf64_header: magic number incorrect"elseletendian=(deduce_endiannessident)inbind(read_elf64_halfendianbs)(fun(typ,bs)->bind(read_elf64_halfendianbs)(fun(machine,bs)->bind(read_elf64_wordendianbs)(fun(version,bs)->bind(read_elf64_addrendianbs)(fun(entry,bs)->bind(read_elf64_offendianbs)(fun(phoff,bs)->bind(read_elf64_offendianbs)(fun(shoff,bs)->bind(read_elf64_wordendianbs)(fun(flags,bs)->bind(read_elf64_halfendianbs)(fun(ehsize,bs)->bind(read_elf64_halfendianbs)(fun(phentsize,bs)->bind(read_elf64_halfendianbs)(fun(phnum,bs)->bind(read_elf64_halfendianbs)(fun(shentsize,bs)->bind(read_elf64_halfendianbs)(fun(shnum,bs)->bind(read_elf64_halfendianbs)(fun(shstrndx,bs)->(matchLem_list.list_indexident4with|None->fail"read_elf64_header: transcription of ELF identifier failed"|Somec->ifNat_big_num.equal(Uint32_wrapper.to_bigintc)elf_class_64thenreturn({elf64_ident=ident;elf64_type=typ;elf64_machine=machine;elf64_version=version;elf64_entry=entry;elf64_phoff=phoff;elf64_shoff=shoff;elf64_flags=flags;elf64_ehsize=ehsize;elf64_phentsize=phentsize;elf64_phnum=phnum;elf64_shentsize=shentsize;elf64_shnum=shnum;elf64_shstrndx=shstrndx},bs)elsefail"read_elf64_header: not a 64-bit ELF file"))))))))))))))))(** [is_elf32_header_class_correct hdr] checks whether the declared file class
* is correct.
*)(*val is_elf32_header_class_correct : elf32_header -> bool*)letis_elf32_header_class_correctehdr:bool=(Lem.option_equal(=)(Lem_list.list_indexehdr.elf32_ident4)(Some(Uint32_wrapper.of_bigint((Nat_big_num.of_int1)))))(** [is_elf64_header_class_correct hdr] checks whether the declared file class
* is correct.
*)(*val is_elf64_header_class_correct : elf64_header -> bool*)letis_elf64_header_class_correctehdr:bool=(Lem.option_equal(=)(Lem_list.list_indexehdr.elf64_ident4)(Some(Uint32_wrapper.of_bigint((Nat_big_num.of_int1)))))(** [is_elf32_header_version_correct hdr] checks whether the declared file version
* is correct.
*)(*val is_elf32_header_version_correct : elf32_header -> bool*)letis_elf32_header_version_correctehdr:bool=(Lem.option_equal(=)(Lem_list.list_indexehdr.elf32_ident6)(Some(Uint32_wrapper.of_bigint((Nat_big_num.of_int1)))))(** [is_elf64_header_version_correct hdr] checks whether the declared file version
* is correct.
*)(*val is_elf64_header_version_correct : elf64_header -> bool*)letis_elf64_header_version_correctehdr:bool=(Lem.option_equal(=)(Lem_list.list_indexehdr.elf64_ident6)(Some(Uint32_wrapper.of_bigint((Nat_big_num.of_int1)))))(** [is_elf32_header_valid] checks whether an [elf32_header] value is a valid 32-bit
* ELF file header (i.e. [elf32_ident] is [ei_nident] entries long, and other
* constraints on headers).
*)(*val is_elf32_header_valid : elf32_header -> bool*)letis_elf32_header_validehdr:bool=(Nat_big_num.equal(Nat_big_num.of_int(List.lengthehdr.elf32_ident))ei_nident&&(is_magic_number_correctehdr.elf32_ident&&(is_elf32_header_padding_correctehdr&&(is_elf32_header_class_correctehdr&&is_elf32_header_version_correctehdr))))(** [get_elf32_header_program_table_size] calculates the size of the program table
* (entry size x number of entries) based on data in the ELF header.
*)(*val get_elf32_header_program_table_size : elf32_header -> natural*)letget_elf32_header_program_table_sizeehdr:Nat_big_num.num=(letphentsize=(Uint32_wrapper.to_bigintehdr.elf32_phentsize)inletphnum=(Uint32_wrapper.to_bigintehdr.elf32_phnum)inNat_big_num.mulphentsizephnum)(** [get_elf64_header_program_table_size] calculates the size of the program table
* (entry size x number of entries) based on data in the ELF header.
*)(*val get_elf64_header_program_table_size : elf64_header -> natural*)letget_elf64_header_program_table_sizeehdr:Nat_big_num.num=(letphentsize=(Uint32_wrapper.to_bigintehdr.elf64_phentsize)inletphnum=(Uint32_wrapper.to_bigintehdr.elf64_phnum)inNat_big_num.mulphentsizephnum)(** [is_elf32_header_section_table_present] calculates whether a section table
* is present in the ELF file or not.
*)(*val is_elf32_header_section_table_present : elf32_header -> bool*)letis_elf32_header_section_table_presentehdr:bool=(not(Nat_big_num.equal(Uint32_wrapper.to_bigintehdr.elf32_shoff)((Nat_big_num.of_int0))))(** [is_elf64_header_section_table_present] calculates whether a section table
* is present in the ELF file or not.
*)(*val is_elf64_header_section_table_present : elf64_header -> bool*)letis_elf64_header_section_table_presentehdr:bool=(not(Nat_big_num.equal(Uint64_wrapper.to_bigintehdr.elf64_shoff)((Nat_big_num.of_int0))))(** [get_elf32_header_section_table_size] calculates the size of the section table
* (entry size x number of entries) based on data in the ELF header.
*)(*val get_elf32_header_section_table_size : elf32_header -> natural*)letget_elf32_header_section_table_sizeehdr:Nat_big_num.num=(letshentsize=(Uint32_wrapper.to_bigintehdr.elf32_shentsize)inletshnum=(Uint32_wrapper.to_bigintehdr.elf32_shnum)inNat_big_num.mulshentsizeshnum)(** [get_elf64_header_section_table_size] calculates the size of the section table
* (entry size x number of entries) based on data in the ELF header.
*)(*val get_elf64_header_section_table_size : elf64_header -> natural*)letget_elf64_header_section_table_sizeehdr:Nat_big_num.num=(letshentsize=(Uint32_wrapper.to_bigintehdr.elf64_shentsize)inletshnum=(Uint32_wrapper.to_bigintehdr.elf64_shnum)inNat_big_num.mulshentsizeshnum)