package linksem
A formalisation of the core ELF and DWARF file formats written in Lem
Install
Dune Dependency
Authors
Maintainers
Sources
0.8.tar.gz
md5=2075c56715539b3b8f54ae65cc808b8c
sha512=f7c16e4036a1440a6a8d13707a43f0f9f9db0c68489215f948cc300b6a164dba5bf852e58f89503e9d9f38180ee658d9478156ca1a1ef64d6861eec5f9cf43d2
doc/src/linksem_zarith/elf_header.ml.html
Source file elf_header.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480
(*Generated by Lem from elf_header.lem.*) (** [elf_header] includes types, functions and other definitions for working with * ELF headers. *) open Lem_basic_classes open Lem_bool open Lem_function open Lem_list open Lem_maybe open Lem_num open Lem_string (*import Set*) open Lem_assert_extra open Default_printing open Endianness open Elf_types_native_uint open Byte_sequence open Error open Missing_pervasives open Show (** 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). *) let shn_undef : Nat_big_num.num= ( (Nat_big_num.of_int 0)) (** [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). *) let shn_xindex : Nat_big_num.num= ( (Nat_big_num.of_int 65535)) (* 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 *) let elf_ft_none : Nat_big_num.num= ( (Nat_big_num.of_int 0)) (** Relocatable file *) let elf_ft_rel : Nat_big_num.num= ( (Nat_big_num.of_int 1)) (** Executable file *) let elf_ft_exec : Nat_big_num.num= ( (Nat_big_num.of_int 2)) (** Shared object file *) let elf_ft_dyn : Nat_big_num.num= ( (Nat_big_num.of_int 3)) (** Core file *) let elf_ft_core : Nat_big_num.num= ( (Nat_big_num.of_int 4)) (** Operating-system specific *) let elf_ft_lo_os : Nat_big_num.num= ( (Nat_big_num.of_int 65024)) (* 0xfe00 *) (** Operating-system specific *) let elf_ft_hi_os : Nat_big_num.num= ( (Nat_big_num.of_int 65279)) (* 0xfeff *) (** Processor specific *) let elf_ft_lo_proc : Nat_big_num.num= ( (Nat_big_num.of_int 65280)) (* 0xff00 *) (** Processor specific *) let elf_ft_hi_proc : Nat_big_num.num= ( (Nat_big_num.of_int 65535)) (* 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*) let string_of_elf_file_type os_specific proc_specific m:string= (if Nat_big_num.equal m elf_ft_none then "No file type" else if Nat_big_num.equal m elf_ft_rel then "REL (Relocatable file)" else if Nat_big_num.equal m elf_ft_exec then "EXEC (Executable file)" else if Nat_big_num.equal m elf_ft_dyn then "DYN (Shared object file)" else if Nat_big_num.equal m elf_ft_core then "CORE (Core file)" else if Nat_big_num.greater_equal m elf_ft_lo_os && Nat_big_num.less_equal m elf_ft_hi_os then os_specific m else if Nat_big_num.greater_equal m elf_ft_lo_proc && Nat_big_num.less_equal m elf_ft_hi_proc then proc_specific m else "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*) let is_operating_system_specific_object_file_type_value v:bool= (Nat_big_num.greater_equal v( (Nat_big_num.of_int 65024)) && Nat_big_num.less_equal v( (Nat_big_num.of_int 65279))) (** [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*) let is_processor_specific_object_file_type_value v:bool= (Nat_big_num.greater_equal v( (Nat_big_num.of_int 65280)) && Nat_big_num.less_equal v( (Nat_big_num.of_int 65535))) (** ELF machine architectures *) (** RISC-V *) let elf_ma_riscv : Nat_big_num.num= ( (Nat_big_num.of_int 243)) (** AMD GPU architecture *) let elf_ma_amdgpu : Nat_big_num.num= ( (Nat_big_num.of_int 224)) (** Moxie processor family *) let elf_ma_moxie : Nat_big_num.num= ( (Nat_big_num.of_int 223)) (** FTDI Chip FT32 high performance 32-bit RISC architecture *) let elf_ma_ft32 : Nat_big_num.num= ( (Nat_big_num.of_int 222)) (** Controls and Data Services VISIUMcore processor *) let elf_ma_visium : Nat_big_num.num= ( (Nat_big_num.of_int 221)) (** Zilog Z80 *) let elf_ma_z80 : Nat_big_num.num= ( (Nat_big_num.of_int 220)) (** CSR Kalimba architecture family *) let elf_ma_kalimba : Nat_big_num.num= ( (Nat_big_num.of_int 219)) (** Nanoradio optimised RISC *) let elf_ma_norc : Nat_big_num.num= ( (Nat_big_num.of_int 218)) (** iCelero CoolEngine *) let elf_ma_cool : Nat_big_num.num= ( (Nat_big_num.of_int 217)) (** Cognitive Smart Memory Processor *) let elf_ma_coge : Nat_big_num.num= ( (Nat_big_num.of_int 216)) (** Paneve CDP architecture family *) let elf_ma_cdp : Nat_big_num.num= ( (Nat_big_num.of_int 215)) (** KM211 KVARC processor *) let elf_ma_kvarc : Nat_big_num.num= ( (Nat_big_num.of_int 214)) (** KM211 KMX8 8-bit processor *) let elf_ma_kmx8 : Nat_big_num.num= ( (Nat_big_num.of_int 213)) (** KM211 KMX16 16-bit processor *) let elf_ma_kmx16 : Nat_big_num.num= ( (Nat_big_num.of_int 212)) (** KM211 KMX32 32-bit processor *) let elf_ma_kmx32 : Nat_big_num.num= ( (Nat_big_num.of_int 211)) (** KM211 KM32 32-bit processor *) let elf_ma_km32 : Nat_big_num.num= ( (Nat_big_num.of_int 210)) (** Microchip 8-bit PIC(r) family *) let elf_ma_mchp_pic : Nat_big_num.num= ( (Nat_big_num.of_int 204)) (** XMOS xCORE processor family *) let elf_ma_xcore : Nat_big_num.num= ( (Nat_big_num.of_int 203)) (** Beyond BA2 CPU architecture *) let elf_ma_ba2 : Nat_big_num.num= ( (Nat_big_num.of_int 202)) (** Beyond BA1 CPU architecture *) let elf_ma_ba1 : Nat_big_num.num= ( (Nat_big_num.of_int 201)) (** Freescale 56800EX Digital Signal Controller (DSC) *) let elf_ma_5600ex : Nat_big_num.num= ( (Nat_big_num.of_int 200)) (** 199 Renesas 78KOR family *) let elf_ma_78kor : Nat_big_num.num= ( (Nat_big_num.of_int 199)) (** Broadcom VideoCore V processor *) let elf_ma_videocore5 : Nat_big_num.num= ( (Nat_big_num.of_int 198)) (** Renesas RL78 family *) let elf_ma_rl78 : Nat_big_num.num= ( (Nat_big_num.of_int 197)) (** Open8 8-bit RISC soft processing core *) let elf_ma_open8 : Nat_big_num.num= ( (Nat_big_num.of_int 196)) (** Synopsys ARCompact V2 *) let elf_ma_arc_compact2 : Nat_big_num.num= ( (Nat_big_num.of_int 195)) (** KIPO_KAIST Core-A 2nd generation processor family *) let elf_ma_corea_2nd : Nat_big_num.num= ( (Nat_big_num.of_int 194)) (** KIPO_KAIST Core-A 1st generation processor family *) let elf_ma_corea_1st : Nat_big_num.num= ( (Nat_big_num.of_int 193)) (** CloudShield architecture family *) let elf_ma_cloudshield : Nat_big_num.num= ( (Nat_big_num.of_int 192)) (** Infineon Technologies SLE9X core *) let elf_ma_sle9x : Nat_big_num.num= ( (Nat_big_num.of_int 179)) (** Intel L10M *) let elf_ma_l10m : Nat_big_num.num= ( (Nat_big_num.of_int 180)) (** Intel K10M *) let elf_ma_k10m : Nat_big_num.num= ( (Nat_big_num.of_int 181)) (** ARM 64-bit architecture (AARCH64) *) let elf_ma_aarch64 : Nat_big_num.num= ( (Nat_big_num.of_int 183)) (** Atmel Corporation 32-bit microprocessor family *) let elf_ma_avr32 : Nat_big_num.num= ( (Nat_big_num.of_int 185)) (** STMicroelectronics STM8 8-bit microcontroller *) let elf_ma_stm8 : Nat_big_num.num= ( (Nat_big_num.of_int 186)) (** Tilera TILE64 multicore architecture family *) let elf_ma_tile64 : Nat_big_num.num= ( (Nat_big_num.of_int 187)) (** Tilera TILEPro multicore architecture family *) let elf_ma_tilepro : Nat_big_num.num= ( (Nat_big_num.of_int 188)) (** Xilinix MicroBlaze 32-bit RISC soft processor core *) let elf_ma_microblaze : Nat_big_num.num= ( (Nat_big_num.of_int 189)) (** NVIDIA CUDA architecture *) let elf_ma_cuda : Nat_big_num.num= ( (Nat_big_num.of_int 190)) (** Tilera TILE-Gx multicore architecture family *) let elf_ma_tilegx : Nat_big_num.num= ( (Nat_big_num.of_int 191)) (** Cypress M8C microprocessor *) let elf_ma_cypress : Nat_big_num.num= ( (Nat_big_num.of_int 161)) (** Renesas R32C series microprocessors *) let elf_ma_r32c : Nat_big_num.num= ( (Nat_big_num.of_int 162)) (** NXP Semiconductors TriMedia architecture family *) let elf_ma_trimedia : Nat_big_num.num= ( (Nat_big_num.of_int 163)) (** QUALCOMM DSP6 processor *) let elf_ma_qdsp6 : Nat_big_num.num= ( (Nat_big_num.of_int 164)) (** Intel 8051 and variants *) let elf_ma_8051 : Nat_big_num.num= ( (Nat_big_num.of_int 165)) (** STMicroelectronics STxP7x family of configurable and extensible RISC processors *) let elf_ma_stxp7x : Nat_big_num.num= ( (Nat_big_num.of_int 166)) (** Andes Technology compact code size embedded RISC processor family *) let elf_ma_nds32 : Nat_big_num.num= ( (Nat_big_num.of_int 167)) (** Cyan Technology eCOG1X family *) let elf_ma_ecog1x : Nat_big_num.num= ( (Nat_big_num.of_int 168)) (** Dallas Semiconductor MAXQ30 Core Micro-controllers *) let elf_ma_maxq30 : Nat_big_num.num= ( (Nat_big_num.of_int 169)) (** New Japan Radio (NJR) 16-bit DSP Processor *) let elf_ma_ximo16 : Nat_big_num.num= ( (Nat_big_num.of_int 170)) (** M2000 Reconfigurable RISC Microprocessor *) let elf_ma_manik : Nat_big_num.num= ( (Nat_big_num.of_int 171)) (** Cray Inc. NV2 vector architecture *) let elf_ma_craynv2 : Nat_big_num.num= ( (Nat_big_num.of_int 172)) (** Renesas RX family *) let elf_ma_rx : Nat_big_num.num= ( (Nat_big_num.of_int 173)) (** Imagination Technologies META processor architecture *) let elf_ma_metag : Nat_big_num.num= ( (Nat_big_num.of_int 174)) (** MCST Elbrus general purpose hardware architecture *) let elf_ma_mcst_elbrus : Nat_big_num.num= ( (Nat_big_num.of_int 175)) (** Cyan Technology eCOG16 family *) let elf_ma_ecog16 : Nat_big_num.num= ( (Nat_big_num.of_int 176)) (** National Semiconductor CompactRISC CR16 16-bit microprocessor *) let elf_ma_cr16 : Nat_big_num.num= ( (Nat_big_num.of_int 177)) (** Freescale Extended Time Processing Unit *) let elf_ma_etpu : Nat_big_num.num= ( (Nat_big_num.of_int 178)) (** Altium TSK3000 core *) let elf_ma_tsk3000 : Nat_big_num.num= ( (Nat_big_num.of_int 131)) (** Freescale RS08 embedded processor *) let elf_ma_rs08 : Nat_big_num.num= ( (Nat_big_num.of_int 132)) (** Analog Devices SHARC family of 32-bit DSP processors *) let elf_ma_sharc : Nat_big_num.num= ( (Nat_big_num.of_int 133)) (** Cyan Technology eCOG2 microprocessor *) let elf_ma_ecog2 : Nat_big_num.num= ( (Nat_big_num.of_int 134)) (** Sunplus S+core7 RISC processor *) let elf_ma_ccore7 : Nat_big_num.num= ( (Nat_big_num.of_int 135)) (** New Japan Radio (NJR) 24-bit DSP Processor *) let elf_ma_dsp24 : Nat_big_num.num= ( (Nat_big_num.of_int 136)) (** Broadcom VideoCore III processor *) let elf_ma_videocore3 : Nat_big_num.num= ( (Nat_big_num.of_int 137)) (** RISC processor for Lattice FPGA architecture *) let elf_ma_latticemico32 : Nat_big_num.num= ( (Nat_big_num.of_int 138)) (** Seiko Epson C17 family *) let elf_ma_c17 : Nat_big_num.num= ( (Nat_big_num.of_int 139)) (** The Texas Instruments TMS320C6000 DSP family *) let elf_ma_c6000 : Nat_big_num.num= ( (Nat_big_num.of_int 140)) (** The Texas Instruments TMS320C2000 DSP family *) let elf_ma_c2000 : Nat_big_num.num= ( (Nat_big_num.of_int 141)) (** The Texas Instruments TMS320C55x DSP family *) let elf_ma_c5500 : Nat_big_num.num= ( (Nat_big_num.of_int 142)) (** STMicroelectronics 64bit VLIW Data Signal Processor *) let elf_ma_mmdsp_plus : Nat_big_num.num= ( (Nat_big_num.of_int 160)) (** LSI Logic 16-bit DSP Processor *) let elf_ma_zsp : Nat_big_num.num= ( (Nat_big_num.of_int 79)) (** Donald Knuth's educational 64-bit processor *) let elf_ma_mmix : Nat_big_num.num= ( (Nat_big_num.of_int 80)) (** Harvard University machine-independent object files *) let elf_ma_huany : Nat_big_num.num= ( (Nat_big_num.of_int 81)) (** SiTera Prism *) let elf_ma_prism : Nat_big_num.num= ( (Nat_big_num.of_int 82)) (** Atmel AVR 8-bit microcontroller *) let elf_ma_avr : Nat_big_num.num= ( (Nat_big_num.of_int 83)) (** Fujitsu FR30 *) let elf_ma_fr30 : Nat_big_num.num= ( (Nat_big_num.of_int 84)) (** Mitsubishi D10V *) let elf_ma_d10v : Nat_big_num.num= ( (Nat_big_num.of_int 85)) (** Mitsubishi D30V *) let elf_ma_d30v : Nat_big_num.num= ( (Nat_big_num.of_int 86)) (** NEC v850 *) let elf_ma_v850 : Nat_big_num.num= ( (Nat_big_num.of_int 87)) (** Mitsubishi M32R *) let elf_ma_m32r : Nat_big_num.num= ( (Nat_big_num.of_int 88)) (** Matsushita MN10300 *) let elf_ma_mn10300 : Nat_big_num.num= ( (Nat_big_num.of_int 89)) (** Matsushita MN10200 *) let elf_ma_mn10200 : Nat_big_num.num= ( (Nat_big_num.of_int 90)) (** picoJava *) let elf_ma_pj : Nat_big_num.num= ( (Nat_big_num.of_int 91)) (** OpenRISC 32-bit embedded processor *) let elf_ma_openrisc : Nat_big_num.num= ( (Nat_big_num.of_int 92)) (** ARC International ARCompact processor (old spelling/synonym: ELF_MA_ARC_A5) *) let elf_ma_arc_compact : Nat_big_num.num= ( (Nat_big_num.of_int 93)) (** Tensilica Xtensa Architecture *) let elf_ma_xtensa : Nat_big_num.num= ( (Nat_big_num.of_int 94)) (** Alphamosaic VideoCore processor *) let elf_ma_videocore : Nat_big_num.num= ( (Nat_big_num.of_int 95)) (** Thompson Multimedia General Purpose Processor *) let elf_ma_tmm_gpp : Nat_big_num.num= ( (Nat_big_num.of_int 96)) (** National Semiconductor 32000 series *) let elf_ma_ns32k : Nat_big_num.num= ( (Nat_big_num.of_int 97)) (** Tenor Network TPC processor *) let elf_ma_tpc : Nat_big_num.num= ( (Nat_big_num.of_int 98)) (** Trebia SNP 1000 processor *) let elf_ma_snp1k : Nat_big_num.num= ( (Nat_big_num.of_int 99)) (** STMicroelectronics ST200 microcontroller *) let elf_ma_st200 : Nat_big_num.num= ( (Nat_big_num.of_int 100)) (** Ubicom IP2xxx microcontroller family *) let elf_ma_ip2k : Nat_big_num.num= ( (Nat_big_num.of_int 101)) (** MAX Processor *) let elf_ma_max : Nat_big_num.num= ( (Nat_big_num.of_int 102)) (** National Semiconductor CompactRISC microprocessor *) let elf_ma_cr : Nat_big_num.num= ( (Nat_big_num.of_int 103)) (** Fujitsu F2MC16 *) let elf_ma_f2mc16 : Nat_big_num.num= ( (Nat_big_num.of_int 104)) (** Texas Instruments embedded microcontroller msp430 *) let elf_ma_msp430 : Nat_big_num.num= ( (Nat_big_num.of_int 105)) (** Analog Devices Blackfin (DSP) processor *) let elf_ma_blackfin : Nat_big_num.num= ( (Nat_big_num.of_int 106)) (** S1C33 Family of Seiko Epson processors *) let elf_ma_se_c33 : Nat_big_num.num= ( (Nat_big_num.of_int 107)) (** Sharp embedded microprocessor *) let elf_ma_sep : Nat_big_num.num= ( (Nat_big_num.of_int 108)) (** Arca RISC Microprocessor *) let elf_ma_arca : Nat_big_num.num= ( (Nat_big_num.of_int 109)) (** Microprocessor series from PKU-Unity Ltd. and MPRC of Peking University *) let elf_ma_unicore : Nat_big_num.num= ( (Nat_big_num.of_int 110)) (** eXcess: 16/32/64-bit configurable embedded CPU *) let elf_ma_excess : Nat_big_num.num= ( (Nat_big_num.of_int 111)) (** Icera Semiconductor Inc. Deep Execution Processor *) let elf_ma_dxp : Nat_big_num.num= ( (Nat_big_num.of_int 112)) (** Altera Nios II soft-core processor *) let elf_ma_altera_nios2 : Nat_big_num.num= ( (Nat_big_num.of_int 113)) (** National Semiconductor CompactRISC CRX microprocessor *) let elf_ma_crx : Nat_big_num.num= ( (Nat_big_num.of_int 114)) (** Motorola XGATE embedded processor *) let elf_ma_xgate : Nat_big_num.num= ( (Nat_big_num.of_int 115)) (** Infineon C16x/XC16x processor *) let elf_ma_c166 : Nat_big_num.num= ( (Nat_big_num.of_int 116)) (** Renesas M16C series microprocessors *) let elf_ma_m16c : Nat_big_num.num= ( (Nat_big_num.of_int 117)) (** Microchip Technology dsPIC30F Digital Signal Controller *) let elf_ma_dspic30f : Nat_big_num.num= ( (Nat_big_num.of_int 118)) (** Freescale Communication Engine RISC core *) let elf_ma_ce : Nat_big_num.num= ( (Nat_big_num.of_int 119)) (** Renesas M32C series microprocessors *) let elf_ma_m32c : Nat_big_num.num= ( (Nat_big_num.of_int 120)) (** No machine *) let elf_ma_none : Nat_big_num.num= ( (Nat_big_num.of_int 0)) (** AT&T WE 32100 *) let elf_ma_m32 : Nat_big_num.num= ( (Nat_big_num.of_int 1)) (** SPARC *) let elf_ma_sparc : Nat_big_num.num= ( (Nat_big_num.of_int 2)) (** Intel 80386 *) let elf_ma_386 : Nat_big_num.num= ( (Nat_big_num.of_int 3)) (** Motorola 68000 *) let elf_ma_68k : Nat_big_num.num= ( (Nat_big_num.of_int 4)) (** Motorola 88000 *) let elf_ma_88k : Nat_big_num.num= ( (Nat_big_num.of_int 5)) (** Intel 80860 *) let elf_ma_860 : Nat_big_num.num= ( (Nat_big_num.of_int 7)) (** MIPS I Architecture *) let elf_ma_mips : Nat_big_num.num= ( (Nat_big_num.of_int 8)) (** IBM System/370 Processor *) let elf_ma_s370 : Nat_big_num.num= ( (Nat_big_num.of_int 9)) (** MIPS RS3000 Little-endian *) let elf_ma_mips_rs3_le : Nat_big_num.num= ( (Nat_big_num.of_int 10)) (** Hewlett-Packard PA-RISC *) let elf_ma_parisc : Nat_big_num.num= ( (Nat_big_num.of_int 15)) (** Fujitsu VPP500 *) let elf_ma_vpp500 : Nat_big_num.num= ( (Nat_big_num.of_int 17)) (** Enhanced instruction set SPARC *) let elf_ma_sparc32plus : Nat_big_num.num= ( (Nat_big_num.of_int 18)) (** Intel 80960 *) let elf_ma_960 : Nat_big_num.num= ( (Nat_big_num.of_int 19)) (** PowerPC *) let elf_ma_ppc : Nat_big_num.num= ( (Nat_big_num.of_int 20)) (** 64-bit PowerPC *) let elf_ma_ppc64 : Nat_big_num.num= ( (Nat_big_num.of_int 21)) (** IBM System/390 Processor *) let elf_ma_s390 : Nat_big_num.num= ( (Nat_big_num.of_int 22)) (** IBM SPU/SPC *) let elf_ma_spu : Nat_big_num.num= ( (Nat_big_num.of_int 23)) (** NEC V800 *) let elf_ma_v800 : Nat_big_num.num= ( (Nat_big_num.of_int 36)) (** Fujitsu FR20 *) let elf_ma_fr20 : Nat_big_num.num= ( (Nat_big_num.of_int 37)) (** TRW RH-32 *) let elf_ma_rh32 : Nat_big_num.num= ( (Nat_big_num.of_int 38)) (** Motorola RCE *) let elf_ma_rce : Nat_big_num.num= ( (Nat_big_num.of_int 39)) (** ARM 32-bit architecture (AARCH32) *) let elf_ma_arm : Nat_big_num.num= ( (Nat_big_num.of_int 40)) (** Digital Alpha *) let elf_ma_alpha : Nat_big_num.num= ( (Nat_big_num.of_int 41)) (** Hitachi SH *) let elf_ma_sh : Nat_big_num.num= ( (Nat_big_num.of_int 42)) (** SPARC Version 9 *) let elf_ma_sparcv9 : Nat_big_num.num= ( (Nat_big_num.of_int 43)) (** Siemens TriCore embedded processor *) let elf_ma_tricore : Nat_big_num.num= ( (Nat_big_num.of_int 44)) (** Argonaut RISC Core, Argonaut Technologies Inc. *) let elf_ma_arc : Nat_big_num.num= ( (Nat_big_num.of_int 45)) (** Hitachi H8/300 *) let elf_ma_h8_300 : Nat_big_num.num= ( (Nat_big_num.of_int 46)) (** Hitachi H8/300H *) let elf_ma_h8_300h : Nat_big_num.num= ( (Nat_big_num.of_int 47)) (** Hitachi H8S *) let elf_ma_h8s : Nat_big_num.num= ( (Nat_big_num.of_int 48)) (** Hitachi H8/500 *) let elf_ma_h8_500 : Nat_big_num.num= ( (Nat_big_num.of_int 49)) (** Intel IA-64 processor architecture *) let elf_ma_ia_64 : Nat_big_num.num= ( (Nat_big_num.of_int 50)) (** Stanford MIPS-X *) let elf_ma_mips_x : Nat_big_num.num= ( (Nat_big_num.of_int 51)) (** Motorola ColdFire *) let elf_ma_coldfire : Nat_big_num.num= ( (Nat_big_num.of_int 52)) (** Motorola M68HC12 *) let elf_ma_68hc12 : Nat_big_num.num= ( (Nat_big_num.of_int 53)) (** Fujitsu MMA Multimedia Accelerator *) let elf_ma_mma : Nat_big_num.num= ( (Nat_big_num.of_int 54)) (** Siemens PCP *) let elf_ma_pcp : Nat_big_num.num= ( (Nat_big_num.of_int 55)) (** Sony nCPU embedded RISC processor *) let elf_ma_ncpu : Nat_big_num.num= ( (Nat_big_num.of_int 56)) (** Denso NDR1 microprocessor *) let elf_ma_ndr1 : Nat_big_num.num= ( (Nat_big_num.of_int 57)) (** Motorola Star*Core processor *) let elf_ma_starcore : Nat_big_num.num= ( (Nat_big_num.of_int 58)) (** Toyota ME16 processor *) let elf_ma_me16 : Nat_big_num.num= ( (Nat_big_num.of_int 59)) (** STMicroelectronics ST100 processor *) let elf_ma_st100 : Nat_big_num.num= ( (Nat_big_num.of_int 60)) (** Advanced Logic Corp. TinyJ embedded processor family *) let elf_ma_tinyj : Nat_big_num.num= ( (Nat_big_num.of_int 61)) (** AMD x86-64 architecture *) let elf_ma_x86_64 : Nat_big_num.num= ( (Nat_big_num.of_int 62)) (** Sony DSP Processor *) let elf_ma_pdsp : Nat_big_num.num= ( (Nat_big_num.of_int 63)) (** Digital Equipment Corp. PDP-10 *) let elf_ma_pdp10 : Nat_big_num.num= ( (Nat_big_num.of_int 64)) (** Digital Equipment Corp. PDP-11 *) let elf_ma_pdp11 : Nat_big_num.num= ( (Nat_big_num.of_int 65)) (** Siemens FX66 microcontroller *) let elf_ma_fx66 : Nat_big_num.num= ( (Nat_big_num.of_int 66)) (** STMicroelectronics ST9+ 8/16 bit microcontroller *) let elf_ma_st9plus : Nat_big_num.num= ( (Nat_big_num.of_int 67)) (** STMicroelectronics ST7 8-bit microcontroller *) let elf_ma_st7 : Nat_big_num.num= ( (Nat_big_num.of_int 68)) (** Motorola MC68HC16 Microcontroller *) let elf_ma_68hc16 : Nat_big_num.num= ( (Nat_big_num.of_int 69)) (** Motorola MC68HC11 Microcontroller *) let elf_ma_68hc11 : Nat_big_num.num= ( (Nat_big_num.of_int 70)) (** Motorola MC68HC08 Microcontroller *) let elf_ma_68hc08 : Nat_big_num.num= ( (Nat_big_num.of_int 71)) (** Motorola MC68HC05 Microcontroller *) let elf_ma_68hc05 : Nat_big_num.num= ( (Nat_big_num.of_int 72)) (** Silicon Graphics SVx *) let elf_ma_svx : Nat_big_num.num= ( (Nat_big_num.of_int 73)) (** STMicroelectronics ST19 8-bit microcontroller *) let elf_ma_st19 : Nat_big_num.num= ( (Nat_big_num.of_int 74)) (** Digital VAX *) let elf_ma_vax : Nat_big_num.num= ( (Nat_big_num.of_int 75)) (** Axis Communications 32-bit embedded processor *) let elf_ma_cris : Nat_big_num.num= ( (Nat_big_num.of_int 76)) (** Infineon Technologies 32-bit embedded processor *) let elf_ma_javelin : Nat_big_num.num= ( (Nat_big_num.of_int 77)) (** Element 14 64-bit DSP Processor *) let elf_ma_firepath : Nat_big_num.num= ( (Nat_big_num.of_int 78)) (** Reserved by Intel *) let elf_ma_intel209 : Nat_big_num.num= ( (Nat_big_num.of_int 209)) (** Reserved by Intel *) let elf_ma_intel208 : Nat_big_num.num= ( (Nat_big_num.of_int 208)) (** Reserved by Intel *) let elf_ma_intel207 : Nat_big_num.num= ( (Nat_big_num.of_int 207)) (** Reserved by Intel *) let elf_ma_intel206 : Nat_big_num.num= ( (Nat_big_num.of_int 206)) (** Reserved by Intel *) let elf_ma_intel205 : Nat_big_num.num= ( (Nat_big_num.of_int 205)) (** Reserved by Intel *) let elf_ma_intel182 : Nat_big_num.num= ( (Nat_big_num.of_int 182)) (** Reserved by ARM *) let elf_ma_arm184 : Nat_big_num.num= ( (Nat_big_num.of_int 184)) (** Reserved for future use *) let elf_ma_reserved6 : Nat_big_num.num= ( (Nat_big_num.of_int 6)) (** Reserved for future use *) let elf_ma_reserved11 : Nat_big_num.num= ( (Nat_big_num.of_int 11)) (** Reserved for future use *) let elf_ma_reserved12 : Nat_big_num.num= ( (Nat_big_num.of_int 12)) (** Reserved for future use *) let elf_ma_reserved13 : Nat_big_num.num= ( (Nat_big_num.of_int 13)) (** Reserved for future use *) let elf_ma_reserved14 : Nat_big_num.num= ( (Nat_big_num.of_int 14)) (** Reserved for future use *) let elf_ma_reserved16 : Nat_big_num.num= ( (Nat_big_num.of_int 16)) (** Reserved for future use *) let elf_ma_reserved24 : Nat_big_num.num= ( (Nat_big_num.of_int 24)) (** Reserved for future use *) let elf_ma_reserved25 : Nat_big_num.num= ( (Nat_big_num.of_int 25)) (** Reserved for future use *) let elf_ma_reserved26 : Nat_big_num.num= ( (Nat_big_num.of_int 26)) (** Reserved for future use *) let elf_ma_reserved27 : Nat_big_num.num= ( (Nat_big_num.of_int 27)) (** Reserved for future use *) let elf_ma_reserved28 : Nat_big_num.num= ( (Nat_big_num.of_int 28)) (** Reserved for future use *) let elf_ma_reserved29 : Nat_big_num.num= ( (Nat_big_num.of_int 29)) (** Reserved for future use *) let elf_ma_reserved30 : Nat_big_num.num= ( (Nat_big_num.of_int 30)) (** Reserved for future use *) let elf_ma_reserved31 : Nat_big_num.num= ( (Nat_big_num.of_int 31)) (** Reserved for future use *) let elf_ma_reserved32 : Nat_big_num.num= ( (Nat_big_num.of_int 32)) (** Reserved for future use *) let elf_ma_reserved33 : Nat_big_num.num= ( (Nat_big_num.of_int 33)) (** Reserved for future use *) let elf_ma_reserved34 : Nat_big_num.num= ( (Nat_big_num.of_int 34)) (** Reserved for future use *) let elf_ma_reserved35 : Nat_big_num.num= ( (Nat_big_num.of_int 35)) (** Reserved for future use *) let elf_ma_reserved121 : Nat_big_num.num= ( (Nat_big_num.of_int 121)) (** Reserved for future use *) let elf_ma_reserved122 : Nat_big_num.num= ( (Nat_big_num.of_int 122)) (** Reserved for future use *) let elf_ma_reserved123 : Nat_big_num.num= ( (Nat_big_num.of_int 123)) (** Reserved for future use *) let elf_ma_reserved124 : Nat_big_num.num= ( (Nat_big_num.of_int 124)) (** Reserved for future use *) let elf_ma_reserved125 : Nat_big_num.num= ( (Nat_big_num.of_int 125)) (** Reserved for future use *) let elf_ma_reserved126 : Nat_big_num.num= ( (Nat_big_num.of_int 126)) (** Reserved for future use *) let elf_ma_reserved127 : Nat_big_num.num= ( (Nat_big_num.of_int 127)) (** Reserved for future use *) let elf_ma_reserved128 : Nat_big_num.num= ( (Nat_big_num.of_int 128)) (** Reserved for future use *) let elf_ma_reserved129 : Nat_big_num.num= ( (Nat_big_num.of_int 129)) (** Reserved for future use *) let elf_ma_reserved130 : Nat_big_num.num= ( (Nat_big_num.of_int 130)) (** Reserved for future use *) let elf_ma_reserved143 : Nat_big_num.num= ( (Nat_big_num.of_int 143)) (** Reserved for future use *) let elf_ma_reserved144 : Nat_big_num.num= ( (Nat_big_num.of_int 144)) (** Reserved for future use *) let elf_ma_reserved145 : Nat_big_num.num= ( (Nat_big_num.of_int 145)) (** Reserved for future use *) let elf_ma_reserved146 : Nat_big_num.num= ( (Nat_big_num.of_int 146)) (** Reserved for future use *) let elf_ma_reserved147 : Nat_big_num.num= ( (Nat_big_num.of_int 147)) (** Reserved for future use *) let elf_ma_reserved148 : Nat_big_num.num= ( (Nat_big_num.of_int 148)) (** Reserved for future use *) let elf_ma_reserved149 : Nat_big_num.num= ( (Nat_big_num.of_int 149)) (** Reserved for future use *) let elf_ma_reserved150 : Nat_big_num.num= ( (Nat_big_num.of_int 150)) (** Reserved for future use *) let elf_ma_reserved151 : Nat_big_num.num= ( (Nat_big_num.of_int 151)) (** Reserved for future use *) let elf_ma_reserved152 : Nat_big_num.num= ( (Nat_big_num.of_int 152)) (** Reserved for future use *) let elf_ma_reserved153 : Nat_big_num.num= ( (Nat_big_num.of_int 153)) (** Reserved for future use *) let elf_ma_reserved154 : Nat_big_num.num= ( (Nat_big_num.of_int 154)) (** Reserved for future use *) let elf_ma_reserved155 : Nat_big_num.num= ( (Nat_big_num.of_int 155)) (** Reserved for future use *) let elf_ma_reserved156 : Nat_big_num.num= ( (Nat_big_num.of_int 156)) (** Reserved for future use *) let elf_ma_reserved157 : Nat_big_num.num= ( (Nat_big_num.of_int 157)) (** Reserved for future use *) let elf_ma_reserved158 : Nat_big_num.num= ( (Nat_big_num.of_int 158)) (** Reserved for future use *) let elf_ma_reserved159 : Nat_big_num.num= ( (Nat_big_num.of_int 159)) (** [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*) let string_of_elf_machine_architecture m:string= (if Nat_big_num.equal m elf_ma_386 then "Intel 80386" else if Nat_big_num.equal m elf_ma_ppc then "PowerPC" else if Nat_big_num.equal m elf_ma_ppc64 then "PowerPC64" else if Nat_big_num.equal m elf_ma_arm then "AArch" else if Nat_big_num.equal m elf_ma_x86_64 then "Advanced Micro Devices X86-64" else if Nat_big_num.equal m elf_ma_aarch64 then "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 *) let elf_ev_none : Nat_big_num.num= ( (Nat_big_num.of_int 0)) (** Current version *) let elf_ev_current : Nat_big_num.num= ( (Nat_big_num.of_int 1)) (** [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*) let string_of_elf_version_number m:string= (if Nat_big_num.equal m elf_ev_none then "Invalid ELF version" else if Nat_big_num.equal m elf_ev_current then "1 (current)" else "Extended ELF version") (** Check that an extended version number is correct (i.e. greater than 1). *) let is_valid_extended_version_number (n : Nat_big_num.num):bool= (Nat_big_num.greater n( (Nat_big_num.of_int 1))) (** Identification indices. The initial bytes of an ELF header (and an object * file) correspond to the e_ident member. *) (** File identification *) let elf_ii_mag0 : Nat_big_num.num= ( (Nat_big_num.of_int 0)) (** File identification *) let elf_ii_mag1 : Nat_big_num.num= ( (Nat_big_num.of_int 1)) (** File identification *) let elf_ii_mag2 : Nat_big_num.num= ( (Nat_big_num.of_int 2)) (** File identification *) let elf_ii_mag3 : Nat_big_num.num= ( (Nat_big_num.of_int 3)) (** File class *) let elf_ii_class : Nat_big_num.num= ( (Nat_big_num.of_int 4)) (** Data encoding *) let elf_ii_data : Nat_big_num.num= ( (Nat_big_num.of_int 5)) (** File version *) let elf_ii_version : Nat_big_num.num= ( (Nat_big_num.of_int 6)) (** Operating system/ABI identification *) let elf_ii_osabi : Nat_big_num.num= ( (Nat_big_num.of_int 7)) (** ABI version *) let elf_ii_abiversion : Nat_big_num.num= ( (Nat_big_num.of_int 8)) (** Start of padding bytes *) let elf_ii_pad : Nat_big_num.num= ( (Nat_big_num.of_int 9)) (** Size of e*_ident[] *) let elf_ii_nident : Nat_big_num.num= ( (Nat_big_num.of_int 16)) (** 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 *) let elf_mn_mag0 : Uint32_wrapper.uint32= (Uint32_wrapper.of_bigint( (Nat_big_num.of_int 127))) (** Position: e*_ident[elf_ii_mag1], 'E' format identifier *) let elf_mn_mag1 : Uint32_wrapper.uint32= (Uint32_wrapper.of_bigint( (Nat_big_num.of_int 69))) (** Position: e*_ident[elf_ii_mag2], 'L' format identifier *) let elf_mn_mag2 : Uint32_wrapper.uint32= (Uint32_wrapper.of_bigint( (Nat_big_num.of_int 76))) (** Position: e*_ident[elf_ii_mag3], 'F' format identifier *) let elf_mn_mag3 : Uint32_wrapper.uint32= (Uint32_wrapper.of_bigint( (Nat_big_num.of_int 70))) (** 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 *) let elf_class_none : Nat_big_num.num= ( (Nat_big_num.of_int 0)) (** 32 bit objects *) let elf_class_32 : Nat_big_num.num= ( (Nat_big_num.of_int 1)) (** 64 bit objects *) let elf_class_64 : Nat_big_num.num= ( (Nat_big_num.of_int 2)) (** [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*) let string_of_elf_file_class m:string= (if Nat_big_num.equal m elf_class_none then "Invalid ELF file class" else if Nat_big_num.equal m elf_class_32 then "ELF32" else if Nat_big_num.equal m elf_class_64 then "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 *) let elf_data_none : Nat_big_num.num= ( (Nat_big_num.of_int 0)) (** Two's complement values, least significant byte occupying lowest address *) let elf_data_2lsb : Nat_big_num.num= ( (Nat_big_num.of_int 1)) (** Two's complement values, most significant byte occupying lowest address *) let elf_data_2msb : Nat_big_num.num= ( (Nat_big_num.of_int 2)) (** [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*) let string_of_elf_data_encoding m:string= (if Nat_big_num.equal m elf_data_none then "Invalid data encoding" else if Nat_big_num.equal m elf_data_2lsb then "2's complement, little endian" else if Nat_big_num.equal m elf_data_2msb then "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 *) let elf_osabi_none : Nat_big_num.num= ( (Nat_big_num.of_int 0)) (** Hewlett-Packard HP-UX *) let elf_osabi_hpux : Nat_big_num.num= ( (Nat_big_num.of_int 1)) (** NetBSD *) let elf_osabi_netbsd : Nat_big_num.num= ( (Nat_big_num.of_int 2)) (** GNU *) let elf_osabi_gnu : Nat_big_num.num= ( (Nat_big_num.of_int 3)) (** Linux, historical alias for GNU *) let elf_osabi_linux : Nat_big_num.num= ( (Nat_big_num.of_int 3)) (** Sun Solaris *) let elf_osabi_solaris : Nat_big_num.num= ( (Nat_big_num.of_int 6)) (** AIX *) let elf_osabi_aix : Nat_big_num.num= ( (Nat_big_num.of_int 7)) (** IRIX *) let elf_osabi_irix : Nat_big_num.num= ( (Nat_big_num.of_int 8)) (** FreeBSD *) let elf_osabi_freebsd : Nat_big_num.num= ( (Nat_big_num.of_int 9)) (** Compaq Tru64 Unix *) let elf_osabi_tru64 : Nat_big_num.num= ( (Nat_big_num.of_int 10)) (** Novell Modesto *) let elf_osabi_modesto : Nat_big_num.num= ( (Nat_big_num.of_int 11)) (** OpenBSD *) let elf_osabi_openbsd : Nat_big_num.num= ( (Nat_big_num.of_int 12)) (** OpenVMS *) let elf_osabi_openvms : Nat_big_num.num= ( (Nat_big_num.of_int 13)) (** Hewlett-Packard Non-stop Kernel *) let elf_osabi_nsk : Nat_big_num.num= ( (Nat_big_num.of_int 14)) (** Amiga Research OS *) let elf_osabi_aros : Nat_big_num.num= ( (Nat_big_num.of_int 15)) (** FenixOS highly-scalable multi-core OS *) let elf_osabi_fenixos : Nat_big_num.num= ( (Nat_big_num.of_int 16)) (** Nuxi CloudABI *) let elf_osabi_cloudabi : Nat_big_num.num= ( (Nat_big_num.of_int 17)) (** Stratus technologies OpenVOS *) let elf_osabi_openvos : Nat_big_num.num= ( (Nat_big_num.of_int 18)) (** Checks an architecture defined OSABI version is correct, i.e. in the range * 64 to 255 inclusive. *) let is_valid_architecture_defined_osabi_version (n : Nat_big_num.num):bool= (Nat_big_num.greater_equal n( (Nat_big_num.of_int 64)) && Nat_big_num.less_equal n( (Nat_big_num.of_int 255))) (** [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*) let string_of_elf_osabi_version arch m:string= (if Nat_big_num.equal m elf_osabi_none then "UNIX - System V" else if Nat_big_num.equal m elf_osabi_netbsd then "Hewlett-Packard HP-UX" else if Nat_big_num.equal m elf_osabi_netbsd then "NetBSD" else if Nat_big_num.equal m elf_osabi_gnu then "UNIX - GNU" else if Nat_big_num.equal m elf_osabi_linux then "Linux" else if Nat_big_num.equal m elf_osabi_solaris then "Sun Solaris" else if Nat_big_num.equal m elf_osabi_aix then "AIX" else if Nat_big_num.equal m elf_osabi_irix then "IRIX" else if Nat_big_num.equal m elf_osabi_freebsd then "FreeBSD" else if Nat_big_num.equal m elf_osabi_tru64 then "Compaq Tru64 Unix" else if Nat_big_num.equal m elf_osabi_modesto then "Novell Modesto" else if Nat_big_num.equal m elf_osabi_openbsd then "OpenBSD" else if Nat_big_num.equal m elf_osabi_openvms then "OpenVMS" else if Nat_big_num.equal m elf_osabi_nsk then "Hewlett-Packard Non-stop Kernel" else if Nat_big_num.equal m elf_osabi_aros then "Amiga Research OS" else if Nat_big_num.equal m elf_osabi_fenixos then "FenixOS highly-scalable multi-core OS" else if Nat_big_num.equal m elf_osabi_cloudabi then "Nuxi CloudABI" else if Nat_big_num.equal m elf_osabi_openvos then "Stratus technologies OpenVOS" else if is_valid_architecture_defined_osabi_version m then arch m else "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*) let ei_nident:Nat_big_num.num= ( (Nat_big_num.of_int 16)) (** [elf32_header] is the type of headers for 32-bit ELF files. *) type elf32_header = { elf32_ident : Uint32_wrapper.uint32 list (** 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. *) type elf64_header = { elf64_ident : Uint32_wrapper.uint32 list (** 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*) let is_valid_elf32_header hdr:bool= (listEqualBy (=) (Lem_list.take 4 hdr.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*) let is_valid_elf64_header hdr:bool= (listEqualBy (=) (Lem_list.take 4 hdr.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*) let elf32_header_compare h1 h2:int= (pairCompare (lexicographic_compare Nat_big_num.compare) (lexicographic_compare Nat_big_num.compare) (Lem_list.map Uint32_wrapper.to_bigint h1.elf32_ident, [Uint32_wrapper.to_bigint h1.elf32_type; Uint32_wrapper.to_bigint h1.elf32_machine ; Uint32_wrapper.to_bigint h1.elf32_version ; Uint32_wrapper.to_bigint h1.elf32_entry ; Uint32_wrapper.to_bigint h1.elf32_phoff ; Uint32_wrapper.to_bigint h1.elf32_shoff ; Uint32_wrapper.to_bigint h1.elf32_flags ; Uint32_wrapper.to_bigint h1.elf32_ehsize ; Uint32_wrapper.to_bigint h1.elf32_phentsize; Uint32_wrapper.to_bigint h1.elf32_phnum ; Uint32_wrapper.to_bigint h1.elf32_shentsize; Uint32_wrapper.to_bigint h1.elf32_shnum ; Uint32_wrapper.to_bigint h1.elf32_shstrndx]) (Lem_list.map Uint32_wrapper.to_bigint h2.elf32_ident, [Uint32_wrapper.to_bigint h2.elf32_type; Uint32_wrapper.to_bigint h2.elf32_machine ; Uint32_wrapper.to_bigint h2.elf32_version ; Uint32_wrapper.to_bigint h2.elf32_entry ; Uint32_wrapper.to_bigint h2.elf32_phoff ; Uint32_wrapper.to_bigint h2.elf32_shoff ; Uint32_wrapper.to_bigint h2.elf32_flags ; Uint32_wrapper.to_bigint h2.elf32_ehsize ; Uint32_wrapper.to_bigint h2.elf32_phentsize; Uint32_wrapper.to_bigint h2.elf32_phnum ; Uint32_wrapper.to_bigint h2.elf32_shentsize; Uint32_wrapper.to_bigint h2.elf32_shnum ; Uint32_wrapper.to_bigint h2.elf32_shstrndx])) let instance_Basic_classes_Ord_Elf_header_elf32_header_dict:(elf32_header)ord_class= ({ compare_method = elf32_header_compare; isLess_method = (fun f1 -> (fun f2 -> ( Lem.orderingEqual(elf32_header_compare f1 f2) (-1)))); isLessEqual_method = (fun f1 -> (fun f2 -> Pset.mem (elf32_header_compare f1 f2)(Pset.from_list compare [(-1); 0]))); isGreater_method = (fun f1 -> (fun f2 -> ( Lem.orderingEqual(elf32_header_compare f1 f2) 1))); isGreaterEqual_method = (fun f1 -> (fun f2 -> Pset.mem (elf32_header_compare f1 f2)(Pset.from_list compare [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*) let elf64_header_compare h1 h2:int= (pairCompare (lexicographic_compare Nat_big_num.compare) (lexicographic_compare Nat_big_num.compare) (Lem_list.map Uint32_wrapper.to_bigint h1.elf64_ident, [Uint32_wrapper.to_bigint h1.elf64_type; Uint32_wrapper.to_bigint h1.elf64_machine ; Uint32_wrapper.to_bigint h1.elf64_version ; Ml_bindings.nat_big_num_of_uint64 h1.elf64_entry ; Uint64_wrapper.to_bigint h1.elf64_phoff ; Uint64_wrapper.to_bigint h1.elf64_shoff ; Uint32_wrapper.to_bigint h1.elf64_flags ; Uint32_wrapper.to_bigint h1.elf64_ehsize ; Uint32_wrapper.to_bigint h1.elf64_phentsize; Uint32_wrapper.to_bigint h1.elf64_phnum ; Uint32_wrapper.to_bigint h1.elf64_shentsize; Uint32_wrapper.to_bigint h1.elf64_shnum ; Uint32_wrapper.to_bigint h1.elf64_shstrndx]) (Lem_list.map Uint32_wrapper.to_bigint h2.elf64_ident, [Uint32_wrapper.to_bigint h2.elf64_type; Uint32_wrapper.to_bigint h2.elf64_machine ; Uint32_wrapper.to_bigint h2.elf64_version ; Ml_bindings.nat_big_num_of_uint64 h2.elf64_entry ; Uint64_wrapper.to_bigint h2.elf64_phoff ; Uint64_wrapper.to_bigint h2.elf64_shoff ; Uint32_wrapper.to_bigint h2.elf64_flags ; Uint32_wrapper.to_bigint h2.elf64_ehsize ; Uint32_wrapper.to_bigint h2.elf64_phentsize; Uint32_wrapper.to_bigint h2.elf64_phnum ; Uint32_wrapper.to_bigint h2.elf64_shentsize; Uint32_wrapper.to_bigint h2.elf64_shnum ; Uint32_wrapper.to_bigint h2.elf64_shstrndx])) let instance_Basic_classes_Ord_Elf_header_elf64_header_dict:(elf64_header)ord_class= ({ compare_method = elf64_header_compare; isLess_method = (fun f1 -> (fun f2 -> ( Lem.orderingEqual(elf64_header_compare f1 f2) (-1)))); isLessEqual_method = (fun f1 -> (fun f2 -> Pset.mem (elf64_header_compare f1 f2)(Pset.from_list compare [(-1); 0]))); isGreater_method = (fun f1 -> (fun f2 -> ( Lem.orderingEqual(elf64_header_compare f1 f2) 1))); isGreaterEqual_method = (fun f1 -> (fun f2 -> Pset.mem (elf64_header_compare f1 f2)(Pset.from_list compare [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*) let is_elf32_executable_file hdr:bool= (Nat_big_num.equal (Uint32_wrapper.to_bigint hdr.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*) let is_elf64_executable_file hdr: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*) let hdr:bool= (Nat_big_num.equal (Uint32_wrapper.to_bigint hdr.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*) let hdr:bool= (Nat_big_num.equal (Uint32_wrapper.to_bigint hdr.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*) let is_elf32_relocatable_file hdr:bool= (Nat_big_num.equal (Uint32_wrapper.to_bigint hdr.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*) let is_elf64_relocatable_file hdr:bool= (Nat_big_num.equal (Uint32_wrapper.to_bigint hdr.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*) let is_elf32_linkable_file hdr:bool= (is_elf32_shared_object_file hdr || is_elf32_relocatable_file hdr) (** [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*) let is_elf64_linkable_file hdr:bool= (is_elf64_shared_object_file hdr || is_elf64_relocatable_file hdr) (** [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*) let get_elf32_machine_architecture hdr:Nat_big_num.num= (Uint32_wrapper.to_bigint hdr.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*) let get_elf64_machine_architecture hdr:Nat_big_num.num= (Uint32_wrapper.to_bigint hdr.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*) let get_elf32_osabi hdr:Nat_big_num.num= ((match Lem_list.list_index hdr.elf32_ident (Nat_big_num.to_int elf_ii_osabi) with | Some osabi -> Uint32_wrapper.to_bigint osabi | 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*) let get_elf64_osabi hdr:Nat_big_num.num= ((match Lem_list.list_index hdr.elf64_ident (Nat_big_num.to_int elf_ii_osabi) with | Some osabi -> Uint32_wrapper.to_bigint osabi | 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*) let get_elf32_data_encoding hdr:Nat_big_num.num= ((match Lem_list.list_index hdr.elf32_ident (Nat_big_num.to_int elf_ii_data) with | Some data -> Uint32_wrapper.to_bigint data | 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*) let get_elf64_data_encoding hdr:Nat_big_num.num= ((match Lem_list.list_index hdr.elf64_ident (Nat_big_num.to_int elf_ii_data) with | Some data -> Uint32_wrapper.to_bigint data | 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*) let get_elf32_file_class hdr:Nat_big_num.num= ((match Lem_list.list_index hdr.elf32_ident (Nat_big_num.to_int elf_ii_class) with | Some cls -> Uint32_wrapper.to_bigint cls | 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*) let get_elf64_file_class hdr:Nat_big_num.num= ((match Lem_list.list_index hdr.elf64_ident (Nat_big_num.to_int elf_ii_class) with | Some cls -> Uint32_wrapper.to_bigint cls | 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*) let get_elf32_version_number hdr:Nat_big_num.num= ((match Lem_list.list_index hdr.elf32_ident (Nat_big_num.to_int elf_ii_version) with | Some ver -> Uint32_wrapper.to_bigint ver | 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*) let get_elf64_version_number hdr:Nat_big_num.num= ((match Lem_list.list_index hdr.elf64_ident (Nat_big_num.to_int elf_ii_version) with | Some ver -> Uint32_wrapper.to_bigint ver | 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*) let is_valid_elf32_version_numer hdr:bool= (Nat_big_num.equal (get_elf32_version_number hdr) 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*) let is_valid_elf64_version_numer hdr:bool= (Nat_big_num.equal (get_elf64_version_number hdr) 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*) let get_elf32_abi_version hdr:Nat_big_num.num= ((match Lem_list.list_index hdr.elf32_ident (Nat_big_num.to_int elf_ii_abiversion) with | Some ver -> Uint32_wrapper.to_bigint ver | 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*) let get_elf64_abi_version hdr:Nat_big_num.num= ((match Lem_list.list_index hdr.elf64_ident (Nat_big_num.to_int elf_ii_abiversion) with | Some ver -> Uint32_wrapper.to_bigint ver | 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*) let deduce_endianness id2:endianness= ((match Lem_list.list_index id2 5 with | None -> failwith "deduce_endianness: read of magic number has failed" | Some v -> if Nat_big_num.equal (Uint32_wrapper.to_bigint v) elf_data_2lsb then Little else if Nat_big_num.equal (Uint32_wrapper.to_bigint v) elf_data_2msb then Big else failwith "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*) let get_elf32_header_endianness hdr: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*) let get_elf64_header_endianness hdr: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*) let has_elf32_header_associated_entry_point hdr:bool= (not (Nat_big_num.equal (Uint32_wrapper.to_bigint hdr.elf32_entry)( (Nat_big_num.of_int 0)))) (** [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*) let has_elf64_header_associated_entry_point hdr:bool= (not (Nat_big_num.equal (Ml_bindings.nat_big_num_of_uint64 hdr.elf64_entry)( (Nat_big_num.of_int 0)))) (** [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*) let has_elf32_header_string_table hdr:bool= (not (Nat_big_num.equal (Uint32_wrapper.to_bigint hdr.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*) let has_elf64_header_string_table hdr:bool= (not (Nat_big_num.equal (Uint32_wrapper.to_bigint hdr.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*) let is_elf32_header_section_size_in_section_header_table hdr:bool= (Nat_big_num.equal (Uint32_wrapper.to_bigint hdr.elf32_shnum)( (Nat_big_num.of_int 0))) (** [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*) let is_elf64_header_section_size_in_section_header_table hdr:bool= (Nat_big_num.equal (Uint32_wrapper.to_bigint hdr.elf64_shnum)( (Nat_big_num.of_int 0))) (** [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*) let is_elf32_header_string_table_index_in_link hdr:bool= (Nat_big_num.equal (Uint32_wrapper.to_bigint hdr.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*) let is_elf64_header_string_table_index_in_link hdr:bool= (Nat_big_num.equal (Uint32_wrapper.to_bigint hdr.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. *) type hdr_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*) let string_of_elf32_header (os, proc) hdr:string= (unlines [ ("\t" ^ ("Magic number: " ^ string_of_list instance_Show_Show_Elf_types_native_uint_unsigned_char_dict hdr.elf32_ident)) ; ("\t" ^ ("Endianness: " ^ string_of_endianness (deduce_endianness hdr.elf32_ident))) ; ("\t" ^ ("Type: " ^ string_of_elf_file_type os proc (Uint32_wrapper.to_bigint hdr.elf32_type))) ; ("\t" ^ ("Version: " ^ string_of_elf_version_number (Uint32_wrapper.to_bigint hdr.elf32_version))) ; ("\t" ^ ("Machine: " ^ string_of_elf_machine_architecture (Uint32_wrapper.to_bigint hdr.elf32_machine))) ; ("\t" ^ ("Entry point: " ^ Uint32_wrapper.to_string hdr.elf32_entry)) ; ("\t" ^ ("Flags: " ^ Uint32_wrapper.to_string hdr.elf32_flags)) ; ("\t" ^ ("Entries in program header table: " ^ Uint32_wrapper.to_string hdr.elf32_phnum)) ; ("\t" ^ ("Entries in section header table: " ^ Uint32_wrapper.to_string hdr.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*) let string_of_elf64_header (os, proc) hdr:string= (unlines [ ("\t" ^ ("Magic number: " ^ string_of_list instance_Show_Show_Elf_types_native_uint_unsigned_char_dict hdr.elf64_ident)) ; ("\t" ^ ("Endianness: " ^ string_of_endianness (deduce_endianness hdr.elf64_ident))) ; ("\t" ^ ("Type: " ^ string_of_elf_file_type os proc (Uint32_wrapper.to_bigint hdr.elf64_type))) ; ("\t" ^ ("Version: " ^ string_of_elf_version_number (Uint32_wrapper.to_bigint hdr.elf64_version))) ; ("\t" ^ ("Machine: " ^ string_of_elf_machine_architecture (Uint32_wrapper.to_bigint hdr.elf64_machine))) ; ("\t" ^ ("Entry point: " ^ Uint64_wrapper.to_string hdr.elf64_entry)) ; ("\t" ^ ("Flags: " ^ Uint32_wrapper.to_string hdr.elf64_flags)) ; ("\t" ^ ("Entries in program header table: " ^ Uint32_wrapper.to_string hdr.elf64_phnum)) ; ("\t" ^ ("Entries in section header table: " ^ Uint32_wrapper.to_string hdr.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*) let string_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*) let string_of_elf64_header_default:elf64_header ->string= (string_of_elf64_header (default_os_specific_print, default_proc_specific_print)) let instance_Show_Show_Elf_header_elf32_header_dict:(elf32_header)show_class= ({ show_method = string_of_elf32_header_default}) let instance_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)*) let read_elf_ident bs:((Uint32_wrapper.uint32)list*Byte_sequence_wrapper.byte_sequence)error= (repeatM' ei_nident bs (read_unsigned_char default_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*) let bytes_of_elf32_header hdr:Byte_sequence_wrapper.byte_sequence= (let endian = (deduce_endianness hdr.elf32_ident) in Byte_sequence.from_byte_lists [ Lem_list.map (fun u->Char.chr (Uint32_wrapper.to_int u)) hdr.elf32_ident ; bytes_of_elf32_half endian hdr.elf32_type ; bytes_of_elf32_half endian hdr.elf32_machine ; bytes_of_elf32_word endian hdr.elf32_version ; bytes_of_elf32_addr endian hdr.elf32_entry ; bytes_of_elf32_off endian hdr.elf32_phoff ; bytes_of_elf32_off endian hdr.elf32_shoff ; bytes_of_elf32_word endian hdr.elf32_flags ; bytes_of_elf32_half endian hdr.elf32_ehsize ; bytes_of_elf32_half endian hdr.elf32_phentsize ; bytes_of_elf32_half endian hdr.elf32_phnum ; bytes_of_elf32_half endian hdr.elf32_shentsize ; bytes_of_elf32_half endian hdr.elf32_shnum ; bytes_of_elf32_half endian hdr.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*) let bytes_of_elf64_header hdr:Byte_sequence_wrapper.byte_sequence= (let endian = (deduce_endianness hdr.elf64_ident) in Byte_sequence.from_byte_lists [ Lem_list.map (fun u->Char.chr (Uint32_wrapper.to_int u)) hdr.elf64_ident ; bytes_of_elf64_half endian hdr.elf64_type ; bytes_of_elf64_half endian hdr.elf64_machine ; bytes_of_elf64_word endian hdr.elf64_version ; bytes_of_elf64_addr endian hdr.elf64_entry ; bytes_of_elf64_off endian hdr.elf64_phoff ; bytes_of_elf64_off endian hdr.elf64_shoff ; bytes_of_elf64_word endian hdr.elf64_flags ; bytes_of_elf64_half endian hdr.elf64_ehsize ; bytes_of_elf64_half endian hdr.elf64_phentsize ; bytes_of_elf64_half endian hdr.elf64_phnum ; bytes_of_elf64_half endian hdr.elf64_shentsize ; bytes_of_elf64_half endian hdr.elf64_shnum ; bytes_of_elf64_half endian hdr.elf64_shstrndx ]) (*val is_elf32_header_padding_correct : elf32_header -> bool*) let is_elf32_header_padding_correct ehdr:bool= ((Lem.option_equal (=) (Lem_list.list_index ehdr.elf32_ident 9) (Some (Uint32_wrapper.of_bigint( (Nat_big_num.of_int 0))))) && ((Lem.option_equal (=) (Lem_list.list_index ehdr.elf32_ident 10) (Some (Uint32_wrapper.of_bigint( (Nat_big_num.of_int 0))))) && ((Lem.option_equal (=) (Lem_list.list_index ehdr.elf32_ident 11) (Some (Uint32_wrapper.of_bigint( (Nat_big_num.of_int 0))))) && ((Lem.option_equal (=) (Lem_list.list_index ehdr.elf32_ident 12) (Some (Uint32_wrapper.of_bigint( (Nat_big_num.of_int 0))))) && ((Lem.option_equal (=) (Lem_list.list_index ehdr.elf32_ident 13) (Some (Uint32_wrapper.of_bigint( (Nat_big_num.of_int 0))))) && ((Lem.option_equal (=) (Lem_list.list_index ehdr.elf32_ident 14) (Some (Uint32_wrapper.of_bigint( (Nat_big_num.of_int 0))))) && (Lem.option_equal (=) (Lem_list.list_index ehdr.elf32_ident 15) (Some (Uint32_wrapper.of_bigint( (Nat_big_num.of_int 0))))))))))) (*val is_magic_number_correct : list unsigned_char -> bool*) let is_magic_number_correct ident:bool= ((Lem.option_equal (=) (Lem_list.list_index ident 0) (Some (Uint32_wrapper.of_bigint( (Nat_big_num.of_int 127))))) && ((Lem.option_equal (=) (Lem_list.list_index ident 1) (Some (Uint32_wrapper.of_bigint( (Nat_big_num.of_int 69))))) && ((Lem.option_equal (=) (Lem_list.list_index ident 2) (Some (Uint32_wrapper.of_bigint( (Nat_big_num.of_int 76))))) && (Lem.option_equal (=) (Lem_list.list_index ident 3) (Some (Uint32_wrapper.of_bigint( (Nat_big_num.of_int 70)))))))) (** [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)*) let read_elf32_header bs:(elf32_header*Byte_sequence_wrapper.byte_sequence)error= (bind (read_elf_ident bs) (fun (ident, bs) -> if not (is_magic_number_correct ident) then fail "read_elf32_header: magic number incorrect" else let endian = (deduce_endianness ident) in bind (read_elf32_half endian bs) (fun (typ, bs) -> bind (read_elf32_half endian bs) (fun (machine, bs) -> bind (read_elf32_word endian bs) (fun (version, bs) -> bind (read_elf32_addr endian bs) (fun (entry, bs) -> bind (read_elf32_off endian bs) (fun (phoff, bs) -> bind (read_elf32_off endian bs) (fun (shoff, bs) -> bind (read_elf32_word endian bs) (fun (flags, bs) -> bind (read_elf32_half endian bs) (fun (ehsize, bs) -> bind (read_elf32_half endian bs) (fun (phentsize, bs) -> bind (read_elf32_half endian bs) (fun (phnum, bs) -> bind (read_elf32_half endian bs) (fun (shentsize, bs) -> bind (read_elf32_half endian bs) (fun (shnum, bs) -> bind (read_elf32_half endian bs) (fun (shstrndx, bs) -> (match Lem_list.list_index ident 4 with | None -> fail "read_elf32_header: transcription of ELF identifier failed" | Some c -> if Nat_big_num.equal (Uint32_wrapper.to_bigint c) elf_class_32 then return ({ 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) else fail "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)*) let read_elf64_header bs:(elf64_header*Byte_sequence_wrapper.byte_sequence)error= (bind (read_elf_ident bs) (fun (ident, bs) -> if not (is_magic_number_correct ident) then fail "read_elf64_header: magic number incorrect" else let endian = (deduce_endianness ident) in bind (read_elf64_half endian bs) (fun (typ, bs) -> bind (read_elf64_half endian bs) (fun (machine, bs) -> bind (read_elf64_word endian bs) (fun (version, bs) -> bind (read_elf64_addr endian bs) (fun (entry, bs) -> bind (read_elf64_off endian bs) (fun (phoff, bs) -> bind (read_elf64_off endian bs) (fun (shoff, bs) -> bind (read_elf64_word endian bs) (fun (flags, bs) -> bind (read_elf64_half endian bs) (fun (ehsize, bs) -> bind (read_elf64_half endian bs) (fun (phentsize, bs) -> bind (read_elf64_half endian bs) (fun (phnum, bs) -> bind (read_elf64_half endian bs) (fun (shentsize, bs) -> bind (read_elf64_half endian bs) (fun (shnum, bs) -> bind (read_elf64_half endian bs) (fun (shstrndx, bs) -> (match Lem_list.list_index ident 4 with | None -> fail "read_elf64_header: transcription of ELF identifier failed" | Some c -> if Nat_big_num.equal (Uint32_wrapper.to_bigint c) elf_class_64 then return ({ 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) else fail "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*) let is_elf32_header_class_correct ehdr:bool= (Lem.option_equal (=) (Lem_list.list_index ehdr.elf32_ident 4) (Some (Uint32_wrapper.of_bigint( (Nat_big_num.of_int 1))))) (** [is_elf64_header_class_correct hdr] checks whether the declared file class * is correct. *) (*val is_elf64_header_class_correct : elf64_header -> bool*) let is_elf64_header_class_correct ehdr:bool= (Lem.option_equal (=) (Lem_list.list_index ehdr.elf64_ident 4) (Some (Uint32_wrapper.of_bigint( (Nat_big_num.of_int 1))))) (** [is_elf32_header_version_correct hdr] checks whether the declared file version * is correct. *) (*val is_elf32_header_version_correct : elf32_header -> bool*) let is_elf32_header_version_correct ehdr:bool= (Lem.option_equal (=) (Lem_list.list_index ehdr.elf32_ident 6) (Some (Uint32_wrapper.of_bigint( (Nat_big_num.of_int 1))))) (** [is_elf64_header_version_correct hdr] checks whether the declared file version * is correct. *) (*val is_elf64_header_version_correct : elf64_header -> bool*) let is_elf64_header_version_correct ehdr:bool= (Lem.option_equal (=) (Lem_list.list_index ehdr.elf64_ident 6) (Some (Uint32_wrapper.of_bigint( (Nat_big_num.of_int 1))))) (** [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*) let is_elf32_header_valid ehdr:bool= (Nat_big_num.equal (Nat_big_num.of_int (List.length ehdr.elf32_ident)) ei_nident && (is_magic_number_correct ehdr.elf32_ident && (is_elf32_header_padding_correct ehdr && (is_elf32_header_class_correct ehdr && is_elf32_header_version_correct ehdr)))) (** [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*) let get_elf32_header_program_table_size ehdr:Nat_big_num.num= (let phentsize = (Uint32_wrapper.to_bigint ehdr.elf32_phentsize) in let phnum = (Uint32_wrapper.to_bigint ehdr.elf32_phnum) in Nat_big_num.mul phentsize phnum) (** [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*) let get_elf64_header_program_table_size ehdr:Nat_big_num.num= (let phentsize = (Uint32_wrapper.to_bigint ehdr.elf64_phentsize) in let phnum = (Uint32_wrapper.to_bigint ehdr.elf64_phnum) in Nat_big_num.mul phentsize phnum) (** [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*) let is_elf32_header_section_table_present ehdr:bool= (not ( Nat_big_num.equal(Uint32_wrapper.to_bigint ehdr.elf32_shoff)( (Nat_big_num.of_int 0)))) (** [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*) let is_elf64_header_section_table_present ehdr:bool= (not ( Nat_big_num.equal(Uint64_wrapper.to_bigint ehdr.elf64_shoff)( (Nat_big_num.of_int 0)))) (** [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*) let get_elf32_header_section_table_size ehdr:Nat_big_num.num= (let shentsize = (Uint32_wrapper.to_bigint ehdr.elf32_shentsize) in let shnum = (Uint32_wrapper.to_bigint ehdr.elf32_shnum) in Nat_big_num.mul shentsize shnum) (** [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*) let get_elf64_header_section_table_size ehdr:Nat_big_num.num= (let shentsize = (Uint32_wrapper.to_bigint ehdr.elf64_shentsize) in let shnum = (Uint32_wrapper.to_bigint ehdr.elf64_shnum) in Nat_big_num.mul shentsize shnum)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>