Compare commits

..
304 Commits
1.0 .. d
Author SHA1 Message Date
pancake 7ec6dbcf88 Release 4.0 2019-10-28 16:52:59 +01:00
pancake bc6d3f36da Import r2ida from https://github.com/radare/radare2ida 2019-10-28 11:03:42 +01:00
Sylvain Pelissier 96d68f14ed Microblaze ESIL update (#215)
* Corrected jumps and remove git messages
* Add ESIL for right shift and correct imm value
* Separate branch with immediate instructions
2019-10-16 12:52:27 +02:00
dependabot[bot] a67e7f0adb Bump lodash from 4.17.11 to 4.17.15 in /r2jadx (#213)
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.11 to 4.17.15.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.11...4.17.15)

Signed-off-by: dependabot[bot] <[email protected]>
2019-10-07 18:24:45 +08:00
dependabot[bot] 7125f795b4 Bump eslint-utils from 1.3.1 to 1.4.2 in /r2jadx (#212)
Bumps [eslint-utils](https://github.com/mysticatea/eslint-utils) from 1.3.1 to 1.4.2.
- [Release notes](https://github.com/mysticatea/eslint-utils/releases)
- [Commits](https://github.com/mysticatea/eslint-utils/compare/v1.3.1...v1.4.2)

Signed-off-by: dependabot[bot] <[email protected]>
2019-10-07 18:24:36 +08:00
Sylvain Pelissier 6ad247901d Update test to use NodeJS 10 (#211) 2019-10-07 17:24:36 +08:00
Maijin 7ecb70cd26 Change radare->radareorg links 2019-10-07 10:53:33 +02:00
Sylvain Pelissier f90380fc23 Improvements for Microblaze ESIL of jump an return operations 2019-10-07 15:53:45 +08:00
Anton Kochkov a0d0c360da Fix urls 2019-10-07 15:48:54 +08:00
Anton Kochkov 80e37a663d Fix urls 2019-10-07 15:48:15 +08:00
pancake fb3c96694e Add checkm8 io plugin 2019-09-30 20:01:56 +02:00
Sylvain Pelissier 2ee3d1153b Microblaze add calls and delay branch (#209) 2019-09-24 20:19:46 +02:00
Sylvain Pelissier 972e774df8 Add Travis CI test for Microblaze and update ESIL (#207) 2019-09-18 14:15:21 +02:00
pancake 4325c5c797 Release 3.9.0 2019-09-17 18:50:05 +02:00
Sylvain Pelissier 738ed6451c Improve Microblaze ESIL ##anal (#206) 2019-09-16 09:36:43 +02:00
Sylvain Pelissier d686d94c0e Correct pointer for r_str_newf function (#205) 2019-09-10 13:25:21 +02:00
Sylvain Pelissier 86a32aa11e Handle negative immediate values in instructions (#204) 2019-09-08 19:09:49 +02:00
pancake 0d830052ad Release 3.7.0 2019-08-01 05:10:31 +02:00
pancake cb31b4c934 Fixes and improvements in cmdline handling and such for r2snow 2019-07-24 12:06:33 +02:00
pancake 78336f4977 More fixes for r2snow 2019-07-24 06:45:43 +02:00
pancake 85f79f83b3 Import snowman output as comments into r2 in r2snow 2019-07-24 04:41:53 +02:00
pancake 940dfec369 More fixes and ipmrovements for r2jadx 2019-07-11 06:45:45 +02:00
pancake 807d1999c0 Update r2pipe dependency for r2jadx 2019-07-10 20:15:31 +02:00
pancake b74f1d306b Lots of improvements for r2jadx! 2019-07-10 12:54:43 +02:00
pancake 3134973ee0 Fix indent and add one more try/catch block 2019-07-09 15:42:37 +02:00
pancake 6993b40789 Use --illegal-access=warn 2019-07-09 15:39:04 +02:00
pancake f54381e411 Add missing md380 Makefile 2019-07-09 15:34:21 +02:00
pancake bd89b33d1a Add ^C message 2019-07-09 15:33:55 +02:00
pancake 96a6b07921 Check for jadx version and use r2pipe.isAvailable() after upgrading dependencies 2019-07-09 15:24:39 +02:00
pancake 05f76e5578 Release 3.6.0 2019-06-24 15:49:47 +02:00
pancake 2e8fac708c Initial working version of r2jadx 2019-06-21 10:27:44 +02:00
pancake c7ffc478e5 Initial implementation of r2jadx 2019-06-16 20:15:02 +02:00
meme c276d25c57 Update <mybfd.h> to reflect the static inlining of bfd_get_bits
https://github.com/radare/radare2/blob/master/libr/asm/arch/include/mybfd.h#L584-L585
2019-06-15 16:35:17 +02:00
dissonant-research c45284dab5 Switching from RIOSection to RIOMap in unicorn debug 2019-05-24 09:27:58 +02:00
pancake e9b20fb9eb Release 3.5.0 2019-05-13 11:18:56 +02:00
pancake cabcd22f39 refix 2019-04-26 00:28:49 +02:00
pancake 65b16c4ea2 Fix build for udis 2019-04-26 00:25:37 +02:00
pancake 32caa03626 Fix bin-md380 crash 2019-04-20 11:48:55 +02:00
pancake 710bd658e3 Implement loadbuffer ni md380 2019-04-20 02:17:43 +02:00
pancake a39b5dfac7 Fix build of md380 bin 2019-04-20 02:15:27 +02:00
pancake 207a4677a1 Initial import of the r2emuhash 2019-04-14 13:35:49 +02:00
pancake 9eb4ca72bb Release 3.4.0 2019-04-01 22:16:24 +02:00
Fedor Sakharov 0459dfa816 fixes trimmed last bytes in disassembly (#195)
Fixes #194
2019-03-10 23:20:46 +08:00
pancake d8517a28ec Fix truncated numbers issue 2019-03-08 19:44:30 +01:00
pancake 5a0cc39fac Release 3.3.0 2019-02-19 14:50:08 +01:00
Andrew Barbarello 5883f35f20 yara-r2: replace r_io_read_at with r_io_pread_at
r_io_read_at is deprecated, and the intention is clearly to read all
bytes of the current file to be scanned with yara rules.
2019-02-17 16:25:15 +01:00
Andrew Barbarello 93f603828e yara-r2: remove unused yara2 sigs/refs to yara2 2019-02-17 16:25:15 +01:00
Andrew Barbarello fdcd534137 yara-r2: install to R2PM_USERPLUGIN_DIR
Makefile was using `R2_PLUGDIR`, which is no longer exported in
environment by `r2pm`, see
https://github.com/radare/radare2/issues/12751 .

Instead, we use `R2PM_USRPLUGIN_DIR`. Also update
`r_cmd_yara_load_default_rules` to load yara3 rules from the correct
path
2019-02-17 16:25:15 +01:00
Maijin 37e60e452c Add pcap in r2r-extras travis 2019-01-03 22:12:26 +01:00
Francesco Tamagni 43be0652d4 Move BPF plugin here 2018-12-31 20:27:38 +01:00
Stevie Johnstone 9d081e9f84 Fix unicorn README. dh is now dL 2018-12-30 01:36:32 +01:00
Stevie Johnstone 277114e466 Fix unicorn plugin build
* debug_evm.so was being built instead of debug_unicorn.so fix Makefiles
* "sections" is now an SdbList
* debug interface has changed to take RDebug* as the first argument
* "flags" member is now "perm"
* R_IO_READ and friends are now R_PERM_R etc
2018-12-30 01:36:32 +01:00
Federico G. Schwindt b2244eb386 More fixes to get these building (#187)
While here silence some warnings and simplify.
2018-12-20 12:24:28 +01:00
Federico G. Schwindt 038878331c Fix compilation (#186)
* Add missing object file

* Correctly append the insn

* Fix compilation
2018-12-19 15:18:55 +01:00
pancake 7436fe335a Missing ; 2018-12-04 17:05:47 +01:00
pancake 5be184ad09 Add one more NE url reference 2018-12-04 15:39:41 +01:00
pancake 412a2b3c10 Add NE and JNI headers 2018-12-04 15:39:11 +01:00
pancake e369064b38 Release 3.1.0 2018-11-26 04:24:12 +01:00
Sebastien Alaiwan 4c6150eb72 Use new buf_asm interface for mycpu example plugin (#183) 2018-11-21 13:53:44 +01:00
Sebastien Alaiwan 111f9716de Add Jaguar GPU disassembler (#184) 2018-11-21 13:32:27 +01:00
Giovanni 87cf193fa9 Update README.md (#182) 2018-11-19 13:03:21 +01:00
pancake a5a5d23273 Release 3.0.1 2018-11-09 17:49:04 +01:00
condret 7db8694ccf refix bale anal-plugin (use the new interrupt api) (#177) 2018-10-21 18:41:49 +02:00
Fedor Sakharov c9268f928d fixes r_io flags in io_evm (#180) 2018-10-21 18:41:40 +02:00
Fedor Sakharov bc5297eb66 Fixes permissions flag for the EVM plugin (#179) 2018-10-21 15:50:40 +02:00
Christopher Hewitt fe6b3f0356 nios: Update to match new RasmOp API. (#178) 2018-10-21 13:26:12 +02:00
pancake 6a2b0792bd Fix some more asm plugins, more to go! 2018-10-18 19:09:41 +02:00
pancake 49b143ecec Fix snprintf issue in last baleful commit 2018-10-18 19:02:22 +02:00
pancake 78aae788e2 Delete unnecessary yara/build.mk 2018-10-18 17:47:12 +02:00
pancake d6dac273e9 Start to improve the makefiles and add missing bitcoin.h 2018-10-18 17:46:14 +02:00
d4em0n 3edba75c46 Bring back the missing dmangle.d 2018-10-18 17:08:53 +02:00
skuater f5743ad7ee fixed baleful 2018-10-18 16:05:38 +02:00
pancake 7f322a2194 Fix #175 - build for udis86 plugin 2018-10-16 22:36:21 +02:00
pancake b22e3a37ef Add r2elisa 2018-10-04 02:40:51 +02:00
Fedor Sakharov 0d721e2d33 Fixes long push operands display (#171) 2018-09-20 19:20:03 +02:00
pancake d087a6076e Release 2.9.0 2018-09-04 02:08:10 +02:00
Fedor Sakharov 2479d03e9d Updates EVM code for the new RasmOp API (#169) 2018-09-03 10:16:22 +02:00
David Douard 26650ee04e mc6809: update to match new RasmOp API (#168) 2018-08-31 18:00:09 +02:00
Rene Laemmert 63ecdc603a fix usage of RStrBuf in keystone.c 2018-08-26 17:30:33 +02:00
pancake 0c43eec6cf Refix olly(2) 2018-08-25 13:50:19 +02:00
pancake 3b8c967d7d Refix olly 2018-08-25 13:49:46 +02:00
pancake ec86d7d221 Fix atom and x86 plugins 2018-08-25 13:47:45 +02:00
pancake 206108514e Release 2.8.0 2018-08-14 16:15:17 +02:00
Maijin 25d39975d5 Add more R2_ prefix for some var 2018-08-07 22:15:32 +02:00
pancake af308ea3bd Release radare2-extras 2.7.0 2018-07-09 16:17:36 +02:00
pancake 89bf3cc1e7 Fix build of lief 2018-06-20 19:51:20 +02:00
Christopher Hewitt becc4cfb70 nios: Update libr/Makefile for r2pm plugin use. 2018-06-08 00:37:10 +02:00
Christopher Hewitt f00cecbc5f nios: Add nios to libr/asm/Makefile. 2018-06-07 09:42:28 +02:00
Christopher Hewitt 1a56c842e1 nios: Working disassembler plugin. 2018-06-07 09:42:28 +02:00
Christopher Hewitt 33882645ba nios: Update dis-asm.h and mybfd.h. 2018-06-07 09:42:28 +02:00
Christopher Hewitt cb010aff69 nios: Manually merge in contemporary binutils code and other fixes for modern compilers. 2018-06-07 09:42:28 +02:00
Christopher Hewitt e809b61b47 nios: Add missing headers and support code. 2018-06-07 09:42:28 +02:00
Christopher Hewitt 956b3aaf14 nios: Import cpu definitions from bfd and cgen opcodes support code. 2018-06-07 09:42:28 +02:00
Christopher Hewitt f64cec8e36 nios: Create asm_nios target. Update mybfd.h. 2018-06-07 09:42:28 +02:00
Christopher Hewitt 7028bab425 nios: Initial import of nios binutils. 2018-06-07 09:42:28 +02:00
pancake 5a9d5c4b36 Fix overflow in swf 2018-06-06 17:55:48 +02:00
Damien Zammit ec624bef6f dwarf: Fix broken test 2018-06-02 17:01:24 +02:00
Damien Zammit 6f5fa00837 x86zyan: Fix broken test 2018-06-02 17:01:24 +02:00
Damien Zammit 525c42ef94 yara: Fix broken test 2018-06-02 17:01:24 +02:00
Damien Zammit 9127f0e92d TESTS: Comment out broken tests, add build id where it broke 2018-06-02 17:01:24 +02:00
Damien Zammit f41d4b1305 travis: Install rust as default, use gcc-7, 14.04 and install GNU make 2018-06-02 17:01:24 +02:00
Damien Zammit 9b6801955e atombios: Improvements
- Include local data blocks as locs
- Autodetect binary fix
- Include global data blocks as sections
- Add ESIL to resolve data from tables
- Bugfix ESIL for various instructions
- Bugfix ESIL for jmp conditions
- Easier to read disasm, still with ESIL support
2018-05-30 14:27:02 +08:00
Anton Kochkov b64bc715dc Enable sudo for Travis 2018-05-30 14:22:15 +08:00
Damien Zammit d2137ab4e4 atombios: disasm + analysis + bin plugins (#158) 2018-05-26 12:32:51 +02:00
pancake 1780ea5dd2 Add task_struct pointer field in the proc_info struct 2018-05-25 22:19:55 +10:00
pancake d2e83eda06 Fix format string 2018-05-25 13:03:42 +02:00
pancake 5445b2ae79 Release 2.6.0 and generate acr files with 1.6.2 2018-05-21 18:39:01 +02:00
pancake 1e04d8b4e9 +x r2crash.js 2018-04-23 02:11:57 +02:00
pancake aad642538c Use enum instead of define 2018-04-12 11:20:51 +02:00
pancake 938e608c62 Initial import of types/ 2018-04-12 11:14:35 +02:00
ilovezfs 8cce5eb0a4 x86_udis.mk: also pass LDFLAGS (#154) 2018-04-11 16:33:28 +02:00
pancake 4d45b13de6 Release 2.5.0 2018-04-10 00:07:10 +02:00
pancake 99fb4669ad Fix copies from protected zones in r2k 2018-04-03 14:33:36 +02:00
pancake c8c7fdfa6b Fix copy_to_user crash in r2k (happening in linux64 4.15 kernels) 2018-04-02 22:18:01 +02:00
pancake bf73b81148 Use more void*, %p and build fixes in r2k-linux 2018-04-02 19:58:34 +02:00
pancake 30750b1843 Update cr3/cr4 code in r2k for kernels 4.9 and 4.13 2018-04-02 19:34:15 +02:00
pancake 5f74c1cc3c Fix build of r2k on linux4, crashes everywhere 2018-04-02 14:21:25 +02:00
pancake 4088f4a750 Add install and uninstall targets 2018-03-29 05:08:32 +02:00
pancake 714c551579 Add build instructions in readme 2018-03-29 05:03:47 +02:00
pancake 5c9d831a58 Initial import of the r2tox plugin 2018-03-29 04:56:33 +02:00
wavvs 41b78ff52a Fix cloning to non-empty existing directory (#139) (#140) 2018-03-19 15:11:43 +01:00
GNU fbc790d5c9 update x86_udis.mk (#151) 2018-03-19 15:09:56 +01:00
pancake 76f80bbadd Add blackfin build 2018-03-15 00:34:29 +01:00
pancake c96395e089 Fix udis build 2018-03-15 00:31:57 +01:00
pancake 4410acf12c Add x86udis for travis 2018-03-15 00:21:36 +01:00
pancake cfc652101a Fix udis regprofile 2018-03-15 00:15:57 +01:00
pancake 3bd9f11283 Fix anal.x86.udis build 2018-03-14 23:49:15 +01:00
pancake 8582da5145 Add generic udis86 target 2018-03-14 22:43:47 +01:00
pancake 882fbe49b8 Import the anal.x86.udis plugin from core 2018-03-14 22:36:05 +01:00
pancake 60285a5370 Initial import of the asm.x86.udis86 plugin
Moved from radare2 (core)
2018-03-14 22:34:04 +01:00
pancake 409a0e7a45 Release 2.4.0 2018-03-05 18:24:30 +01:00
Silur 7d0fee72b2 byzantium opcodes (#149) 2018-02-25 10:32:27 +01:00
pancake 3f594da048 Release 2.3.0 2018-02-06 14:45:11 +01:00
pancake cd73547b05 Add r2crash script to generate r2 scripts out of Mac crashlogs 2018-01-29 11:24:28 +01:00
Fedor Sakharov 49183314d8 Fix for initial declarations in debug_evm.c (#146) 2017-12-25 16:25:16 +01:00
Fedor Sakharov 52bd0b571a Add targets for EVM so r2pm works (#145) 2017-12-25 13:52:39 +01:00
pancake 010ade6bf6 Release 2.2.0 2017-12-24 19:05:49 +01:00
Fedor Sakharov a912bd66ea Evm improvements (#144)
* Fix warnings in anal_evm.c

* Correctly handle error codes in io_evm.c

* io_evm has to use application/json headers

* Read evm function signatures from file

* Fix opcode types in EVM

* Fix sizes of DUPn commands in EVM

* io_evm now reads stack backwards

* Brings anal-evm to build

* Move to radare-specific types

* Fix warnings

* Store all push addrs to sdb to use for jump opcodes

* Removes debug prints

* Adds anal-install target to Makefile.acr

* Fix memleaks in EVM sdb usage
2017-12-12 20:04:50 +01:00
pancake 9214455cd5 Release 2.1.0 2017-11-27 13:33:37 +01:00
Fedor Sakharov 5cd7a4e8d7 Init the rioevm pointer (#143) 2017-11-21 14:57:03 +01:00
Fedor Sakharov 791aa4a7cc Moves EVM code from core here (#141)
* Fix Makefile in libr/debug/p

Now we work like the rest of the makefiles

* Improves EVM support.

Adds anal, io and debug plugins.

* Adds io plugins to Makefile.acr
2017-11-21 01:30:45 +01:00
pancake d6793dd540 Add missing plugin symbol for the lua disassembler. wtf 2017-11-17 14:57:08 -05:00
pancake 7616dfd553 Some fixes for swf, but still many more bugs going on 2017-11-16 12:25:40 -05:00
pancake 589d5645af Fix lua plugin build 2017-11-16 10:35:17 -05:00
pancake 08cbe6baac Fix hang on mac 2017-11-14 15:41:16 +09:00
Anton Kochkov a54be9a48b Fix linux build [2] 2017-11-14 14:06:30 +08:00
Anton Kochkov f69fb9dcdc Fix fs-squash linux build 2017-11-14 14:01:56 +08:00
pancake 03fcaf700e Fixes for squashfs 2017-11-14 10:31:43 +09:00
pancake 389d9f0c3c Honor delta for squashfs 2017-11-11 13:40:01 +09:00
Alex Kornitzer 5acc166c8b mdmp: removed mdmp as it has been added to the core (#137) 2017-11-10 19:01:16 +08:00
pancake b27bf9c5be More fixes for squashfs 2017-11-08 02:16:16 +01:00
pancake d97908145b Fix infinite loop on error 2017-11-08 01:17:54 +01:00
pancake 70b57f0446 Add license and fix cat in squashfs 2017-11-08 00:44:19 +01:00
pancake 484e34194a Initial working version of the fs_squashfs plugin 2017-11-08 00:28:53 +01:00
pancake b265df6684 Unixify unsquashfs, half-way to become an api and an r2 plug 2017-11-07 22:47:31 +01:00
pancake 333f05f36b Cleanup README 2017-10-26 11:39:40 +02:00
pancake 9280c200d6 Initial import of the r2k for mac (based on Frida's earlier kernel agent) 2017-10-20 12:54:05 +02:00
pancake 4f9dfe81a4 Release 2.0.0 2017-10-09 17:11:39 +02:00
Alex Kornitzer 07a53ae50a mdmp: bump to latest pe changes 2017-10-03 00:21:12 +08:00
Alex Kornitzer 1be1b5af58 travis: actually test the pull requests 2017-10-02 23:45:24 +08:00
Ayman Khamouma (ak42) ec0f676dd5 pimp: sync with pimp's repo (#134) 2017-09-12 11:40:21 +02:00
pancake 043b7ccec4 Indent fixes for r2k-linux 2017-09-11 00:37:17 +02:00
pancake f5725ba1d9 Do not define debug_unicorn build rules twice 2017-08-14 18:45:40 +02:00
SkUaTeR b9f47a9eac Update README.md 2017-08-14 00:14:45 +02:00
SkUaTeR 8719d50ac7 Update README.md 2017-08-13 16:17:27 +02:00
SkUaTeR b833e5c841 Update README.md 2017-08-13 16:12:49 +02:00
SkUaTeR a556cacc6e Update README.md 2017-08-13 16:11:42 +02:00
SkUaTeR ea6b669030 Update README.md 2017-08-13 16:10:56 +02:00
SkUaTeR 224eaab256 Update README.md 2017-08-08 22:50:36 +02:00
SkUaTeR 5c342711fe Update README.md 2017-08-03 23:35:36 +02:00
Stanisław Drozd 64fb679d01 r2wars: fix the misspelled name of the original game (#130)
* r2wars: fix the misspelled name of the original game

* r2wars: fix another typo
2017-08-03 14:59:49 +02:00
Alex Kornitzer e1e415d53f mdmp: Added custom binary info (#129)
Added useful variables from the MDMP header into the binary infos
section.
2017-08-02 16:08:53 +02:00
pancake 38354a8a90 Add options on top 2017-08-01 14:52:54 +02:00
pancake 6a53c991b6 Update readme with Q&A 2017-08-01 14:40:08 +02:00
pancake 7cbf405c72 Add mips, gb and x86 programs for r2wars
- Some instructions fail to assemble for gb and mips
2017-08-01 05:51:45 +02:00
pancake 53e61e6397 Fix not-enough-memory in r2wars 2017-07-30 12:33:08 +02:00
Alex Kornitzer 276d44a93e MDMP - r2 v1.7 Compatability (#128)
* Brought in the latest changes for v1.7

Updated the pe files. Also set the has_lit boolean to true to fix
plt resolving.

* Fixed incorrect Travis pathing
2017-07-30 03:57:46 +02:00
pancake 99d91566be Add dummy PE.lief plugin 2017-07-26 12:59:35 +02:00
pancake a874ce793c Add make uninstall 2017-07-26 12:22:30 +02:00
pancake 121b598f2e Add WIP non working mach0.lief plugin 2017-07-26 12:03:54 +02:00
pancake 3471a94802 Clean code 2017-07-26 00:55:10 +02:00
pancake 482e9a890d Initial import of the elf.lief plugin for r2 2017-07-26 00:51:25 +02:00
SrimantaBarua 1d764b5a8f add ipv6 2017-07-23 13:38:58 +08:00
alvarofe 1b6a772bc7 Revert "Add r2pm update into .travis.yml"
This reverts commit 32f00c056d.
2017-07-11 22:52:47 +02:00
alvarofe 32f00c056d Add r2pm update into .travis.yml 2017-07-11 22:09:02 +02:00
pancake 85464f68d4 Release 1.6.0 2017-07-11 19:54:37 +02:00
pancake ef23c6cd76 Many enhancements for the r2wars
* implement curses interface (no colors, but better)
* refactor a bit the code into functions
* properly report who wins and who dies
* realign columns depending on the terminal size
* wrap lines to avoid overflows or glitches
* generate graph output for competition
* doesnt accept two files with the same filename
2017-07-06 05:20:52 +02:00
pancake a68d45230f Fix r2wars 2017-07-06 00:55:29 +02:00
Rakholiya Jenish 311f54c60e fix get_num_from_attr, add help, improve json output, fix type output (#123)
full json print for structname.member..
2017-07-03 14:02:36 +02:00
pancake c53d9fcdb8 Implement some more randomness for r2wars 2017-06-18 00:39:16 +02:00
pancake b9f835e569 Update r2wars README 2017-06-12 12:29:47 +02:00
Rakholiya Jenish 4ec480b96d re-write dwarf plugin with added support for better array output and (#121)
json support for iddd command
2017-06-12 10:00:59 +02:00
pancake 1817227d1b Initial import of the r2wars game 2017-06-10 21:23:58 +02:00
pancake c35dcb2f65 After release version bump, Do not plugins/plugins in md380.bin 2017-05-31 11:56:24 +02:00
pancake 865a076436 Release 1.5.0 2017-05-30 19:53:19 +02:00
pancake df94e8a510 Fixes for md380fw 2017-05-29 03:08:16 +02:00
pancake faeb33da9e Move r2angr one directory up 2017-05-23 03:59:29 +02:00
Ayman Khamouma 9a4ddb04a6 add pimp plugin (#119) 2017-05-21 10:05:50 +02:00
pancake 2fd1ec9eb5 Fix yara-r2 plugin warnings 2017-05-20 20:46:32 +02:00
pancake f672f22e30 Initial implementation of r2angr 2017-05-18 04:40:24 +02:00
pancake e9d1003969 Remove install-yara because it's available via r2pm 2017-05-10 15:07:06 +02:00
pancake 47501d1019 Add libgmp for Travis 2017-04-20 15:56:12 +02:00
pancake 30de74c83f Fix unicorn 2017-04-20 14:45:47 +02:00
pancake f2e6a5ba2a Fix warning 2017-04-20 14:40:38 +02:00
pancake b2c4a45811 Add swf and pyc targets 2017-04-20 14:40:17 +02:00
pancake 9af983bad7 Fix swf 2017-04-20 14:38:25 +02:00
pancake 4acb86db3c Release 1.4.0 2017-04-20 13:23:14 +02:00
pancake ebbea9c2e6 Fix yara pkgnames 2017-04-20 13:16:25 +02:00
pancake 6edae6dd01 Fix build of pyc 2017-04-20 13:15:04 +02:00
pancake a969cd8307 Aim to fix a linking issue 2017-04-20 13:11:21 +02:00
pancake 63cc7a0ec5 Link bin.pyc against gmp 2017-04-20 13:09:55 +02:00
pancake 2531177e5f Fix pyc 2017-04-20 13:08:40 +02:00
pancake 0e5a9b1501 Fix duktape for travis 2017-04-20 13:06:17 +02:00
pancake 0587b582f5 Support home installations of yara 2017-04-19 11:35:21 +02:00
pancake 8844031058 Fix build of the yara plugin for r2 2017-04-19 11:23:02 +02:00
pancake 0d5cba5913 Remove tms320c64x plugin, which is now in master 2017-04-18 11:25:47 +02:00
Srimanta Barua deaa4d5546 Initial pcap plugin (#116)
* Loaded pcap file

* Added info about network type

* Initial loading of symbols at structures

* Added strings

* Separated into functions

* Fixed tcp endianness issue

* Fixed incorrect comment

* Removed unneeded RList
2017-04-17 12:59:57 +02:00
Alex Kornitzer d374445ae5 The next round of fixes needed due to core changes (#115) 2017-04-15 18:27:53 +02:00
pancake 8e2d5b7688 rar disassembler and bin plugin moved from r2 to r2e 2017-04-11 13:51:10 +02:00
l0stb1t d38637e950 Fix build issues, adding more error checking, fix many small issues (#110)
* Fix pyc support
* Adding more pyc objects. This code is not 100% corret yet
* Fix some copy-paste errors
* Add interned type support
* Adding more error checking, fix many small issues, currently not support python3 yet
2017-04-10 01:05:21 +02:00
pancake 3dd04865d5 Add uncommited z80 files 2017-04-10 01:04:21 +02:00
pancake be859f20a8 Makeile tweaks for the x86-zyan plugin 2017-04-10 01:03:43 +02:00
Duncan Ogilvie 5a80650a47 added zyan disassembler plugin (#113) 2017-04-09 10:44:36 +02:00
Guillaume Valadon 072dd8d8d9 Support the new plugin API (#112) 2017-04-06 16:54:59 +02:00
pancake ea05bf15c5 Fix last coverities for lua53 2017-04-05 10:38:20 +02:00
pancake f508660134 Use r2-indent and fix some memleaks 2017-04-05 10:28:21 +02:00
pancake ba912dacac Add root makefile for lua53 2017-04-05 10:22:04 +02:00
Cararasu 2ef7baad50 Lua 5.3 Assembler/Disassembler, Analyzer and Binary Plugin
* Added Lua 5.3 Assembly and Disassembly
    * Implemented Lua 5.3 Binary Analyzer #3836
    * removed unnecesasry prints for lua implementation #3836

    * implemented caching for parsing the lua-file #3836 grouped global data together
    * added mnemonics to analyzer and fixed a wrong instructionname
    * replaced llx and llu with PFMT64x
    * removed trailing whitespaces from lua 5.3 assembler and binary analyzer
    * made all functions in lua53 plugins that are possible static
2017-04-05 10:15:55 +02:00
alvarofe a5eaf60a35 Update debug_unicorn.c with changes in upstream 2017-04-02 12:58:58 +02:00
Rakholiya Jenish c61d4e5e28 r2pm to use local r2-extras cloned repo instead of master in travis (#103) 2017-03-27 13:28:19 +02:00
l0stb1t 62e4780a2b Fix PYC support
* fix some copy-paste errors
* add interned type support
* add a disassemble plugin
2017-03-27 13:21:24 +02:00
pancake cd3d82dedd Add md380 io and bin plugins 2017-03-27 13:20:17 +02:00
l0stb1t 40235e278d Adding more pyc objects (#107)
* fix pyc support

* adding more pyc objects. This code is not 100% corret yet

* fix some copy-paste errors

* add interned type support

* add interned type support

* add a disassemble plugin
2017-03-27 10:25:21 +02:00
pancake 1233f1bd8c Add r2kaitai 2017-03-25 01:47:36 +01:00
Rakholiya Jenish 4c028c7225 rename r_str_concat to r_str_append (#108) 2017-03-20 19:44:40 +01:00
Alex Kornitzer b6cb372635 Support for changes in the core (r2 1.3.0) (#105) 2017-03-18 12:49:49 +01:00
pancake 93c4558909 Release 1.3.0 2017-03-13 04:04:56 +01:00
Maijin 30f1d743df Re-add Python bindings in travis 2017-02-24 11:14:12 +01:00
Maijin 792ce9f864 Re-add Python bindings in travis 2017-02-23 21:16:56 +01:00
Maijin d1ef68df83 Update .travis.yml 2017-02-23 19:56:11 +01:00
pancake e078e85e35 Add sample kext for XNU (macOS) 2017-02-23 12:38:52 +01:00
Rakholiya Jenish efae36d2b4 add iddt command, fix makefile and proper integration with travis (#102)
* fix linking options in makefile
* fix printing member of data type pointed by pointers
* fix makefile
* fix infinite loop in idddl command for pointer to structs
* update TODO
* update readme
* refactor r_cmd_dwarf_call for easier extension with new commands and make it easier to understand
* fix travis to use regressions tests
* add iddt
2017-02-16 09:00:59 +01:00
Rakholiya Jenish 7976e4f1e4 fix makefile for use with r2pm (#101)
* fix makefile for use with r2pm

* add dwarf-parser to travis
2017-02-10 02:07:23 +01:00
Maijin 98f896184b Remove r2snow from travis temporarly [skip-ci] 2017-02-08 11:53:59 +01:00
Rakholiya Jenish 88f343a55e add iddlf, iddlg and iddd (#100)
- add idddl
- add iddlf and iddlg commands to load function and global symbols respectively
- add size to flags
- update Readme
- add C-declaration output
2017-02-08 06:29:11 +01:00
pancake 65d54dffa9 Use the official git repo for Yara 2017-02-07 02:31:56 +01:00
pancake 2c06304977 Fix install-yara for osx 2017-02-07 02:16:28 +01:00
pancake 4e22cf3bb7 Fix install/uninstall for tms320c64x 2017-02-04 02:14:10 +01:00
pancake 65eaee16c2 Initial implementation of the tms320-c64x based on capstone 2017-02-04 02:10:58 +01:00
Maijin df153040a4 Add travis badge 2017-02-01 22:59:42 +01:00
Rakholiya Jenish 2e1e660478 Follow pointer and add support for idd* subcommands (#99) 2017-02-01 22:57:48 +01:00
pancake 4a3c06342d Release 1.2.0 2017-01-30 10:33:10 +01:00
NighterMan 9e97f9e719 Sync r2k/linux to latest version from leberus/r2k
* Fix several build issues
* Add support to disable x86 WP on writes
* Workaround for HARDENED_USERCOPY on newer kernels
* Fix: return ENOSYS if feature is not implemented
* Add: print warning after loading the module
* Fix: create device with 0600 perms
2017-01-29 18:11:31 +01:00
Maijin 4a59f18192 Fix r2snow? 2017-01-29 16:05:35 +01:00
Maijin ed26cfb958 NodeJS 7 2017-01-29 15:56:03 +01:00
Rakholiya Jenish f318e46d68 Print specific members from structure using abc.def format and get address for writing specific field in struct (#98) 2017-01-29 15:01:59 +01:00
pancake 3f48304b25 Delete some .d files 2017-01-25 15:33:43 +01:00
pancake 1687a03f3e Fix the Yara plugin 2017-01-25 15:32:46 +01:00
Alex Kornitzer 843ff3a467 Applied fixes due to changes in the core (#97)
The MDMP plugin will no longer segfault in the latest git build of r2.
Support for the haddr changes in the core have been added.
2017-01-23 15:47:39 +01:00
pancake fdcab991f4 Fix null deref crash in unicorn plugin 2017-01-22 01:04:08 +01:00
pancake 70900ebf66 Add unicorn/'s make clean 2017-01-22 00:38:11 +01:00
Rakholiya Jenish 06f08a5c0c Add readme (#96) 2017-01-19 18:16:52 +01:00
Rakholiya Jenish aaf3bcc405 deallocate dwarf types and json format output (#95) 2017-01-19 11:10:59 +01:00
Maijin 1f01bd2f43 Add tests to olly travis 2017-01-17 16:12:01 +01:00
Sven Steinbauer 92ebbf827d Add x86_olly to extras (#94) 2017-01-17 15:30:32 +01:00
Maijin b36da8ef58 Add r2frida 2017-01-16 22:21:38 +01:00
Rakholiya Jenish c480849434 Dwarf reloaded (#91)
* initial rewrite for dwarf

* re-write of dwarf integration

* print array properly

* proper integration with r2

fix makefile
2017-01-10 15:42:41 +01:00
pancake 9aae368533 Add cmake3 debian package for Travis 2017-01-10 15:31:51 +01:00
pancake b38ad089ce Aim to fix the r2snow build by travis 2017-01-10 14:58:31 +01:00
nevun 6eb8aa9894 In case the file path has spaces in it we need to quote $TARGET. (#92) 2017-01-10 11:00:58 +01:00
fabianfreyer a3c3c8155a Use snowman fork fabianfreyer/snowman for now (#90)
Fixes a regression caused by merging #87 before
https://github.com/yegord/snowman/pull/104

Once that is merged, this commit should be reverted.
2017-01-04 13:12:43 +01:00
fabianfreyer cd5be298a7 Clean up r2snow (#87)
This depends on https://github.com/yegord/snowman/pull/104
2017-01-04 10:28:10 +01:00
fabianfreyer 905f7a76c7 Fix Travis checks: r2snow dependencies (#89) 2017-01-04 10:27:59 +01:00
fabianfreyer 3cc1da0c8a r2snow.pl: Fix reading source file into scalar (#88)
The rf function reads a file into an array context; however it is
assigned to the scalar $source below. On some (all?) versions of perl,
this scalar is then assigned the line count of the source file. Joining
the array solves this problem.
2017-01-04 10:27:51 +01:00
pancake e81b864761 Use Optional function pointers and comment dead code 2017-01-03 11:48:14 +01:00
pancake 96eb7c0441 Use repr(C) in rust-asm6502 2017-01-03 11:39:39 +01:00
pancake 3d59572c78 First asm plugin written in Rust 2017-01-03 00:08:49 +01:00
pancake 99609c0478 Add rf/wf subroutines to avoid the use of File::Slurp 2017-01-02 20:43:21 +01:00
ditch 306c67414b Make r2snow always exit with 0 (#86)
Sometimes r2snow returns proper r2 commands but still exits with non-0 return value causing r_sys_cmd_str_full: failed command 'r2snow'.
This dirty hack supresses this.
2016-12-29 22:51:33 +01:00
makigumo eb876d6959 fix obsolete yara2/3 reference in Makefile.acr (#85) 2016-12-28 20:59:04 +01:00
pancake aff68afab3 Fix r2snow offbyone 2016-12-22 18:17:06 +01:00
Maijin a879a111a1 Adding r2snow in travis 2016-12-22 17:52:42 +01:00
pancake 7a664146c7 oops for r2snow 2016-12-22 17:29:31 +01:00
pancake b451a12e82 Add .txt in the simplified source 2016-12-22 17:25:53 +01:00
pancake 840f0dbe0c Find .bin and .pl in PATH 2016-12-22 17:22:43 +01:00
pancake 7d66697375 install != all 2016-12-22 16:59:06 +01:00
pancake 49e0a2d86b Add install/uninstall targets for r2snow 2016-12-22 16:40:23 +01:00
pancake af4fe2f44e Initial import of the ugliest integration for snowman into r2 2016-12-22 13:11:07 +01:00
NighterMan d917e56e8d Fix keystone compilation error due to bad linker args 2016-12-22 11:03:55 +01:00
pancake ba9aa02d4c uhm workaround to avoid a blessr2 crash 2016-12-21 11:48:38 +01:00
pancake 9c91b621fa Update blessr2 for the latest r2pipe.js 2016-12-21 11:41:31 +01:00
pancake 477f65b628 Release 1.1.0 2016-12-20 02:58:13 +01:00
pancake cae1941b52 Add r2k/linux from leberus/r2k 2016-12-19 22:41:28 +01:00
Maijin 0ffc1ebb32 Rename plugin in travis too cc @radare 2016-11-24 13:30:17 +01:00
pancake 02798ec5c0 More build fixes for the m68k renaming 2016-11-23 15:57:04 +01:00
pancake 3de7fb8670 More build fixes for the m68k renaming 2016-11-23 15:56:24 +01:00
pancake dde23abf62 Fix arch in x86.simple 2016-11-23 15:54:10 +01:00
pancake bc08d309ff anal.m68k.net renamed 2016-11-23 15:53:50 +01:00
pancake 0604e86106 Missing rename 2016-11-23 15:51:54 +01:00
pancake 0613a9e017 Remove useless .d files from mdmp 2016-11-23 15:49:03 +01:00
pancake 9d6144693f Rename the m68k thing 2016-11-23 15:48:04 +01:00
Alex Kornitzer 988f7a9517 Minor Makefile changes (#82)
* Renaming in Makefile.acr

The make command for building binary plugins used to be dlang which does
not make any sense, have renamed this to bin.

* Changed the mdmp.mk to prevent error

Copied the format in pyc.mk and this seems to build using the commands
in the r2pm script. So hopefully travis and r2pm will be happy now.
2016-11-17 15:31:17 +01:00
Marek Sebera 621311346a Enabled -fPIC on BCL compilation, fixes #83 (#84) 2016-11-17 10:53:01 +01:00
Alex Kornitzer a2bd9f9073 MDMP v1.1 - The pf edition (#81)
* Rework of the mdmp plugin

Major rework of the mdmp plugin, sections will load using their virtual
adressess and physical addresses will map to the correct locations in
the mdmp file if they exist (full dumps). The memory section is used to
store all memeory segments found within the mdmp file, again physical
addressess will point to the correct locations withing the file.

* Applied r2 code style guidelines

Applied the r2 code style guidelines to the code:
https://github.com/radare/radare2/blob/master/CONTRIBUTING.md

* More guideline conforming

A little more work on conforming to guidelines.

* Even more guideline conforming

Further minor changes to the coding style.

* Fixed tab spaces on bin_mdmp.c

How did I miss this file during the conversion!!!

* Fixed linking between v and paddr; added mem_info

Fixed the issue where vaddr would not link to the paddr contents. Added
initial memory info parsing support; this feature is currently disabled
as it breaks the vaddr paddr mapping.

* Added TODOs

Added TODOs to the parsing section to highlight which streams are in
need of further implementation.

* Bug fix in mdmp.c

Fixed a bug introduced with the srwx function.

* Added memory permissions to sections

I was being a bit of an idiot and have reenabled memory permissions as
this was not the cause of the vaddr/paddr issue.

* Entrypoint support

Entrypoint support for PE files has been added. Due to the fact that the
implementation is in extras the pe folder had to be cloned. This will be
removed when the plugin migrates into main.

* Fix for the entrypoint maths

Fixed an incorrect assumption about calculating entrypoints.

* Preliminary symbol support

Parses most cases of symbols, some cases are yet to be caught. Cleaning
is required before PR. Furthermore a bug fix within pe.c is required for
symbol parsing to complete successfully. Would not be surprised if there
are additional issues in pe.c!

* Initial import support

Will load imports into the import section, need to test against some
other files to double check paddr/vaddr.

* Added initial relocs support

This has added support for the relocs section. This will change due to
the leak I have introduced due to the cross dependency. As a result I
will probably now parse all modules once and store them in an RList.

* Architecture change

The first architecture change to deal with the fact that r2 uses two
binary plugins for pe files. This fixes some of my oversights and solves
a large number of issues I had reported previously.

* New architecture complete

The new more modular architecture is complete. I took some/a lot of
inspiration from nibble.

* Cleanup and some other minor changes

Including the above, had to disable the symbol function as sending bins
to pe.c is causing a seg fault.

* Fixed some memory issues

Fixed some issues with rlists assumptions. Made some quick hacky fixes
so that imports work again for now.

* Added linked library support

Will pull the linked libraries from the embedded binaries.

* Basic string support

Will now allow searching of sections for strings, i.e. enabled iz.

* String refinement

Increased the minstrlen otherwise we get string in text sections
everywhere. This could be greatly improved but identifying individual
sections!

* Re-enabled mdmp in the travis yml

Re-enabled mdmp in the travis yml and added the regression args.

* Minor cleaning

Applied the changes highlighted in the previous PR. Removed some
pointless if statements and fixed the header guard.

* Duplicate module support

MDMP will now filter duplicate bins found within the module list.

* Removed a testing comment

Removed a testing comment

* Parse pe_bin sections for correlated MDMP modules

Sections will now map the pe_bin sections to give us finer grain
control. We can now see the permissions within the pe_bin modules and
can mark only the correct sections for default string checking.

* Fixed r_list_join and added some comments

Finally fixed the join issue, will create a PR for this in the core
later on. Added some more useful and consistent comments.

* Name change to avoid clash

Only temp until a the function is moved.

* Initial parsing support

Added parsing support, need to add support for unions and add support
for other structures such as TEB and PEB.

* Fixes to pf

Oversights and errors have been fixed, still have an odd issue with
missing but not missing structs!

* Moved the temp functions

Moved the temp functions to the top of the file.

* Found the B format variable

So added that where required.

* Found the t format variable

So added that as well!

* Made il easier to read

Now uses the bins vaddr rather than an arbitrary number.
2016-11-16 15:29:53 +01:00
408 changed files with 125029 additions and 9738 deletions

No files matched your search

+65 -37
View File
@@ -1,90 +1,118 @@
dist:
- trusty
sudo:
- false
os:
- linux
compiler:
- clang
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++
- gcc-7
- llvm-dev
- libatomic-ops-dev
- mono-xbuild
- curl
- make
- tcc
- libboost-dev
- libqt4-dev
- cmake
- cmake-data
- ninja-build
- libboost-dev
- libqt4-dev
- exuberant-ctags
- libelf-dev
- libgmp-dev
- zlib1g-dev
- swig
env:
- TESTS="r2pm -i armthumb"
- TESTS="r2pm -i baleful"
# - TESTS="r2pm -i bcl" [BR] https://travis-ci.org/radare/radare2-extras/builds/157522362
# - TESTS="r2pm -i bcl" [BR] https://travis-ci.org/radareorg/radare2-extras/builds/157522362
- TESTS="r2pm -i blackfin"
- TESTS="r2pm -i blessr2"
# - TESTS="r2pm -i bpf" [BR] https://travis-ci.org/radare/radare2-extras/builds/157522362
# - TESTS="r2pm -i dlang" [BR] https://travis-ci.org/radare/radare2-extras/builds/157522362
# - TESTS="r2pm -i bpf" [BR] https://travis-ci.org/radareorg/radare2-extras/builds/157522362
# - TESTS="r2pm -i dlang" [BR] https://travis-ci.org/radareorg/radare2-extras/builds/157522362
- TESTS="r2pm -i dirtycow"
- TESTS="r2pm -i duktape"
- TESTS="r2pm -i lang-duktape"
- TESTS="git clone git://git.code.sf.net/p/libdwarf/code libdwarf-code && cd libdwarf-code && ./configure && make && cd .. && r2pm -i dwarf-parser && cd radare2-regressions && ./r2r dwarf && cd .. && r2pm -u libdwarf && rm -rf libdwarf-code" #need to remove libdwarf? or travis destroys the vm so no issue in that?
- TESTS="r2pm -i r2frida"
# - TESTS="r2pm -i io-ewf" # https://github.com/travis-ci/apt-package-whitelist/issues/3205
# - TESTS="r2pm -i keystone-lib && r2pm -i keystone && cd radare2-regressions && make keystone && cd .." [BR] https://travis-ci.org/radare/radare2-extras/builds/157522362
- TESTS="r2pm -i mdmp" && cd radare2-regressions && make extras.mdmp && cd .."
- TESTS="r2pm -i microblaze"
# - TESTS="r2pm -i keystone-lib && r2pm -i keystone && cd radare2-regressions && make keystone && cd .." [BR] https://travis-ci.org/radareorg/radare2-extras/builds/157522362
- TESTS="r2pm -i mc6809"
- TESTS="r2pm -i microblaze && cd radare2-regressions && make microblaze"
- TESTS="r2pm -i msil"
- TESTS="r2pm -i pcap"
- TESTS="r2pm -i ppcdisasm"
- TESTS="r2pm -i psosvm"
- TESTS="r2pm -i pyc"
# - TESTS="r2pm -i python" [BR] https://travis-ci.org/radare/radare2-extras/builds/157522362
# - TESTS="r2pm -i r2pipe-cs" [BR] https://travis-ci.org/radare/radare2-extras/builds/157522362
- TESTS="r2pm -i r2pipe-go"
# - TESTS="r2pm -i vala && r2pm -i valabind && r2pm -i r2api-python" [BR] https://travis-ci.org/radareorg/radare2-extras/builds/387043680
# - TESTS="r2pm -i r2pipe-cs" [BR] https://travis-ci.org/radareorg/radare2-extras/builds/157522362
# - TESTS="r2pm -i r2pipe-go" [BR] https://travis-ci.org/radareorg/radare2-extras/builds/387043680
- TESTS="r2pm -i r2pipe-js"
- TESTS="r2pm -i r2pipe-py"
- TESTS="r2pm -i r2pipe-rb"
# - TESTS="r2pm -i r2pipe-vala" https://travis-ci.org/radare/radare2-extras/builds/157522362
# - TESTS="r2pm -i r2pipe-vala" https://travis-ci.org/radareorg/radare2-extras/builds/157522362
- TESTS="r2pm -i radare2"
# - TESTS="r2pm -i r2snow" https://travis-ci.org/radareorg/radare2-extras/jobs/199500082
# - TESTS="r2pm -i radeco" [BR] https://travis-ci.org/radare/radare2-extras/builds/157522362
- TESTS="r2pm -i retdec"
- TESTS="r2pm -i swf && cd radare2-regressions && make swf && cd .."
- TESTS="r2pm -i m68k && cd radare2-regressions && make m68k-extras && cd .."
# - TESTS="r2pm -i m68k-net && cd radare2-regressions && make m68k-extras && cd .." [BR] https://travis-ci.org/radare/radare2-extras/builds/387043680
# - TESTS="r2pm -i swig" Sorry. This package cannot be installed in your home.
- TESTS="r2pm -i syms2elf"
# - TESTS="r2pm -i tcc" [BR] https://travis-ci.org/radare/radare2-extras/builds/157522362
- TESTS="r2pm -i unicorn-lib && r2pm -i unicorn"
# - TESTS="r2pm -i vala" Sorry. This package cannot be installed at home.
# - TESTS="r2pm -i valabind" Sorry. This package cannot be installed at home
- TESTS="r2pm -i vapi"
- TESTS="r2pm -i unicorn-lib && r2pm -i unicorn" # need to do this properly
- TESTS="r2pm -i vala"
# - TESTS="r2pm -i valabind" [BR] https://travis-ci.org/radare/radare2-extras/builds/387043680
# - TESTS="r2pm -i vapi" [BR] https://travis-ci.org/radare/radare2-extras/builds/387043680
- TESTS="r2pm -i vc4"
- TESTS="r2pm -i winapi"
- TESTS="r2pm -i www-enyo"
# - TESTS="r2pm -i www-m" [BR] https://travis-ci.org/radare/radare2-extras/builds/157522362
- TESTS="r2pm -i www-p"
- TESTS="r2pm -i www-t"
- TESTS="r2pm -i x86udis"
- TESTS="r2pm -i x86bea"
- TESTS="r2pm -i x86tab"
- TESTS="r2pm -i x86olly && cd radare2-regressions && make olly-extras && cd .."
- TESTS="r2pm -i z80-nc"
- TESTS="r2pm -i yara-lib && r2pm -i yara"
sudo:
- false
- TESTS="r2pm -i yara && r2pm -i yara-r2"
- TESTS="r2pm -i x86zyan"
language:
- c
- rust
rust:
- stable
cache:
- ccache
- apt
before_script:
- git clone https://github.com/radare/radare2-regressions
- git clone https://github.com/radare/radare2 && cd radare2
- ./configure --prefix=`pwd`/install > /dev/null
- export WORKING_DIR=${TRAVIS_BUILD_DIR}/..
- cd ${WORKING_DIR}
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install 10
- git clone https://github.com/radareorg/radare2-regressions
- git clone https://github.com/radareorg/radare2 && cd radare2
- export CC=gcc-7
- ./configure --prefix=${WORKING_DIR}/install > /dev/null
- make -s -j2 > /dev/null
- make install > /dev/null
- export PATH=${TRAVIS_BUILD_DIR}/radare2/install/bin:${PATH}
- export LD_LIBRARY_PATH=${TRAVIS_BUILD_DIR}/radare2/install/lib:${LD_LIBRARY_PATH}
- export LIBR_INCLUDE=${TRAVIS_BUILD_DIR}/radare2/libr/include
- export LIBR_UTIL=${TRAVIS_BUILD_DIR}/radare2/libr/util
- export PKG_CONFIG_PATH=${TRAVIS_BUILD_DIR}/radare2/pkgcfg
- export GOPATH=${TRAVIS_BUILD_DIR}/radare2/
- curl -sSf https://static.rust-lang.org/rustup.sh | sh
- cd ..
- export PATH=${WORKING_DIR}/install/bin:${PATH}
- export LD_LIBRARY_PATH=${WORKING_DIR}/install/lib:${LD_LIBRARY_PATH}
- export LIBR_INCLUDE=${WORKING_DIR}/radare2/libr/include
- export LIBR_UTIL=${WORKING_DIR}/radare2/libr/util
- export PKG_CONFIG_PATH=${WORKING_DIR}/radare2/pkgcfg
- export GOPATH=${WORKING_DIR}/
- r2pm init
- export R2PM_GITDIR=${WORKING_DIR}
- cd radare2-extras
- ./configure --prefix=${WORKING_DIR}/install
- cd ..
script:
- ./configure --prefix=`pwd`/radare2/install
- r2pm init
- eval $TESTS
+21 -18
View File
@@ -1,14 +1,12 @@
VERSION=@VERSION@
HAVE_LIB_YARA=@HAVE_LIB_YARA@
PREFIX=@PREFIX@
include options.mk
DESTDIR?=
TAR=tar -cvf
CZ=xz -f
DIRS=
ifeq ($(HAVE_LIB_YARA),1)
DIRS+=yara/yara2
DIRS+=yara/yara3
DIRS+=yara/yara
DIRS+=libr/asm/p
DIRS+=libr/anal/p
endif
@@ -18,13 +16,16 @@ help:
@echo " all - build everything"
@echo " baleful - build baleful r2 plugin"
@echo " asm - build armthumb, ppc, psosvm, x86bea, m68k plugins"
@echo " io - build io plugins"
@echo " anal - build analysis plugins (RAnal)"
@echo " bin - build binary plugins (RBin)"
@echo " debug - build debugger plugins (RDebug)"
@echo " dlang - support DLang demangler (RBin)"
@echo " yara{2,3} - build yara2 or yara3 r2 plugin"
@echo " yara - build yara3 r2 plugin"
@echo " (target)-install - install given plugin"
@echo " (target)-clean - clean given plugin"
@echo " install-yara{2,3} - install Yara 2 or 3 from Git"
# @echo " install-yara{2,3} - install Yara 2 or 3 from Git"
baleful:
$(MAKE) -C baleful
@@ -32,33 +33,35 @@ debug unicorn:
$(MAKE) -C libr/debug/p
anal:
$(MAKE) -C libr/anal/p
anal-install:
$(MAKE) -C libr/anal/p install DESTDIR=$(DESTDIR)
asm:
$(MAKE) -C libr/asm/p
asm-install:
$(MAKE) -C libr/asm/p install DESTDIR=$(DESTDIR)
asm-clean:
$(MAKE) -C libr/asm/p clean
dlang:
bin:
$(MAKE) -C libr/bin/p
dlang-install:
bin-install:
$(MAKE) -C libr/bin/p install DESTDIR=$(DESTDIR)
yara2 yara3:
io:
$(MAKE) -C libr/io/p
io-install:
$(MAKE) -C libr/io/p install DESTDIR=$(DESTDIR)
yara:
cd yara/$@ ; ./configure --prefix=$(PREFIX)
$(MAKE) -C yara/$@
yara2-clean:
$(MAKE) -C yara/yara2 clean
yara3-clean:
$(MAKE) -C yara/yara3 clean
yara-clean:
$(MAKE) -C yara/yara clean
baleful-install:
$(MAKE) -C baleful install DESTDIR=$(DESTDIR)
debug-install unicorn-install:
$(MAKE) -C libr/debug/p install DESTDIR=$(DESTDIR)
debug-uninstall unicorn-uninstall:
$(MAKE) -C libr/debug/p uninstall DESTDIR=$(DESTDIR)
yara2-install:
$(MAKE) -C yara/yara2 install DESTDIR=$(DESTDIR)
yara3-install:
$(MAKE) -C yara/yara3 install DESTDIR=$(DESTDIR)
$(MAKE) -C yara/yara install DESTDIR=$(DESTDIR)
all:
for a in $(DIRS) ; do \
+4 -85
View File
@@ -1,4 +1,4 @@
radare2-extras
radare2-extras [![Build Status](https://travis-ci.org/radareorg/radare2-extras.svg?branch=master)](https://travis-ci.org/radareorg/radare2-extras)
==============
This repository contains extra plugins for radare2.
@@ -29,89 +29,8 @@ keep it usable for 99% of users.
Building
========
To build radare2-extras, just follow the common gnu-configure steps:
./configure --prefix=/usr
make baleful
make baleful-install
The recommended way to build and install those plugins for users
is to use r2pm. See the radare2-pm repository for details:
To install yara3 and the r2 plugin:
./configure --prefix=/usr
make install-yara3
make yara3
make yara3-install
Note the `symstall` instead of `install` will symlink the plugins
instead of copying them. This way you can just avoid installing
every time you build. This installation method is prefered for
developers.
Each module may have it's own configure script, this way
packagers can create plugin-specific packages like this:
radare2-extras-yara -> yara plugin
Directories
===========
* yara/yara2 yara/yara3
yara2/3 command. Depends on libyara
* libr/asm/p
Contains assembler/disassembler plugins:
* m68k
* armthumb
* psosvm
* ppc
* libr/bin/p
Bin-related plugins:
* dlang demangler
* libr/anal/p
Contains code analysis plugins
* libr/vm
Contains the initial implementation of ESIL. It is kept
for historical reasons, but will be removed soon or late.
* libr/cmd
very work-in-progress core cmd plugins
for historical reasons, but will be removed soon or late.
RFC
===
In addition we should add sys/*.sh files to fetch and build the
plugins and dependencies if needed (yara.sh) to allow git users
to get the proper version installed without depending on the
pkgsystem.
We could still provide one-liners to help them. We should keep
different versioning numbers for each plugin..
radare2-extras-yara3-0.9.9-0.1
[pkgname] [modname] [r2version] [modversion]
* Do we need a radare2-extra-regressions then?
I would just add the tests inside the radare2-extras/libr/core/p/yara/t/
for example.. and just make those tests run from inside that
repo, no need to add more repos because those plugins would be
pretty contained.
* What about checking all the tests right away?
Also maybe the plugins depend on some r2 behavior, that has
been broken, and we need to test for that jenkins should run
those tests don't know much about jenkins, so i won't say much.
just hoping it covers all our bases.
https://github.com/radareorg/radare2-pm
+29 -3
View File
@@ -543,6 +543,32 @@ static int esil_baleful_intr (RAnalEsil *esil, int intr) {
return true;
}
static bool esil_bale_interrupt_wrapper_cb (RAnalEsil *esil, ut32 interrupt, void *user) { //user is always NULL, bc we has no init and fini
return !!esil_baleful_intr(esil, interrupt);
}
RAnalEsilInterruptHandler bale_intr_handler00 = {
.num = 0x00, //interrupt number
.cb = esil_bale_interrupt_wrapper_cb, //the actual handler
};
RAnalEsilInterruptHandler bale_intr_handler04 = {
.num = 0x04, //interrupt number
.cb = esil_bale_interrupt_wrapper_cb, //the actual handler
};
RAnalEsilInterruptHandler bale_intr_handler11 = {
.num = 0x11, //interrupt number
.cb = esil_bale_interrupt_wrapper_cb, //the actual handler
};
RAnalEsilInterruptHandler *bale_intr_handlers[] = {
&bale_intr_handler00,
&bale_intr_handler04,
&bale_intr_handler11,
NULL,
};
static int set_reg_profile(RAnal *anal) {
const char *p = \
"=PC pc\n"
@@ -598,8 +624,10 @@ static int set_reg_profile(RAnal *anal) {
return r_reg_set_profile_string (anal->reg, p);
}
static int esil_baleful_init (RAnalEsil *esil) {
if (!esil)
if (!esil) {
return false;
}
return r_anal_esil_load_interrupts (esil, bale_intr_handlers, 0);
/*
internalMemory=malloc(4096);
if (!internalMemory) {
@@ -610,7 +638,6 @@ static int esil_baleful_init (RAnalEsil *esil) {
*((ut32 *)internalMemory)=0xdeadbeef;
eprintf("leido :%08x\n",*((ut32 *)internalMemory));
*/
return true;
}
static int esil_baleful_fini (RAnalEsil *esil) {
@@ -628,7 +655,6 @@ static RAnalPlugin r_anal_plugin_baleful = {
.bits = 32,
.esil_init = esil_baleful_init,
.esil_fini = esil_baleful_fini,
.esil_intr = esil_baleful_intr,
.esil = true,
.op = &baleful_op,
.set_reg_profile = set_reg_profile,
+36 -35
View File
@@ -211,124 +211,125 @@ static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
const ut8 *r1;
const ut32 *imm;
const ut32 *imm1;
char outbuf[32] = {0};
switch (*buf) {
case 2://8 8 11 5
op->size = asm_baleful_getregs(buf,op->buf_asm,"+",0);
op->size = asm_baleful_getregs(buf,outbuf,"+",0);
break;
case 3://8 8 11 5
op->size = asm_baleful_getregs(buf,op->buf_asm,"-",0);
op->size = asm_baleful_getregs(buf,outbuf,"-",0);
break;
case 4://8 8 11 5
op->size = asm_baleful_getregs(buf,op->buf_asm,"*",0);
op->size = asm_baleful_getregs(buf,outbuf,"*",0);
break;
case 6://8 8 11 5
op->size = asm_baleful_getregs(buf,op->buf_asm,"^",0);
op->size = asm_baleful_getregs(buf,outbuf,"^",0);
break;
case 9://8 8 11 5
op->size = asm_baleful_getregs(buf,op->buf_asm,"&",0);
op->size = asm_baleful_getregs(buf,outbuf,"&",0);
break;
case 10://8 8 11 5
op->size = asm_baleful_getregs(buf,op->buf_asm,"|",0);
op->size = asm_baleful_getregs(buf,outbuf,"|",0);
break;
case 12://8 8 11 5
op->size = asm_baleful_getregs(buf,op->buf_asm,"<<",0);
op->size = asm_baleful_getregs(buf,outbuf,"<<",0);
break;
case 13://8 8 11 5
op->size = asm_baleful_getregs(buf,op->buf_asm,">>",0);
op->size = asm_baleful_getregs(buf,outbuf,">>",0);
break;
case 5: // //9 9 12 6
op->size = asm_baleful_getregs(buf,op->buf_asm,"/",1);
op->size = asm_baleful_getregs(buf,outbuf,"/",1);
break;
case 22: // 7 7 10 4
op->size = asm_baleful_getregs(buf,op->buf_asm,"and",2);
op->size = asm_baleful_getregs(buf,outbuf,"and",2);
break;
case 23: // 7 7 10 4
op->size = asm_baleful_getregs(buf,op->buf_asm,"cmp",2);
op->size = asm_baleful_getregs(buf,outbuf,"cmp",2);
break;
case 24: //7 4
op->size = asm_baleful_getregs(buf,op->buf_asm,"mov",3);
op->size = asm_baleful_getregs(buf,outbuf,"mov",3);
break;
case 30: // 6 3
op->size = asm_baleful_getregs(buf,op->buf_asm,"push",4);
op->size = asm_baleful_getregs(buf,outbuf,"push",4);
break;
case 15: //5
op->size = asm_baleful_getregs(buf,op->buf_asm,"call",5);
op->size = asm_baleful_getregs(buf,outbuf,"call",5);
break;
case 14: //5
op->size = asm_baleful_getregs(buf,op->buf_asm,"jmp",5);
op->size = asm_baleful_getregs(buf,outbuf,"jmp",5);
break;
case 16: //5
op->size = asm_baleful_getregs(buf,op->buf_asm,"jz",5);
op->size = asm_baleful_getregs(buf,outbuf,"jz",5);
break;
case 17: //5
op->size = asm_baleful_getregs(buf,op->buf_asm,"js",5);
op->size = asm_baleful_getregs(buf,outbuf,"js",5);
break;
case 18: //5
op->size = asm_baleful_getregs(buf,op->buf_asm,"jbe",5);
op->size = asm_baleful_getregs(buf,outbuf,"jbe",5);
break;
case 19: //5
op->size = asm_baleful_getregs(buf,op->buf_asm,"jg",5);
op->size = asm_baleful_getregs(buf,outbuf,"jg",5);
break;
case 20: //5
op->size = asm_baleful_getregs(buf,op->buf_asm,"jns",5);
op->size = asm_baleful_getregs(buf,outbuf,"jns",5);
break;
case 21: //5
op->size = asm_baleful_getregs(buf,op->buf_asm,"jnz",5);
op->size = asm_baleful_getregs(buf,outbuf,"jnz",5);
break;
case 27: //3
op->size = 3;
r = buf + 1;
r1 = buf + 2;
snprintf (op->buf_asm, R_ASM_BUFSIZE, "mov r_%02x,[r_%02x]",*r,*r1);
snprintf (outbuf, sizeof (outbuf), "mov r_%02x,[r_%02x]",*r,*r1);
break;
case 28: //3
r = buf + 1;
r1 = buf + 2;
op->size = 3;
snprintf (op->buf_asm, R_ASM_BUFSIZE, "mov [r_%02x],r_%02x",*r,*r1);
snprintf (outbuf, sizeof (outbuf), "mov [r_%02x],r_%02x",*r,*r1);
break;
case 11: //3
op->size = 3;
snprintf (op->buf_asm, R_ASM_BUFSIZE, "regX= regY==0");
snprintf (outbuf, sizeof (outbuf), "regX= regY==0");
break;
case 7: //3
op->size = 3;
snprintf (op->buf_asm, R_ASM_BUFSIZE, "regX= NEG regY");
snprintf (outbuf, sizeof (outbuf), "regX= NEG regY");
break;
case 8: //3
op->size = 3;
snprintf (op->buf_asm, R_ASM_BUFSIZE, "regX= NOT regY");
snprintf (outbuf, sizeof (outbuf), "regX= NOT regY");
break;
case 25: //2
op->size = asm_baleful_getregs(buf,op->buf_asm,"++",6);
op->size = asm_baleful_getregs(buf,outbuf,"++",6);
break;
case 26: //2
op->size = asm_baleful_getregs(buf,op->buf_asm,"--",6);
op->size = asm_baleful_getregs(buf,outbuf,"--",6);
break;
case 31: //2
op->size = asm_baleful_getregs(buf,op->buf_asm,"pop",6);
op->size = asm_baleful_getregs(buf,outbuf,"pop",6);
break;
case 32: // 2
op->size = asm_baleful_getregs(buf,op->buf_asm,"apicall",7);
op->size = asm_baleful_getregs(buf,outbuf,"apicall",7);
break;
case 1:
op->size = 1;
strcpy (op->buf_asm, "ret");
strcpy (outbuf, "ret");
break;
case 0:
op->size = 1;
strcpy (op->buf_asm, "nop");
strcpy (outbuf, "nop");
break;
case 29:
op->size = 1;
strcpy (op->buf_asm, "end virtual");
strcpy (outbuf, "end virtual");
break;
default:
op->size = 1;
strcpy (op->buf_asm, "nop");
strcpy (outbuf, "nop");
break;
}
r_strbuf_set (&op->buf_asm, outbuf);
return op->size;
}
+1 -1
View File
@@ -1,7 +1,7 @@
include ../options.mk
CFLAGS+=$(shell pkg-config --cflags r_util)
CC_LIB=$(CC) -shared $(CFLAGS) $(LDFLAGS)
CC_LIB=$(CC) -shared $(CFLAGS) $(LDFLAGS) -fPIC
CC_ASM=$(CC_LIB) $(shell pkg-config --libs r_asm)
CC_ANA=$(CC_LIB) $(shell pkg-config --libs r_anal)
CC_BIN=$(CC_LIB) $(shell pkg-config --libs r_bin)
+2 -2
View File
@@ -22,8 +22,8 @@ static int mycall(void *user, const char *input) {
int i, j;
const int seqsz = 100;
int data[seqsz];
RCore *core = (RCore *) user;
if (!strncmp (input, "pbc", 3)) {
RCore *core = (RCore *) user;
if (!strncmp (input, "pbc", 3)) {
char lala = input[3];
int newsize, bsize;
int in_color = r_config_get_i (core->config, "scr.color");
+26 -21
View File
@@ -193,7 +193,9 @@ function newBox(name, obj) {
obj.selectedBg = '#000070';
res = blessed.list(obj);
res.setContent = function(x) {
res.setItems(x.split('\n'));
if (typeof x === 'string') {
res.setItems(x.split('\n'));
}
}
}
res.cmd = name;
@@ -230,7 +232,7 @@ function walkInto(r2, foo) {
box.setText('Loading...\n');
screen.render();
[bgbox, box, xbox, gbox].forEach((b) => {
r2.cmd(b.cmd, (txt) => {
r2.cmd(b.cmd, (err, txt) => {
b.setContent(txt);
screen.render();
});
@@ -359,7 +361,7 @@ function refreshBox(r2, box) {
if (!box || !box.cmd) {
return;
}
r2.cmd(box.cmd, (txt) => {
r2.cmd(box.cmd, (err, txt) => {
box.setContent(txt);
screen.render();
});
@@ -528,7 +530,7 @@ function activateLine(r2, box) {
const at = parseInt(line.substring(addr), 16);
const isCode = true; //item.cmd && item.cmd.indexOf && item.cmd.indexOf('pd') != -1;
if (isCode) {
r2.cmd('e scr.color=0;ao@' + at + ';e scr.color=1', (txt) => {
r2.cmd('e scr.color=0;ao@' + at + ';e scr.color=1', (err, txt) => {
let obj = {}
txt.split('\n').forEach((x) => {
const ab = x.split(': ');
@@ -550,13 +552,13 @@ function activateLine(r2, box) {
}
function stepInto(r2, box) {
r2.cmd(config.debug ? 'ds;dr*' : 'aes;.aer*', (cmds) => {
r2.cmd(config.debug ? 'ds;dr*' : 'aes;.aer*', (err, cmds) => {
r2.cmd(cmds.split('\n').join(';'));
if (!box) box = bgbox;
r2.cmd(box.cmd, (txt) => {
r2.cmd(box.cmd, (err, txt) => {
box.setContent(txt);
screen.render();
r2.cmd(bgbox.cmd, (txt) => {
r2.cmd(bgbox.cmd, (err, txt) => {
bgbox.setContent(txt);
screen.render();
refreshAllBoxes(r2);
@@ -602,7 +604,7 @@ function gotoOffset(r2, val, box, nostack) {
if (offsetStack) {
offsetStack.push(val);
}
r2.cmd('s ' + val + ';' + box.cmd, (txt) => {
r2.cmd('s ' + val + ';' + box.cmd, (err, txt) => {
box.setContent(txt);
box.setScroll(0);
box.selected = 0;
@@ -666,10 +668,10 @@ function handleKeys(r2) {
uiQuestion('String', 'String to search', (val) => {
let box = uiNewFrame(r2, val);
box.setContent('Loading...');
r2.cmd('/ ' + val, (txt) => {
r2.cmd('/ ' + val, (err, txt) => {
box.setContent(txt);
screen.render();
r2.cmd('fs searches;f', (txt) => {
r2.cmd('fs searches;f', (err, txt) => {
box.setContent('Search for: "' + val + '":\n\n' + txt);
screen.render();
});
@@ -690,7 +692,7 @@ function handleKeys(r2) {
['S-a', () => {
r2.cmd('af', () => {
let box = screen.focused;
r2.cmd(box.cmd, (txt) => {
r2.cmd(box.cmd, (err, txt) => {
box.setContent(txt);
screen.render();
});
@@ -698,7 +700,7 @@ function handleKeys(r2) {
}],
[':', () => {
uiQuestion('Input', 'Command to run', (val) => {
r2.cmd(bgbox.cmd = val, (txt) => {
r2.cmd(bgbox.cmd = val, (err, txt) => {
bgbox.setContent(txt);
screen.render();
});
@@ -706,11 +708,11 @@ function handleKeys(r2) {
}],
['!', () => {
uiQuestion('Input', 'Command to run', (val) => {
r2.cmd(val, (txt) => {
r2.cmd(val, (err, txt) => {
uiNewFrame(r2, val);
const box = screen.focused;
if (box) {
r2.cmd(box.cmd, (x) => {
r2.cmd(box.cmd, (err, x) => {
box.setContent(x);
});
}
@@ -756,7 +758,7 @@ function handleKeys(r2) {
screen.render();
} else {
uiQuestion('Eval Config', 'key=value', (val) => {
r2.cmd('e ' + val, (txt) => {
r2.cmd('e ' + val, (err, txt) => {
screen.render();
});
});
@@ -780,7 +782,7 @@ function handleKeys(r2) {
});
screen.append(box);
uiQuestion('Offset', 'Where to go?', (val) => {
r2.cmd('s ' + val + ';' + box.cmd, (txt) => {
r2.cmd('s ' + val + ';' + box.cmd, (err, txt) => {
box.setContent(txt);
screen.render();
});
@@ -1065,11 +1067,14 @@ function handleMouse(r2) {
});
}
function main(r2) {
config.theme && r2.cmd("ecr");
handleKeys(r2);
handleMouse(r2);
walkInto(r2, 'entry0');
function main(err, r2) {
if (err) {
throw err;
}
config.theme && r2.cmd("ecr");
handleKeys(r2);
handleMouse(r2);
walkInto(r2, 'entry0');
}
/* main */
+3 -3
View File
@@ -1,11 +1,11 @@
{
"name": "blessr2",
"version": "0.1.1",
"version": "0.2.0",
"description": "bless-based ui for radare2",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/radare/radare2-bindings.git"
"url": "https://github.com/radareorg/radare2-bindings.git"
},
"keywords": [
"radare",
@@ -24,7 +24,7 @@
},
"license": "LGPL-3.0",
"bugs": {
"url": "https://github.com/radare/radare2-extras/issues"
"url": "https://github.com/radareorg/radare2-extras/issues"
},
"homepage": "http://www.radare.org",
"devDependencies": {
+31
View File
@@ -0,0 +1,31 @@
R2_PLUGIN_PATH=$(shell r2 -hh|grep LIBR_PLUGINS|awk '{print $$2}')
R2_INCLUDE_PATH=$(shell r2 -hh|grep INCDIR|awk '{print $$2}')
R2_LIB_PATH=$(shell r2 -hh|grep LIBDIR|awk '{print $$2}')
CFLAGS=-g -fPIC
CFLAGS+=-I$(R2_INCLUDE_PATH)
SUDO=sudo
LDFLAGS=-shared -L$(R2_LIB_PATH) -lr_util -lr_parse -lr_syscall
EXT_SO=$(shell r2 -hh|grep LIBEXT|awk '{print $$2}')
CC_ASM=$(CC) $(CFLAGS) $(LDFLAGS) $(shell pkg-config --libs r_asm)
CC_ANA=$(CC) $(CFLAGS) $(LDFLAGS) $(shell pkg-config --libs r_anal)
CC_BIN=$(CC) $(CFLAGS) $(LDFLAGS) $(shell pkg-config --libs r_bin) -lr_magic
CC_COR=$(CC) $(CFLAGS) $(LDFLAGS) $(shell pkg-config --libs r_core)
all:
$(CC_ASM) -o asm_bpf.$(EXT_SO) asm_bpf.c
$(CC_ANA) -o anal_bpf.$(EXT_SO) anal_bpf.c
$(CC_BIN) -o bin_bpf.$(EXT_SO) bin_bpf.c
# $(CC_COR) -o bpf_core.$(EXT_SO) bpf_core.c
install: all
$(SUDO) cp -f *.$(EXT_SO) $(R2_PLUGIN_PATH)
uninstall:
for a in *.$(EXT_SO) ; do rm -f $(R2_PLUGIN_PATH)/$$a ; done
clean:
rm -f *.$(EXT_SO)
rm -rf *.$(EXT_SO).dSYM
+54
View File
@@ -0,0 +1,54 @@
#BPF architecture for radare2
This is meant to add support for Berkeley Packet Filter in radare2, with full [ESIL](https://radare.gitbooks.io/radare2book/content/esil.html) emulation. The main purpose is to ease the analysis of existing filters encountered in reverse engineering, but can also aid filter development through ESIL emulation.
## Components
It is composed by three plugins:
* **asm_bpf** is the disassembler, i'm planning to add also assembler functionality, but for now it's only disassembler - it is mostly ripped from bpf_dbg.c in the Linux kernel
* **anal_bpf** this is the major contribution of this package, i.e. the analysis plugin which translates everything to ESIL and permits to emulate it completely
* **bin_bpf** is a placeholder, not sure if it's useful at all since there isn't a specific file format - i'm using it just to remember that data is represented big endian by enforcing this information
## Installing using r2pm
This plugin is available in latest r2pm, therefore can be installed simply by:
```
r2pm -i bpf
```
## Building manually
In unix system (tested on mac, but should work in Linux or *BSD out of the box) it should be as easy as doing:
```bash
make install
```
There are two known warnings:
* be sure to have the latest [radare2 from git](https://github.com/radareorg/radare2)
* on mac systems radare2 should be installed with sys/install.sh (and not sys/user.sh) because the Makefile relies on a properly working `pkg-config`
## Example
The provided [bpf.bin](bpf.bin) is ripped from the [berkeley crackme](http://crackmes.de/users/kwisatz_haderach/berkeley/), here is an example session:
[![asciicast](https://asciinema.org/a/1q8oq25bjpp00aut5v5sd4sez.png)](https://asciinema.org/a/1q8oq25bjpp00aut5v5sd4sez)
Moreover, i wrote an [r2pipe script](https://github.com/mrmacete/r2scripts/tree/master/bpf-test/bpftest.py) able to read a pcap file, iterate packets, and test them against the filter by using ESIL emulation.
Here is a not-so-clear live action trying to explain the steps of the above python script:
[![asciicast](https://asciinema.org/a/e22kxl5wncmcnqfvseq0k6dxj.png)](https://asciinema.org/a/e22kxl5wncmcnqfvseq0k6dxj)
## Testing
There's a [python script](https://github.com/mrmacete/r2scripts/tree/master/bpf-test/testtool.py) which parses the Linux kernel's BPF test suite and runs it on radare2's emulated BPF using r2pipe. Until now, all the test which doesn't involve kernel emulation are passing (for the CLASSIC bpf test category only).
If you have collections of test cases you can disclose they're welcome, please open an issue or just PR a test script.
## License
Since most of asm_bpf.c is ripped from Linux kernel, it's licensed on GPLv2.
+538
View File
@@ -0,0 +1,538 @@
/*
*
* Copyright 2015 - mrmacete <[email protected]>
* Licensed under the GNU General Public License, version 2.0 (GPLv2)
*/
#include <string.h>
#include <r_types.h>
#include <r_lib.h>
#include <r_asm.h>
#include <r_anal.h>
#include "bpf.h"
#define EMIT_CJMP(op, addr, f)\
(op)->type = R_ANAL_OP_TYPE_CJMP;\
(op)->jump = (addr) + 8 + (st8) (f)->jt * 8;\
(op)->fail = (addr) + 8 + (st8) (f)->jf * 8;
#define EMIT_LOAD(op, addr, size)\
(op)->type = R_ANAL_OP_TYPE_LOAD;\
(op)->ptr = (addr);\
(op)->ptrsize = (size);
#define NEW_SRC_DST(op)\
(op)->src[0] = r_anal_value_new ();\
(op)->dst = r_anal_value_new ();
#define SET_REG_SRC_DST(op, _src, _dst)\
NEW_SRC_DST ((op));\
(op)->src[0]->reg = r_reg_get (anal->reg, (_src), R_REG_TYPE_GPR);\
(op)->dst->reg = r_reg_get (anal->reg, (_dst), R_REG_TYPE_GPR);
#define SET_REG_DST_IMM(op, _dst, _imm)\
NEW_SRC_DST ((op));\
(op)->dst->reg = r_reg_get (anal->reg, (_dst), R_REG_TYPE_GPR);\
(op)->src[0]->imm = (_imm);
#define SET_A_SRC(op)\
(op)->src[0] = r_anal_value_new ();\
(op)->src[0]->reg = r_reg_get (anal->reg, "A", R_REG_TYPE_GPR);
#define SET_A_DST(op)\
(op)->dst = r_anal_value_new ();\
(op)->dst->reg = r_reg_get (anal->reg, "A", R_REG_TYPE_GPR);
#define INSIDE_M(k) ((k) >= 0 && (k) <= 16)
static bool bpf_int_exit(RAnalEsil *esil, ut32 interrupt, void *user);
RAnalEsilInterruptHandler ih = { 0, NULL, NULL, &bpf_int_exit, NULL };
static const char *M[] = {
"M[0]",
"M[1]",
"M[2]",
"M[3]",
"M[4]",
"M[5]",
"M[6]",
"M[7]",
"M[8]",
"M[9]",
"M[10]",
"M[11]",
"M[12]",
"M[13]",
"M[14]",
"M[15]"
};
static int bpf_anal(RAnal *anal, RAnalOp *op, ut64 addr,
const ut8 *data, int len) {
RBpfSockFilter *f = (RBpfSockFilter *)data;
memset (op, '\0', sizeof (RAnalOp));
op->jump = UT64_MAX;
op->fail = UT64_MAX;
op->ptr = op->val = UT64_MAX;
op->type = R_ANAL_OP_TYPE_UNK;
op->size = 8;
op->addr = addr;
r_strbuf_init (&op->esil);
switch (f->code) {
case BPF_RET | BPF_A:
op->type = R_ANAL_OP_TYPE_RET;
esilprintf (op, "A,R0,=,0,$");
break;
case BPF_RET | BPF_K:
case BPF_RET | BPF_X:
op->type = R_ANAL_OP_TYPE_RET;
if (BPF_SRC (f->code) == BPF_K) {
esilprintf (op, "%" PFMT64d ",R0,=,0,$", f->k);
} else if (BPF_SRC (f->code) == BPF_X) {
esilprintf (op, "X,R0,=,0,$");
}
break;
case BPF_MISC_TAX:
op->type = R_ANAL_OP_TYPE_MOV;
SET_REG_SRC_DST (op, "A", "X");
esilprintf (op, "A,X,=");
break;
case BPF_MISC_TXA:
op->type = R_ANAL_OP_TYPE_MOV;
SET_REG_SRC_DST (op, "X", "A");
esilprintf (op, "X,A,=");
break;
case BPF_ST:
if (INSIDE_M (f->k)) {
op->type = R_ANAL_OP_TYPE_MOV;
SET_REG_SRC_DST (op, "A", M[f->k]);
esilprintf (op, "A,M[%" PFMT64d "],=", f->k);
} else {
op->type = R_ANAL_OP_TYPE_ILL;
}
break;
case BPF_STX:
if (INSIDE_M (f->k)) {
op->type = R_ANAL_OP_TYPE_MOV;
SET_REG_SRC_DST (op, "X", M[f->k]);
esilprintf (op, "X,M[%" PFMT64d "],=", f->k);
} else {
op->type = R_ANAL_OP_TYPE_ILL;
}
break;
case BPF_LD_W | BPF_LEN:
op->type = R_ANAL_OP_TYPE_MOV;
SET_REG_SRC_DST (op, "len", "A");
esilprintf (op, "len,A,=", f->k);
break;
case BPF_LDX | BPF_LEN:
op->type = R_ANAL_OP_TYPE_MOV;
SET_REG_SRC_DST (op, "len", "X");
esilprintf (op, "len,X,=", f->k);
break;
case BPF_LD_W | BPF_ABS:
EMIT_LOAD (op, anal->gp + f->k, 4);
SET_A_DST (op);
esilprintf (op,
"len,%" PFMT64d ",>,?{,0,R0,=,0,$,BREAK,},%" PFMT64d ",[4],A,=",
f->k + 4, op->ptr);
break;
case BPF_LD_H | BPF_ABS:
EMIT_LOAD (op, anal->gp + f->k, 2);
SET_A_DST (op);
esilprintf (op,
"len,%" PFMT64d ",>,?{,0,R0,=,0,$,BREAK,},"
"%" PFMT64d ",[2],A,=",
f->k + 2, op->ptr);
break;
case BPF_LD_B | BPF_ABS:
EMIT_LOAD (op, anal->gp + f->k, 1);
SET_A_DST (op);
esilprintf (op,
"len,%" PFMT64d ",>,?{,0,R0,=,0,$,BREAK,},"
"%" PFMT64d ",[1],A,=",
f->k + 1, op->ptr);
break;
case BPF_LD_W | BPF_IND:
op->type = R_ANAL_OP_TYPE_LOAD;
op->ptrsize = 4;
SET_A_DST (op);
esilprintf (op,
"len,%" PFMT64d ",X,+,0xffffffff,&,>,?{,0,R0,=,0,$,BREAK,},"
"%" PFMT64d ",X,+,0xffffffff,&,[4],A,=",
(st32)f->k + 4, anal->gp + (st32)f->k);
break;
case BPF_LD_H | BPF_IND:
op->type = R_ANAL_OP_TYPE_LOAD;
op->ptrsize = 2;
SET_A_DST (op);
esilprintf (op,
"len,%" PFMT64d ",X,+,0xffffffff,&,>,?{,0,R0,=,0,$,BREAK,},"
"%" PFMT64d ",X,+,0xffffffff,&,[2],A,=",
(st32)f->k + 2, anal->gp + (st32)f->k);
break;
case BPF_LD_B | BPF_IND:
op->type = R_ANAL_OP_TYPE_LOAD;
op->ptrsize = 1;
SET_A_DST (op);
esilprintf (op,
"len,%" PFMT64d ",X,+,0xffffffff,&,>,?{,0,R0,=,0,$,BREAK,},"
"%" PFMT64d ",X,+,0xffffffff,&,[1],A,=",
(st32)f->k + 1, anal->gp + (st32)f->k);
break;
case BPF_LD | BPF_IMM:
op->type = R_ANAL_OP_TYPE_MOV;
op->val = f->k;
SET_REG_DST_IMM (op, "A", f->k);
esilprintf (op, "0x%08" PFMT64x ",A,=", f->k);
break;
case BPF_LDX | BPF_IMM:
op->type = R_ANAL_OP_TYPE_MOV;
op->val = f->k;
SET_REG_DST_IMM (op, "X", f->k);
esilprintf (op, "0x%08" PFMT64x ",X,=", f->k);
break;
case BPF_LDX_B | BPF_MSH:
op->type = R_ANAL_OP_TYPE_LOAD;
op->ptrsize = 1;
op->ptr = anal->gp + f->k;
SET_A_DST (op);
esilprintf (op, "%" PFMT64d ",[1],0xf,&,4,*,X,=", op->ptr);
break;
case BPF_LD | BPF_MEM:
op->type = R_ANAL_OP_TYPE_MOV;
if (INSIDE_M (f->k)) {
SET_REG_SRC_DST (op, M[f->k], "A");
esilprintf (op, "M[%" PFMT64d "],A,=", f->k);
} else {
op->type = R_ANAL_OP_TYPE_ILL;
}
break;
case BPF_LDX | BPF_MEM:
op->type = R_ANAL_OP_TYPE_MOV;
if (INSIDE_M (f->k)) {
SET_REG_SRC_DST (op, M[f->k], "X");
esilprintf (op, "M[%" PFMT64d "],X,=", f->k);
} else {
op->type = R_ANAL_OP_TYPE_ILL;
}
break;
case BPF_JMP_JA:
op->type = R_ANAL_OP_TYPE_JMP;
op->jump = addr + 8 + f->k * 8;
esilprintf (op, "%" PFMT64d ",pc,=", op->jump);
break;
case BPF_JMP_JGT | BPF_X:
case BPF_JMP_JGT | BPF_K:
EMIT_CJMP (op, addr, f);
op->cond = R_ANAL_COND_GT;
if (BPF_SRC (f->code) == BPF_K) {
op->val = f->k;
esilprintf (op,
"%" PFMT64d ",A,>,?{,%" PFMT64d ",pc,=,BREAK,},%" PFMT64d ",pc,=",
op->val, op->jump, op->fail);
} else if (BPF_SRC (f->code) == BPF_X) {
esilprintf (op,
"X,A,>,?{,%" PFMT64d ",pc,=,BREAK,},%" PFMT64d ",pc,=",
op->jump, op->fail);
} else {
op->type = R_ANAL_OP_TYPE_ILL;
}
break;
case BPF_JMP_JGE | BPF_X:
case BPF_JMP_JGE | BPF_K:
EMIT_CJMP (op, addr, f);
op->cond = R_ANAL_COND_GE;
if (BPF_SRC (f->code) == BPF_K) {
op->val = f->k;
esilprintf (op,
"%" PFMT64d ",A,>=,?{,%" PFMT64d ",pc,=,BREAK,},%" PFMT64d ",pc,=",
op->val, op->jump, op->fail);
} else {
esilprintf (op,
"X,A,>=,?{,%" PFMT64d ",pc,=,BREAK,},%" PFMT64d ",pc,=",
op->jump, op->fail);
}
break;
case BPF_JMP_JEQ | BPF_X:
case BPF_JMP_JEQ | BPF_K:
EMIT_CJMP (op, addr, f);
op->cond = R_ANAL_COND_EQ;
if (BPF_SRC (f->code) == BPF_K) {
op->val = f->k;
esilprintf (op,
"%" PFMT64d ",A,==,$z,?{,%" PFMT64d ",pc,=,BREAK,},%" PFMT64d ",pc,=",
op->val, op->jump, op->fail);
} else {
esilprintf (op,
"X,A,==,$z,?{,%" PFMT64d ",pc,=,BREAK,},%" PFMT64d ",pc,=",
op->jump, op->fail);
}
break;
case BPF_JMP_JSET | BPF_X:
case BPF_JMP_JSET | BPF_K:
EMIT_CJMP (op, addr, f);
if (BPF_SRC (f->code) == BPF_K) {
op->val = f->k;
esilprintf (op,
"%" PFMT64d ",A,&,?{,%" PFMT64d ",pc,=,BREAK,},%" PFMT64d ",pc,=",
op->val, op->jump, op->fail);
} else {
esilprintf (op,
"X,A,&,!,?{,%" PFMT64d ",pc,=,BREAK,},%" PFMT64d ",pc,=",
op->val, op->jump, op->fail);
}
break;
case BPF_ALU_NEG:
op->type = R_ANAL_OP_TYPE_NOT;
esilprintf (op, "A,0,-,A,=");
SET_REG_SRC_DST (op, "A", "A");
break;
case BPF_ALU_LSH | BPF_X:
case BPF_ALU_LSH | BPF_K:
op->type = R_ANAL_OP_TYPE_SHL;
if (BPF_SRC (f->code) == BPF_K) {
op->val = f->k;
SET_REG_DST_IMM (op, "A", f->k);
esilprintf (op, "%" PFMT64d ",A,<<=", f->k);
} else {
SET_REG_SRC_DST (op, "X", "A");
esilprintf (op, "X,A,<<=");
}
break;
case BPF_ALU_RSH | BPF_X:
case BPF_ALU_RSH | BPF_K:
op->type = R_ANAL_OP_TYPE_SHR;
if (BPF_SRC (f->code) == BPF_K) {
op->val = f->k;
SET_REG_DST_IMM (op, "A", f->k);
esilprintf (op, "%" PFMT64d ",A,>>=", f->k);
} else {
SET_REG_SRC_DST (op, "X", "A");
esilprintf (op, "X,A,>>=");
}
break;
case BPF_ALU_ADD | BPF_X:
case BPF_ALU_ADD | BPF_K:
op->type = R_ANAL_OP_TYPE_ADD;
if (BPF_SRC (f->code) == BPF_K) {
op->val = f->k;
SET_REG_DST_IMM (op, "A", op->val);
esilprintf (op, "%" PFMT64d ",A,+=", op->val);
} else {
SET_REG_SRC_DST (op, "X", "A");
esilprintf (op, "X,A,+=");
}
break;
case BPF_ALU_SUB | BPF_X:
case BPF_ALU_SUB | BPF_K:
op->type = R_ANAL_OP_TYPE_SUB;
if (BPF_SRC (f->code) == BPF_K) {
op->val = f->k;
SET_REG_DST_IMM (op, "A", op->val);
esilprintf (op, "%" PFMT64d ",A,-=", op->val);
} else {
SET_REG_SRC_DST (op, "X", "A");
esilprintf (op, "X,A,-=");
}
break;
case BPF_ALU_MUL | BPF_X:
case BPF_ALU_MUL | BPF_K:
op->type = R_ANAL_OP_TYPE_MUL;
if (BPF_SRC (f->code) == BPF_K) {
op->val = f->k;
SET_REG_DST_IMM (op, "A", f->k);
esilprintf (op, "%" PFMT64d ",A,*=", f->k);
} else {
SET_REG_SRC_DST (op, "X", "A");
esilprintf (op, "X,A,*=");
}
break;
case BPF_ALU_DIV | BPF_X:
case BPF_ALU_DIV | BPF_K:
op->type = R_ANAL_OP_TYPE_DIV;
if (BPF_SRC (f->code) == BPF_K) {
op->val = f->k;
SET_REG_DST_IMM (op, "A", f->k);
if (f->k == 0) {
esilprintf (op, "0,R0,=,0,$");
} else {
esilprintf (op, "%" PFMT64d ",A,/=", f->k);
}
} else {
SET_REG_SRC_DST (op, "X", "A");
esilprintf (op, "0,X,==,$z,?{,0,R0,=,0,$,BREAK,},X,A,/=");
}
break;
case BPF_ALU_MOD | BPF_X:
case BPF_ALU_MOD | BPF_K:
op->type = R_ANAL_OP_TYPE_MOD;
if (BPF_SRC (f->code) == BPF_K) {
op->val = f->k;
SET_REG_DST_IMM (op, "A", f->k);
if (f->k == 0) {
esilprintf (op, "0,R0,=,0,$");
} else {
esilprintf (op, "%" PFMT64d ",A,%%=", f->k);
}
} else {
SET_REG_SRC_DST (op, "X", "A");
esilprintf (op, "0,X,==,$z,?{,0,R0,=,0,$,BREAK,},X,A,%%=");
}
break;
case BPF_ALU_AND | BPF_X:
case BPF_ALU_AND | BPF_K:
op->type = R_ANAL_OP_TYPE_AND;
if (BPF_SRC (f->code) == BPF_K) {
op->val = f->k;
SET_REG_DST_IMM (op, "A", f->k);
esilprintf (op, "%" PFMT64d ",A,&=", f->k);
} else {
SET_REG_SRC_DST (op, "X", "A");
esilprintf (op, "X,A,&=");
}
break;
case BPF_ALU_OR | BPF_X:
case BPF_ALU_OR | BPF_K:
op->type = R_ANAL_OP_TYPE_OR;
if (BPF_SRC (f->code) == BPF_K) {
op->val = f->k;
SET_REG_DST_IMM (op, "A", f->k);
esilprintf (op, "%" PFMT64d ",A,|=", f->k);
} else {
SET_REG_SRC_DST (op, "X", "A");
esilprintf (op, "X,A,|,A,=");
}
break;
case BPF_ALU_XOR | BPF_X:
case BPF_ALU_XOR | BPF_K:
op->type = R_ANAL_OP_TYPE_XOR;
if (BPF_SRC (f->code) == BPF_K) {
op->val = f->k;
SET_REG_DST_IMM (op, "A", f->k);
esilprintf (op, "%" PFMT64d ",A,^=", f->k);
} else {
SET_REG_SRC_DST (op, "X", "A");
esilprintf (op, "X,A,^=");
}
break;
default:
op->type = R_ANAL_OP_TYPE_ILL;
break;
}
return op->size;
}
static int set_reg_profile(RAnal *anal) {
const char *p =
"=PC pc\n"
"gpr A .32 0 0\n"
"gpr X .32 4 0\n"
"gpr M[0] .32 8 0\n"
"gpr M[1] .32 12 0\n"
"gpr M[2] .32 16 0\n"
"gpr M[3] .32 20 0\n"
"gpr M[4] .32 24 0\n"
"gpr M[5] .32 28 0\n"
"gpr M[6] .32 32 0\n"
"gpr M[7] .32 36 0\n"
"gpr M[8] .32 40 0\n"
"gpr M[9] .32 44 0\n"
"gpr M[10] .32 48 0\n"
"gpr M[11] .32 52 0\n"
"gpr M[12] .32 56 0\n"
"gpr M[13] .32 60 0\n"
"gpr M[14] .32 64 0\n"
"gpr M[15] .32 68 0\n"
"gpr pc .32 72 0\n"
"gpr len .32 76 0\n"
"gpr R0 .32 80 0\n"
"gpr R1 .32 84 0\n"
"gpr R2 .32 88 0\n"
"gpr R3 .32 92 0\n"
"gpr R4 .32 96 0\n"
"gpr R5 .32 100 0\n";
return r_reg_set_profile_string (anal->reg, p);
}
static bool bpf_int_exit(RAnalEsil *esil, ut32 interrupt, void *user) {
int syscall;
ut64 r0;
if (!esil || (interrupt != 0x0))
return false;
r_anal_esil_reg_read (esil, "R0", &r0, NULL);
if (r0 == 0) {
esil->anal->cb_printf ("; BPF result: DROP value: %d\n", (int)r0);
eprintf ("BPF result: DROP value: %d\n", (int)r0);
} else {
esil->anal->cb_printf ("; BPF result: ACCEPT value: %d\n", (int)r0);
eprintf ("BPF result: ACCEPT value: %d\n", (int)r0);
}
return true;
}
static int esil_bpf_init(RAnalEsil *esil) {
if (!esil)
return false;
RAnalEsilInterrupt *intr = r_anal_esil_interrupt_new (esil, 0, &ih);
r_anal_esil_set_interrupt (esil, intr);
return true;
}
static int esil_bpf_fini(RAnalEsil *esil) {
return true;
}
struct r_anal_plugin_t r_anal_plugin_bpf = {
.name = "bpf",
.desc = "Berkely packet filter analysis plugin",
.license = "GPLv2",
.arch = "bpf",
.bits = 32,
.esil = true,
.init = NULL,
.fini = NULL,
.reset_counter = NULL,
.archinfo = NULL,
.op = &bpf_anal,
.bb = NULL,
.fcn = NULL,
.analyze_fns = NULL,
.op_from_buffer = NULL,
.bb_from_buffer = NULL,
.fn_from_buffer = NULL,
.analysis_algorithm = NULL,
.set_reg_profile = &set_reg_profile,
.fingerprint_bb = NULL,
.fingerprint_fcn = NULL,
.diff_bb = NULL,
.diff_fcn = NULL,
.diff_eval = NULL,
.pre_anal = NULL,
.pre_anal_fn_cb = NULL,
.pre_anal_op_cb = NULL,
.post_anal_op_cb = NULL,
.pre_anal_bb_cb = NULL,
.post_anal_bb_cb = NULL,
.post_anal_fn_cb = NULL,
.post_anal = NULL,
.revisit_bb_anal = NULL,
.cmd_ext = NULL,
.esil_init = &esil_bpf_init,
.esil_post_loop = NULL,
.esil_trap = NULL,
.esil_fini = &esil_bpf_fini
};
#ifndef CORELIB
struct r_lib_struct_t radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.data = &r_anal_plugin_bpf,
.version = R2_VERSION
};
#endif
+767
View File
@@ -0,0 +1,767 @@
/*
* Most of this is copied and pasted from linux source (except
* for the assembler part).
*
* Copyright 2015 - mrmacete <[email protected]>
* Licensed under the GNU General Public License, version 2.0 (GPLv2)
*/
#include <r_types.h>
#include <r_util.h>
#include <r_lib.h>
#include <r_asm.h>
#include "bpf.h"
static int disassemble(RAsm *a, RAsmOp *r_op, const ut8 *buf, int len) {
const char *op, *fmt;
RBpfSockFilter *f = (RBpfSockFilter *)buf;
int val = f->k;
char vbuf[256];
switch (f->code) {
case BPF_RET | BPF_K:
op = r_bpf_op_table[BPF_RET];
fmt = "%#x";
break;
case BPF_RET | BPF_A:
op = r_bpf_op_table[BPF_RET];
fmt = "a";
break;
case BPF_RET | BPF_X:
op = r_bpf_op_table[BPF_RET];
fmt = "x";
break;
case BPF_MISC_TAX:
op = r_bpf_op_table[BPF_MISC_TAX];
fmt = "";
break;
case BPF_MISC_TXA:
op = r_bpf_op_table[BPF_MISC_TXA];
fmt = "";
break;
case BPF_ST:
op = r_bpf_op_table[BPF_ST];
fmt = "M[%d]";
break;
case BPF_STX:
op = r_bpf_op_table[BPF_STX];
fmt = "M[%d]";
break;
case BPF_LD_W | BPF_ABS:
op = r_bpf_op_table[BPF_LD_W];
fmt = "[%d]";
break;
case BPF_LD_H | BPF_ABS:
op = r_bpf_op_table[BPF_LD_H];
fmt = "[%d]";
break;
case BPF_LD_B | BPF_ABS:
op = r_bpf_op_table[BPF_LD_B];
fmt = "[%d]";
break;
case BPF_LD_W | BPF_LEN:
op = r_bpf_op_table[BPF_LD_W];
fmt = "len";
break;
case BPF_LD_W | BPF_IND:
op = r_bpf_op_table[BPF_LD_W];
fmt = "[x+%d]";
break;
case BPF_LD_H | BPF_IND:
op = r_bpf_op_table[BPF_LD_H];
fmt = "[x+%d]";
break;
case BPF_LD_B | BPF_IND:
op = r_bpf_op_table[BPF_LD_B];
fmt = "[x+%d]";
break;
case BPF_LD | BPF_IMM:
op = r_bpf_op_table[BPF_LD_W];
fmt = "%#x";
break;
case BPF_LDX | BPF_IMM:
op = r_bpf_op_table[BPF_LDX];
fmt = "%#x";
break;
case BPF_LDX | BPF_LEN:
op = r_bpf_op_table[BPF_LDX];
fmt = "len";
break;
case BPF_LDX | BPF_ABS:
op = r_bpf_op_table[BPF_LDX];
fmt = "[%d]";
break;
case BPF_LDX_B | BPF_MSH:
op = r_bpf_op_table[BPF_LDX_B];
fmt = "4*([%d]&0xf)";
break;
case BPF_LD | BPF_MEM:
op = r_bpf_op_table[BPF_LD_W];
fmt = "M[%d]";
break;
case BPF_LDX | BPF_MEM:
op = r_bpf_op_table[BPF_LDX];
fmt = "M[%d]";
break;
case BPF_JMP_JA:
op = r_bpf_op_table[BPF_JMP_JA];
fmt = "%d";
val = a->pc + 8 + f->k * 8;
break;
case BPF_JMP_JGT | BPF_X:
op = r_bpf_op_table[BPF_JMP_JGT];
fmt = "x";
break;
case BPF_JMP_JGT | BPF_K:
op = r_bpf_op_table[BPF_JMP_JGT];
fmt = "%#x";
break;
case BPF_JMP_JGE | BPF_X:
op = r_bpf_op_table[BPF_JMP_JGE];
fmt = "x";
break;
case BPF_JMP_JGE | BPF_K:
op = r_bpf_op_table[BPF_JMP_JGE];
fmt = "%#x";
break;
case BPF_JMP_JEQ | BPF_X:
op = r_bpf_op_table[BPF_JMP_JEQ];
fmt = "x";
break;
case BPF_JMP_JEQ | BPF_K:
op = r_bpf_op_table[BPF_JMP_JEQ];
fmt = "%#x";
break;
case BPF_JMP_JSET | BPF_X:
op = r_bpf_op_table[BPF_JMP_JSET];
fmt = "x";
break;
case BPF_JMP_JSET | BPF_K:
op = r_bpf_op_table[BPF_JMP_JSET];
fmt = "%#x";
break;
case BPF_ALU_NEG:
op = r_bpf_op_table[BPF_ALU_NEG];
fmt = "";
break;
case BPF_ALU_LSH | BPF_X:
op = r_bpf_op_table[BPF_ALU_LSH];
fmt = "x";
break;
case BPF_ALU_LSH | BPF_K:
op = r_bpf_op_table[BPF_ALU_LSH];
fmt = "%d";
break;
case BPF_ALU_RSH | BPF_X:
op = r_bpf_op_table[BPF_ALU_RSH];
fmt = "x";
break;
case BPF_ALU_RSH | BPF_K:
op = r_bpf_op_table[BPF_ALU_RSH];
fmt = "%d";
break;
case BPF_ALU_ADD | BPF_X:
op = r_bpf_op_table[BPF_ALU_ADD];
fmt = "x";
break;
case BPF_ALU_ADD | BPF_K:
op = r_bpf_op_table[BPF_ALU_ADD];
fmt = "%d";
break;
case BPF_ALU_SUB | BPF_X:
op = r_bpf_op_table[BPF_ALU_SUB];
fmt = "x";
break;
case BPF_ALU_SUB | BPF_K:
op = r_bpf_op_table[BPF_ALU_SUB];
fmt = "%d";
break;
case BPF_ALU_MUL | BPF_X:
op = r_bpf_op_table[BPF_ALU_MUL];
fmt = "x";
break;
case BPF_ALU_MUL | BPF_K:
op = r_bpf_op_table[BPF_ALU_MUL];
fmt = "%d";
break;
case BPF_ALU_DIV | BPF_X:
op = r_bpf_op_table[BPF_ALU_DIV];
fmt = "x";
break;
case BPF_ALU_DIV | BPF_K:
op = r_bpf_op_table[BPF_ALU_DIV];
fmt = "%d";
break;
case BPF_ALU_MOD | BPF_X:
op = r_bpf_op_table[BPF_ALU_MOD];
fmt = "x";
break;
case BPF_ALU_MOD | BPF_K:
op = r_bpf_op_table[BPF_ALU_MOD];
fmt = "%d";
break;
case BPF_ALU_AND | BPF_X:
op = r_bpf_op_table[BPF_ALU_AND];
fmt = "x";
break;
case BPF_ALU_AND | BPF_K:
op = r_bpf_op_table[BPF_ALU_AND];
fmt = "%#x";
break;
case BPF_ALU_OR | BPF_X:
op = r_bpf_op_table[BPF_ALU_OR];
fmt = "x";
break;
case BPF_ALU_OR | BPF_K:
op = r_bpf_op_table[BPF_ALU_OR];
fmt = "%#x";
break;
case BPF_ALU_XOR | BPF_X:
op = r_bpf_op_table[BPF_ALU_XOR];
fmt = "x";
break;
case BPF_ALU_XOR | BPF_K:
op = r_bpf_op_table[BPF_ALU_XOR];
fmt = "%#x";
break;
default:
op = "invalid";
fmt = "%#x";
val = f->code;
break;
}
memset (vbuf, 0, sizeof (vbuf));
snprintf (vbuf, sizeof (vbuf), fmt, val);
vbuf[sizeof (vbuf) - 1] = 0;
if ((BPF_CLASS (f->code) == BPF_JMP && BPF_OP (f->code) != BPF_JA))
r_strbuf_setf (&r_op->buf_asm, "%s %s, 0x%08" PFMT64x ", 0x%08" PFMT64x "", op, vbuf,
a->pc + 8 + f->jt * 8, a->pc + 8 + f->jf * 8);
else r_strbuf_setf (&r_op->buf_asm, "%s %s", op, vbuf);
return r_op->size = 8;
}
/* start of ASSEMBLER code */
#define PARSER_MAX_TOKENS 4
#define COPY_AND_RET(a, b)\
r_strbuf_setbin (&a, (const ut8 *)b, sizeof (*b) + 1);\
return 0;
#define PARSE_FAILURE(message, arg...)\
{\
eprintf ("PARSE FAILURE: " message "\n", ##arg);\
return -1;\
}
#define CMP4(tok, n, x, y, z, w)\
(tok[n][0] == x && tok[n][1] == y && tok[n][2] == z && tok[n][3] == w)
#define CMP3(tok, n, x, y, z)\
(tok[n][0] == x && tok[n][1] == y && tok[n][2] == z)
#define CMP2(tok, n, x, y)\
(tok[n][0] == x && tok[n][1] == y)
#define IS_K_TOK(tok, n)\
(tok[n][0] == '-' || R_BETWEEN ('0', tok[n][0], '9'))
#define IS_LEN(tok, n)\
CMP4 (tok, n, 'l', 'e', 'n', '\0')
#define PARSE_K_OR_FAIL(dst, tok, n)\
dst = strtol (&tok[n][0], &end, 0);\
if (*end != '\0' && *end != ',')\
PARSE_FAILURE ("could not parse k");
#define PARSE_LABEL_OR_FAIL(dst, tok, n)\
dst = strtoul (&tok[n][0], &end, 0);\
if (*end != '\0' && *end != ',') {\
return -1;\
}
#define PARSE_OFFSET_OR_FAIL(dst, tok, n, off)\
dst = strtoul (&tok[n][off], &end, 10);\
if (*end != ']')\
PARSE_FAILURE ("could not parse offset value");
#define PARSE_IND_ABS_OR_FAIL(f, tok, n)\
if (CMP3 (tok, 1, '[', 'x', '+')) {\
f->code = f->code | BPF_IND;\
PARSE_OFFSET_OR_FAIL (f->k, tok, 1, 3);\
return 0;\
} else if (tok[1][0] == '[') {\
f->code = f->code | BPF_ABS;\
PARSE_OFFSET_OR_FAIL (f->k, tok, 1, 1);\
return 0;\
}\
PARSE_FAILURE ("could not parse addressing mode");
#define PARSE_K_OR_X_OR_FAIL(f, tok)\
if (IS_K_TOK (tok, 1)) {\
PARSE_K_OR_FAIL (f->k, tok, 1);\
f->code = f->code | BPF_K;\
} else if (tok[1][0] == 'x' && (tok[1][1] == '\0' || tok[1][1] == ',')) {\
f->code = f->code | BPF_X;\
} else {\
PARSE_FAILURE ("could not parse k or x: %s", tok[1]);\
}
#define PARSE_A_OR_X_OR_FAIL(f, tok)\
if (tok[1][0] == 'x' && (tok[1][1] == '\0' || tok[1][1] == ',')) {\
f->code = f->code | BPF_X;\
} else if (tok[1][0] == 'a' && (tok[1][1] == '\0' || tok[1][1] == ',')) {\
f->code = f->code | BPF_A;\
} else {\
PARSE_FAILURE ("could not parse a or x");\
}
#define PARSE_JUMP_TARGETS(a, f, tok, count)\
PARSE_K_OR_X_OR_FAIL (f, tok);\
if (count >= 3) {\
PARSE_LABEL_OR_FAIL (label, tok, 2);\
f->jt = (st64) (label - a->pc - 8) / 8;\
f->jf = (a->pc >> 3) + 1;\
}\
if (count == 4) {\
PARSE_LABEL_OR_FAIL (label, tok, 3);\
f->jf = (st64) (label - a->pc - 8) / 8;\
}
#define SWAP_JUMP_TARGETS(f)\
temp = f->jt;\
f->jt = f->jf;\
f->jf = temp;
#define ENFORCE_COUNT(count, n)\
if (count != n)\
PARSE_FAILURE ("invalid argument count, try to omit '#'");
#define ENFORCE_COUNT_GE(count, n)\
if (count < n)\
PARSE_FAILURE ("invalid argument count, try to omit '#'");
static int assemble_ld(RAsm *a, RAsmOp *op,
char *tok[PARSER_MAX_TOKENS], int count, RBpfSockFilter *f) {
char *end;
switch (tok[0][2]) {
case '\0':
if (CMP2 (tok, 1, 'm', '[')) {
f->code = BPF_LD | BPF_MEM;
PARSE_OFFSET_OR_FAIL (f->k, tok, 1, 2);
} else if (IS_K_TOK (tok, 1)) {
f->code = BPF_LD | BPF_IMM;
PARSE_K_OR_FAIL (f->k, tok, 1);
} else if (IS_LEN (tok, 1)) {
f->code = BPF_LD | BPF_LEN;
} else {
f->code = BPF_LD_W;
PARSE_IND_ABS_OR_FAIL (f, tok, 1);
}
break;
case 'i':
if (IS_K_TOK (tok, 1)) {
f->code = BPF_LD | BPF_IMM;
PARSE_K_OR_FAIL (f->k, tok, 1);
} else {
PARSE_FAILURE ("ldi without k");
}
break;
case 'b':
f->code = BPF_LD_B;
PARSE_IND_ABS_OR_FAIL (f, tok, 1);
break;
case 'h':
f->code = BPF_LD_H;
PARSE_IND_ABS_OR_FAIL (f, tok, 1);
break;
case 'x':
switch (tok[0][3]) {
case '\0':
if (CMP2 (tok, 1, 'm', '[')) {
f->code = BPF_LDX | BPF_MEM;
PARSE_OFFSET_OR_FAIL (f->k, tok, 1, 2);
} else if (IS_K_TOK (tok, 1)) {
f->code = BPF_LDX | BPF_IMM;
PARSE_K_OR_FAIL (f->k, tok, 1);
} else if (IS_LEN (tok, 1)) {
f->code = BPF_LDX | BPF_LEN;
} else {
f->code = BPF_LDX_W;
PARSE_IND_ABS_OR_FAIL (f, tok, 1);
}
break;
case 'i':
if (IS_K_TOK (tok, 1)) {
f->code = BPF_LDX | BPF_IMM;
PARSE_K_OR_FAIL (f->k, tok, 1);
} else {
PARSE_FAILURE ("ldxi without k");
}
break;
case 'b':
f->code = BPF_LDX_B | BPF_MSH;
if (sscanf (tok[1], "4*([%d]&0xf)", &f->k) != 1) {
PARSE_FAILURE ("invalid nibble addressing");
}
break;
}
break;
default:
PARSE_FAILURE ("unsupported load instruction");
}
return 0;
}
static int assemble_j(RAsm *a, RAsmOp *op, char *tok[PARSER_MAX_TOKENS],
int count, RBpfSockFilter *f) {
int label;
ut8 temp;
char *end;
if (CMP4 (tok, 0, 'j', 'm', 'p', '\0') ||
CMP3 (tok, 0, 'j', 'a', '\0')) {
ENFORCE_COUNT (count, 2);
f->code = BPF_JMP_JA;
PARSE_LABEL_OR_FAIL (f->k, tok, 1);
return 0;
}
if (CMP4 (tok, 0, 'j', 'n', 'e', '\0') ||
CMP4 (tok, 0, 'j', 'n', 'e', 'q')) {
ENFORCE_COUNT_GE (count, 3);
f->code = BPF_JMP_JEQ;
PARSE_JUMP_TARGETS (a, f, tok, count);
SWAP_JUMP_TARGETS (f);
return 0;
}
if (CMP4 (tok, 0, 'j', 'e', 'q', '\0')) {
ENFORCE_COUNT_GE (count, 3);
f->code = BPF_JMP_JEQ;
PARSE_JUMP_TARGETS (a, f, tok, count);
return 0;
}
if (CMP4 (tok, 0, 'j', 'l', 't', '\0')) {
ENFORCE_COUNT_GE (count, 3);
f->code = BPF_JMP_JGE;
PARSE_JUMP_TARGETS (a, f, tok, count);
SWAP_JUMP_TARGETS (f);
return 0;
}
if (CMP4 (tok, 0, 'j', 'l', 'e', '\0')) {
ENFORCE_COUNT_GE (count, 3);
f->code = BPF_JMP_JGT;
PARSE_JUMP_TARGETS (a, f, tok, count);
SWAP_JUMP_TARGETS (f);
return 0;
}
if (CMP4 (tok, 0, 'j', 'g', 't', '\0')) {
ENFORCE_COUNT_GE (count, 3);
f->code = BPF_JMP_JGT;
PARSE_JUMP_TARGETS (a, f, tok, count);
return 0;
}
if (CMP4 (tok, 0, 'j', 'g', 'e', '\0')) {
ENFORCE_COUNT_GE (count, 3);
f->code = BPF_JMP_JGE;
PARSE_JUMP_TARGETS (a, f, tok, count);
return 0;
}
if (CMP4 (tok, 0, 'j', 's', 'e', 't')) {
ENFORCE_COUNT_GE (count, 3);
f->code = BPF_JMP_JSET;
PARSE_JUMP_TARGETS (a, f, tok, count);
return 0;
}
return -1;
}
static int assemble_alu(RAsm *a, RAsmOp *op, char *tok[PARSER_MAX_TOKENS],
int count, RBpfSockFilter *f) {
char *end;
if (CMP4 (tok, 0, 'a', 'd', 'd', '\0')) {
ENFORCE_COUNT (count, 2);
f->code = BPF_ALU_ADD;
PARSE_K_OR_X_OR_FAIL (f, tok);
return 0;
}
if (CMP4 (tok, 0, 's', 'u', 'b', '\0')) {
ENFORCE_COUNT (count, 2);
f->code = BPF_ALU_SUB;
PARSE_K_OR_X_OR_FAIL (f, tok);
return 0;
}
if (CMP4 (tok, 0, 'm', 'u', 'l', '\0')) {
ENFORCE_COUNT (count, 2);
f->code = BPF_ALU_MUL;
PARSE_K_OR_X_OR_FAIL (f, tok);
return 0;
}
if (CMP4 (tok, 0, 'd', 'i', 'v', '\0')) {
ENFORCE_COUNT (count, 2);
f->code = BPF_ALU_DIV;
PARSE_K_OR_X_OR_FAIL (f, tok);
return 0;
}
if (CMP4 (tok, 0, 'm', 'o', 'd', '\0')) {
ENFORCE_COUNT (count, 2);
f->code = BPF_ALU_MOD;
PARSE_K_OR_X_OR_FAIL (f, tok);
return 0;
}
if (CMP4 (tok, 0, 'n', 'e', 'g', '\0')) {
ENFORCE_COUNT (count, 1);
f->code = BPF_ALU_NEG;
return 0;
}
if (CMP4 (tok, 0, 'a', 'n', 'd', '\0')) {
ENFORCE_COUNT (count, 2);
f->code = BPF_ALU_AND;
PARSE_K_OR_X_OR_FAIL (f, tok);
return 0;
}
if (CMP3 (tok, 0, 'o', 'r', '\0')) {
ENFORCE_COUNT (count, 2);
f->code = BPF_ALU_OR;
PARSE_K_OR_X_OR_FAIL (f, tok);
return 0;
}
if (CMP4 (tok, 0, 'x', 'o', 'r', '\0')) {
ENFORCE_COUNT (count, 2);
f->code = BPF_ALU_XOR;
PARSE_K_OR_X_OR_FAIL (f, tok);
return 0;
}
if (CMP4 (tok, 0, 'l', 's', 'h', '\0')) {
ENFORCE_COUNT (count, 2);
f->code = BPF_ALU_LSH;
PARSE_K_OR_X_OR_FAIL (f, tok);
return 0;
}
if (CMP4 (tok, 0, 'r', 's', 'h', '\0')) {
ENFORCE_COUNT (count, 2);
f->code = BPF_ALU_RSH;
PARSE_K_OR_X_OR_FAIL (f, tok);
return 0;
}
return -1;
}
static int assemble_tok(RAsm *a, RAsmOp *op,
char *tok[PARSER_MAX_TOKENS], int count) {
char *end;
int oplen = 0;
RBpfSockFilter f = { 0, 0, 0, 0 };
oplen = strnlen (tok[0], 5);
if (oplen < 2 || oplen > 4) {
PARSE_FAILURE ("mnemonic length not valid");
}
if (CMP4 (tok, 0, 't', 'x', 'a', '\0')) {
ENFORCE_COUNT (count, 1);
f.code = BPF_MISC_TXA;
COPY_AND_RET (op->buf, &f);
}
if (CMP4 (tok, 0, 't', 'a', 'x', '\0')) {
ENFORCE_COUNT (count, 1);
f.code = BPF_MISC_TAX;
COPY_AND_RET (op->buf, &f);
}
if (CMP4 (tok, 0, 'r', 'e', 't', '\0')) {
ENFORCE_COUNT (count, 2);
if (IS_K_TOK (tok, 1)) {
f.code = BPF_RET | BPF_K;
PARSE_K_OR_FAIL (f.k, tok, 1);
} else if (tok[1][0] == 'x') {
f.code = BPF_RET | BPF_X;
} else if (tok[1][0] == 'a') {
f.code = BPF_RET | BPF_A;
} else {
PARSE_FAILURE ("unsupported ret instruction");
}
COPY_AND_RET (op->buf, &f);
}
if (CMP2 (tok, 0, 'l', 'd')) {
ENFORCE_COUNT (count, 2);
if (assemble_ld (a, op, tok, count, &f) == 0) {
COPY_AND_RET (op->buf, &f);
} else {
return -1;
}
}
if (CMP2 (tok, 0, 's', 't')) {
ENFORCE_COUNT (count, 2);
if (tok[0][2] == '\0') {
f.code = BPF_ST;
} else if (tok[0][2] == 'x') {
f.code = BPF_STX;
}
if (CMP2 (tok, 1, 'm', '[')) {
PARSE_OFFSET_OR_FAIL (f.k, tok, 1, 2);
if (f.k > 15) {
PARSE_FAILURE ("mem addressing out of bounds");
}
COPY_AND_RET (op->buf, &f);
} else {
PARSE_FAILURE ("invalid store addressing");
}
}
if (tok[0][0] == 'j') {
if (assemble_j (a, op, tok, count, &f) == 0) {
COPY_AND_RET (op->buf, &f);
} else {
return -1;
}
}
if (assemble_alu (a, op, tok, count, &f) == 0) {
COPY_AND_RET (op->buf, &f);
} else {
return -1;
}
}
static void lower_op(char *c) {
if ((c[0] <= 'Z') && (c[0] >= 'A')) {
c[0] += 0x20;
}
}
#define R_TRUE 1
static void normalize(RStrBuf *buf) {
int i;
char *buf_asm;
if (!buf)
return;
buf_asm = r_strbuf_get (buf);
/* this normalization step is largely sub-optimal */
i = strlen (buf_asm);
while (strstr (buf_asm, " ")) {
r_str_replace_in (buf_asm, (ut32)i, " ", " ", R_TRUE);
}
r_str_replace_in (buf_asm, (ut32)i, " ,", ",", R_TRUE);
r_str_replace_in (buf_asm, (ut32)i, "[ ", "[", R_TRUE);
r_str_replace_in (buf_asm, (ut32)i, " ]", "]", R_TRUE);
r_str_replace_in (buf_asm, (ut32)i, "( ", "(", R_TRUE);
r_str_replace_in (buf_asm, (ut32)i, " )", ")", R_TRUE);
r_str_replace_in (buf_asm, (ut32)i, "+ ", "+", R_TRUE);
r_str_replace_in (buf_asm, (ut32)i, " +", "+", R_TRUE);
r_str_replace_in (buf_asm, (ut32)i, "* ", "*", R_TRUE);
r_str_replace_in (buf_asm, (ut32)i, " *", "*", R_TRUE);
r_str_replace_in (buf_asm, (ut32)i, "& ", "&", R_TRUE);
r_str_replace_in (buf_asm, (ut32)i, " &", "&", R_TRUE);
r_str_replace_in (buf_asm, (ut32)i, "%", "", R_TRUE);
r_str_replace_in (buf_asm, (ut32)i, "#", "", R_TRUE);
r_str_do_until_token (lower_op, buf_asm, '\0');
r_strbuf_set (buf, buf_asm);
}
static int assemble(RAsm *a, RAsmOp *op, const char *buf) {
char *tok[PARSER_MAX_TOKENS];
char tmp[128];
int i, j, l;
const char *p = NULL;
if (!a || !op || !buf) {
return 0;
}
r_strbuf_set (&op->buf_asm, buf);
normalize (&op->buf_asm);
// tokenization, copied from profile.c
j = 0;
p = r_strbuf_get (&op->buf_asm);
// For every word
while (*p) {
// Skip the whitespace
while (*p == ' ' || *p == '\t') {
p++;
}
// Skip the rest of the line is a comment is encountered
if (*p == ';') {
while (*p != '\0') {
p++;
}
}
// EOL ?
if (*p == '\0') {
break;
}
// Gather a handful of chars
// Use isgraph instead of isprint because the latter considers ' ' printable
for (i = 0; isgraph ((const unsigned char)*p) && i < sizeof (tmp) - 1;) {
tmp[i++] = *p++;
}
tmp[i] = '\0';
// Limit the number of tokens
if (j > PARSER_MAX_TOKENS - 1) {
break;
}
// Save the token
tok[j++] = strdup (tmp);
}
if (j) {
if (assemble_tok (a, op, tok, j) < 0) {
return -1;
}
// Clean up
for (i = 0; i < j; i++) {
free (tok[i]);
}
}
return op->size = 8;
}
RAsmPlugin r_asm_plugin_bpf = {
.name = "bpf",
.desc = "Berkeley Packet Filter disassembler",
.license = "GPLv2",
.arch = "bpf",
.bits = 32,
.disassemble = &disassemble,
.assemble = &assemble
};
#ifndef CORELIB
struct r_lib_struct_t radare_plugin = {
.type = R_LIB_TYPE_ASM,
.data = &r_asm_plugin_bpf,
.version = R2_VERSION
};
#endif
+98
View File
@@ -0,0 +1,98 @@
/* LGPL3 - Copyright 2015 - mrmacete */
/* it's a blatant copy of "any" bin plugin from radare, big_endian = 1 */
#include <r_types.h>
#include <r_util.h>
#include <r_lib.h>
#include <r_bin.h>
#include <r_magic.h>
static char *get_filetype(RBinFile *arch) {
ut8 buf[4096] = { 0 };
char *res = NULL;
RMagic *ck;
if (!arch)
return NULL;
ck = r_magic_new (0);
if (ck && arch && arch->buf) {
const char *tmp = NULL;
r_magic_load (ck, R2_SDB_MAGIC);
r_buf_read_at (arch->buf, 0, buf, sizeof (buf));
tmp = r_magic_buffer (ck, buf, sizeof (buf));
if (tmp)
res = strdup (tmp);
}
r_magic_free (ck);
return res;
}
static RBinInfo *info(RBinFile *arch) {
RBinInfo *ret = R_NEW0 (RBinInfo);
if (!ret)
return NULL;
ret->lang = "";
ret->file = arch->file ? strdup (arch->file) : NULL;
ret->type = get_filetype (arch);
ret->has_pi = 0;
ret->has_canary = 0;
if (R_SYS_BITS & R_SYS_BITS_64) {
ret->bits = 64;
} else {
ret->bits = 32;
}
ret->big_endian = 1;
ret->has_va = 0;
ret->has_nx = 0;
ret->dbg_info = 0;
ret->dbg_info = 0;
ret->dbg_info = 0;
return ret;
}
static bool load(RBinFile *arch) {
return true;
}
static int destroy(RBinFile *arch) {
return true;
}
static ut64 baddr(RBinFile *arch) {
return 0LL;
}
struct r_bin_plugin_t r_bin_plugin_bpf = {
.name = "bpf",
.desc = "Berkeley Packet Filter - raw binary",
.license = "LGPL3",
.init = NULL,
.fini = NULL,
.get_sdb = NULL,
.load = &load,
.load_bytes = NULL,
.destroy = &destroy,
.baddr = &baddr,
.boffset = NULL,
.binsym = NULL,
.entries = NULL,
.sections = NULL,
.symbols = NULL,
.imports = NULL,
.strings = NULL,
.info = info,
.fields = NULL,
.libs = NULL,
.relocs = NULL,
.dbginfo = NULL,
.create = NULL,
.write = NULL,
.minstrlen = 0,
};
#ifndef CORELIB
struct r_lib_struct_t radare_plugin = {
.type = R_LIB_TYPE_BIN,
.data = &r_bin_plugin_bpf,
.version = R2_VERSION
};
#endif
BIN
View File
Binary file not shown.
+82
View File
@@ -0,0 +1,82 @@
/*
* Most of this is copied and pasted from linux kernel source
*
* Copyright 2015 - mrmacete <[email protected]>
* Licensed under the GNU General Public License, version 2.0 (GPLv2)
*/
#ifndef _BPF_H_
#define _BPF_H_
#include "bpf_common.h"
/* defines ripped from linux/filter.h : */
#define BPF_A 0x10
#define BPF_TAX 0x00
#define BPF_TXA 0x80
/* defines ripped from bpf_dbg.c : */
#define BPF_LDX_B (BPF_LDX | BPF_B)
#define BPF_LDX_W (BPF_LDX | BPF_W)
#define BPF_JMP_JA (BPF_JMP | BPF_JA)
#define BPF_JMP_JEQ (BPF_JMP | BPF_JEQ)
#define BPF_JMP_JGT (BPF_JMP | BPF_JGT)
#define BPF_JMP_JGE (BPF_JMP | BPF_JGE)
#define BPF_JMP_JSET (BPF_JMP | BPF_JSET)
#define BPF_ALU_ADD (BPF_ALU | BPF_ADD)
#define BPF_ALU_SUB (BPF_ALU | BPF_SUB)
#define BPF_ALU_MUL (BPF_ALU | BPF_MUL)
#define BPF_ALU_DIV (BPF_ALU | BPF_DIV)
#define BPF_ALU_MOD (BPF_ALU | BPF_MOD)
#define BPF_ALU_NEG (BPF_ALU | BPF_NEG)
#define BPF_ALU_AND (BPF_ALU | BPF_AND)
#define BPF_ALU_OR (BPF_ALU | BPF_OR)
#define BPF_ALU_XOR (BPF_ALU | BPF_XOR)
#define BPF_ALU_LSH (BPF_ALU | BPF_LSH)
#define BPF_ALU_RSH (BPF_ALU | BPF_RSH)
#define BPF_MISC_TAX (BPF_MISC | BPF_TAX)
#define BPF_MISC_TXA (BPF_MISC | BPF_TXA)
#define BPF_LD_B (BPF_LD | BPF_B)
#define BPF_LD_H (BPF_LD | BPF_H)
#define BPF_LD_W (BPF_LD | BPF_W)
static const char * const r_bpf_op_table[] = {
[BPF_ST] = "st",
[BPF_STX] = "stx",
[BPF_LD_B] = "ldb",
[BPF_LD_H] = "ldh",
[BPF_LD_W] = "ld",
[BPF_LDX] = "ldx",
[BPF_LDX_B] = "ldxb",
[BPF_JMP_JA] = "ja",
[BPF_JMP_JEQ] = "jeq",
[BPF_JMP_JGT] = "jgt",
[BPF_JMP_JGE] = "jge",
[BPF_JMP_JSET] = "jset",
[BPF_ALU_ADD] = "add",
[BPF_ALU_SUB] = "sub",
[BPF_ALU_MUL] = "mul",
[BPF_ALU_DIV] = "div",
[BPF_ALU_MOD] = "mod",
[BPF_ALU_NEG] = "neg",
[BPF_ALU_AND] = "and",
[BPF_ALU_OR] = "or",
[BPF_ALU_XOR] = "xor",
[BPF_ALU_LSH] = "lsh",
[BPF_ALU_RSH] = "rsh",
[BPF_MISC_TAX] = "tax",
[BPF_MISC_TXA] = "txa",
[BPF_RET] = "ret",
};
typedef struct r_bpf_sock_filter { /* Filter block */
ut16 code; /* Actual filter code */
st8 jt; /* Jump true */
st8 jf; /* Jump false */
ut32 k; /* Generic multiuse field */
} RBpfSockFilter;
#endif
+60
View File
@@ -0,0 +1,60 @@
/*
* this file is directly copied from linux source
* Licensed under the GNU General Public License, version 2.0 (GPLv2)
*/
#ifndef _UAPI__LINUX_BPF_COMMON_H__
#define _UAPI__LINUX_BPF_COMMON_H__
/* Instruction classes */
#define BPF_CLASS(code) ((code) & 0x07)
#define BPF_LD 0x00
#define BPF_LDX 0x01
#define BPF_ST 0x02
#define BPF_STX 0x03
#define BPF_ALU 0x04
#define BPF_JMP 0x05
#define BPF_RET 0x06
#define BPF_MISC 0x07
/* ld/ldx fields */
#define BPF_SIZE(code) ((code) & 0x18)
#define BPF_W 0x00
#define BPF_H 0x08
#define BPF_B 0x10
#define BPF_MODE(code) ((code) & 0xe0)
#define BPF_IMM 0x00
#define BPF_ABS 0x20
#define BPF_IND 0x40
#define BPF_MEM 0x60
#define BPF_LEN 0x80
#define BPF_MSH 0xa0
/* alu/jmp fields */
#define BPF_OP(code) ((code) & 0xf0)
#define BPF_ADD 0x00
#define BPF_SUB 0x10
#define BPF_MUL 0x20
#define BPF_DIV 0x30
#define BPF_OR 0x40
#define BPF_AND 0x50
#define BPF_LSH 0x60
#define BPF_RSH 0x70
#define BPF_NEG 0x80
#define BPF_MOD 0x90
#define BPF_XOR 0xa0
#define BPF_JA 0x00
#define BPF_JEQ 0x10
#define BPF_JGT 0x20
#define BPF_JGE 0x30
#define BPF_JSET 0x40
#define BPF_SRC(code) ((code) & 0x08)
#define BPF_K 0x00
#define BPF_X 0x08
#ifndef BPF_MAXINSNS
#define BPF_MAXINSNS 4096
#endif
#endif /* _UAPI__LINUX_BPF_COMMON_H__ */
+11
View File
@@ -0,0 +1,11 @@
This is the r2 plugin to read/write memory using the checkm8 exploit.
1. Clone https://github.com/axi0mX/ipwndfu
2. Copy this file into the root directory of this repository
3. r2 -I r2io.py ipwndfu://
4. enjoy
NOTES
* This is very unstable, reading on unallocated regions results in device reboot
* Requires python3 .. so maybe better use @geohot's fork
+65
View File
@@ -0,0 +1,65 @@
# iOS pwndfu checkm8 io plugin for radare2
# ========================================
#
# -- pancake @ nopcode.org
#
# Usage:
# r2 -I test-py-io.py pwndfu://
#
# The r2lang.plugin function exposes a way to register new plugins
# into the RCore instance. This API is only available from RLang.
# You must call with with '#!python test.py' or 'r2 -i test.py ..'
import r2lang
from dfuexec import *
FAKESIZE = 512
device = None
def pyio(a):
def _open(path, rw, perm):
global device
device = dfu.acquire_device()
serial_number = device.serial_number
dfu.release_device(device)
device = PwnedDFUDevice()
print("MyPyIO Opening %s"%(path))
return 1234
def _check(path, many):
print("python-check %s"%(path))
return path[0:9] == "pwndfu://"
def _read(offset, length):
global device
res = device.read_memory(address, length)
print("python-read")
return res
def _seek(offset, whence):
print("python-seek")
if whence == 0: # SET
return offset
if whence == 1: # CUR
return offset
if whence == 2: # END
return ROM_SIZE
return ROM_SIZE
def _write(offset, data, length):
print("TODO: python-write")
return True
def _system(cmd):
print("pwndfu://%s"%(cmd))
return True
return {
"name": "pwndfu",
"license": "GPL",
"desc": "pwndfu IO plugin (pwndfu://3)",
"check": _check,
"open": _open,
"read": _read,
"seek": _seek,
"write": _write,
"system": _system,
}
print("Registering Python IO plugin...")
print(r2lang.plugin("io", pyio))
Vendored
+71 -55
View File
@@ -1,9 +1,10 @@
#!/bin/sh
# This script was automatically generated by ACR v0.10.2
# This script was automatically generated by ACR v1.7.2
# @author: pancake <nopcode.org>
# @url: http://www.nopcode.org
# @repo: git clone https://github.com/radare/acr
[ -z "${AWK}" ] && AWK=awk
do_remove() {
if [ "${ACR_RMFILES}" ]; then
printf "cleaning temporally files... "
@@ -25,7 +26,7 @@ while : ; do
ENVWORDS="${ENVWORDS} $1_CPU $1_OS"
STR=`eval "echo ${S}$1"`
SPLIT_CPU="`echo "$STR" | cut -d - -f 1`"
SPLIT_OS="`echo "$STR" | awk -F - '{
SPLIT_OS="`echo "$STR" | $AWK -F - '{
if ($2=="unknown"){
if (NF<3) { print $2; } else { print $3; }
} else {
@@ -41,7 +42,7 @@ done
}
VPATH=`dirname ${0}`
if [ "${VPATH}" = "." ]; then
if [ "${VPATH}" = "." ]; then
WODIS=current
else
if [ "${VPATH}" = "${PWD}" ]; then
@@ -63,6 +64,7 @@ if [ -e "${VPATH}/config.guess" ]; then
fi
CPU="`uname -m|sed -e 's, ,,g'|cut -d - -f 1`"
OS="`uname -s|tr A-Z a-z`"
uname -r | grep -qE "(Microsoft|WSL)" 2>/dev/null && OS="wsl"
GNU="`uname --help 2>&1 | grep gnu`"
[ "${GNU}" ] && OS="${OS}-gnu"
[ "${CPU}" = ppc ] && CPU="powerpc"
@@ -90,10 +92,11 @@ create_environ() {
: ${DATADIR:="${SPREFIX}/share"}
: ${INFODIR:="${DATADIR}/info"}
: ${MANDIR:="${DATADIR}/man"}
: ${DOCDIR:="${DATADIR}/doc/radare2-extras"}
: ${LOCALSTATEDIR:="${SPREFIX}/var"}
for A in `echo ${PATH} | sed -e 's,:, ,g'` ; do
[ -e $A/ginstall ] && : ${INSTALL:=$A/ginstall} && break
[ -e $A/install ] && : ${INSTALL:=$A/install} && break
[ -e "$A"/ginstall ] && : ${INSTALL:="$A"/ginstall} && break
[ -e "$A"/install ] && : ${INSTALL:="$A"/install} && break
done
: ${INSTALL_DIR:=${INSTALL} -d}
: ${INSTALL_DATA:=${INSTALL} -m 644}
@@ -102,12 +105,12 @@ done
: ${INSTALL_PROGRAM_STRIP:=${INSTALL} -m 755 -s}
: ${INSTALL_MAN:=${INSTALL} -m 444}
: ${INSTALL_LIB:=${INSTALL} -m 755 -c}
PKGNAME='radare2-extras' ; VERSION='1.0' ; CONTACT_MAIL="[email protected]" ; CONTACT_NAME="pancake" ; CONTACT="pancake <[email protected]>" ;
PKGNAME='radare2-extras' ; VERSION='4.0.0' ; CONTACT_MAIL="[email protected]" ; CONTACT_NAME="pancake" ; CONTACT="pancake <[email protected]>" ;
}
show_usage() {
cat <<EOF2
'configure' configures radare2-extras-1.0 to adapt to many kinds of systems.
'configure' configures radare2-extras-4.0.0 to adapt to many kinds of systems.
Usage: ./configure [OPTION]... [VAR=VALUE]...
@@ -118,27 +121,28 @@ Defaults for the options are specified in brackets.
Configuration:
-h, --help display this help and exit
-V, --version display version information and exit
-r, --report show what libs/programs require to work
-V, --version display version information and exit
Installation directories:
--prefix=PREFIX install arch-independent files in PREFIX [/usr/local]
--exec-prefix=EPREFIX install arch-dependent files in EPREFIX [PREFIX]
--prefix=PREFIX install arch-independent files in PREFIX [/usr/local]
--sandbox=SPREFIX sandbox prefix directory: SPREFIX [PREFIX]
Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--datadir=DIR read-only architecture-independent data [PREFIX/share]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--libdir=DIR object code libraries [EPREFIX/lib]
--libpath=DIR set rpath/libname-path to linker
--docdir=DIR documentation directory [DATADIR/doc/radare2-extras]
--includedir=DIR C header files [PREFIX/include]
--infodir=DIR info documentation [DATADIR/info]
--libexecdir=DIR program executables [EPREFIX/libexec]
--libdir=DIR object code libraries [EPREFIX/lib]
--libpath=DIR set rpath/libname-path to linker
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--mandir=DIR man documentation [DATADIR/man]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
System types:
--build=BUILD configure for building on BUILD [guessed]
@@ -148,8 +152,8 @@ EOF2
printf "
Optional Features:
--with-ostype Choose OS type ( gnulinux windows darwin haiku ) (USEROSTYPE=auto)
--without-ewf build without libewf
--with-ostype Choose OS type ( gnulinux windows darwin haiku ) (USEROSTYPE=auto)
--without-ewf build without libewf
"
printf "
Some influential environment variables:
@@ -176,7 +180,7 @@ take_environ() {
}
show_version() {
echo "radare2-extras-1.0 configuration script done with acr v0.10.2.
echo "radare2-extras-4.0.0 configuration script done with acr v1.7.2.
The 'Free Software Foundation' message is only for autodetection.
Originally written by pancake <nopcode.org>."
exit 0
@@ -184,7 +188,7 @@ exit 0
parse_options() {
flag=`echo $1| cut -d = -f 1`
value=`echo $1| awk 'BEGIN{FS="=";}{print $2}'`
value=`echo $1| $AWK 'BEGIN{FS="=";}{print $2}'`
flag2=`echo $flag|cut -f2- -d -| sed -e 's,-,_,g' -e 's,^_,,g'|tr '[a-z]' '[A-Z]'`
if [ "${TARGET_OS}" = "darwin" ]; then
@@ -200,14 +204,14 @@ case $flag in
show_version ; ;;
-r|--r|--report)
echo "PKGNAME: radare2-extras"
echo "VERSION: 1.0"
echo "VERSION: 4.0.0"
echo "LANGS: c"
echo "OPTIONAL: libewf"
echo "OPTIONAL: libewf libyara"
echo "PKG-CONFIG: r_core libewf unicorn yara"
echo "FLAGS: --with-ostype=auto --without-ewf"
exit 0
;;
--cache-file)
--cache-file)
# ignored: acr have no cache
;;
--build)
@@ -229,6 +233,8 @@ echo "FLAGS: --with-ostype=auto --without-ewf"
SBINDIR="$value"; ;;
--libexecdir)
LIBEXECDIR="$value"; ;;
--docdir)
DOCDIR="$value"; ;;
--datadir)
DATADIR="$value"; ;;
--sysconfdir)
@@ -250,7 +256,7 @@ echo "FLAGS: --with-ostype=auto --without-ewf"
--with-ostype) if [ -z "${value}" ]; then USEROSTYPE="auto"; else USEROSTYPE="${value}" ; fi ;;
"--without-ewf") WANT_EWF="0"; ;;
*) if [ "$value" ]; then eval "`echo $flag2=$value`" ;
*) if [ "$value" ]; then eval "`echo $flag2=$value`" ;
else echo ; echo "WARNING: Unknown flag '$flag'." >&2 ; echo ; fi ;;
esac
}
@@ -267,7 +273,7 @@ parse_options "$1"
shift
done
ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR SYSCONFDIR DATADIR LIBEXECDIR SBINDIR BINDIR EPREFIX PREFIX SPREFIX TARGET HOST BUILD INSTALL INSTALL_LIB INSTALL_MAN INSTALL_PROGRAM INSTALL_PROGRAM_STRIP INSTALL_DIR INSTALL_SCRIPT INSTALL_DATA HOST_OS HOST_CPU BUILD_OS BUILD_CPU TARGET_OS TARGET_CPU PKGNAME VPATH VERSION CONTACT CONTACT_NAME CONTACT_MAIL CC CFLAGS CPPFLAGS LDFLAGS HAVE_LANG_C R2_CFLAGS R2_LDFLAGS HAVE_PKGCFG_R_CORE USEROSTYPE HAVE_LIB_EWF EWF_CFLAGS EWF_LDFLAGS HAVE_PKGCFG_LIBEWF WANT_EWF UC_CFLAGS UC_LDFLAGS HAVE_PKGCFG_UNICORN HAVE_LIB_YARA YARA_CFLAGS YARA_LDFLAGS HAVE_PKGCFG_YARA"
ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR SYSCONFDIR DATADIR DOCDIR LIBEXECDIR SBINDIR BINDIR EPREFIX PREFIX SPREFIX TARGET HOST BUILD INSTALL INSTALL_LIB INSTALL_MAN INSTALL_PROGRAM INSTALL_PROGRAM_STRIP INSTALL_DIR INSTALL_SCRIPT INSTALL_DATA HOST_OS HOST_CPU BUILD_OS BUILD_CPU TARGET_OS TARGET_CPU PKGNAME VPATH VERSION CONTACT CONTACT_NAME CONTACT_MAIL CC CFLAGS CPPFLAGS LDFLAGS HAVE_LANG_C R2_CFLAGS R2_LDFLAGS HAVE_PKGCFG_R_CORE USEROSTYPE HAVE_LIB_EWF EWF_CFLAGS EWF_LDFLAGS HAVE_PKGCFG_LIBEWF WANT_EWF UC_CFLAGS UC_LDFLAGS HAVE_PKGCFG_UNICORN HAVE_LIB_YARA YARA_CFLAGS YARA_LDFLAGS HAVE_PKGCFG_YARA"
create_environ
@@ -282,7 +288,7 @@ echo "checking for working directories... ${WODIS}"
echo "using prefix '${PREFIX}'"
ACR_RMFILES=" test.c a.out a.exe"
:
COMPILER=CC
printf "checking for c compiler... "
HAVE_LANG_C=1
@@ -298,17 +304,19 @@ do_remove
echo "ERROR: ${CC} cannot create executables" >&2 ;
exit 1 ; fi
[ -z "${PKGCONFIG}" ] && PKGCONFIG=pkg-config
type ${PKGCONFIG} > /dev/null 2>&1 || echo "ERROR: Cannot find PKGCONFIG ${PKGCONFIG}"
echo 'Using PKGCONFIG: '${PKGCONFIG}
printf 'checking pkg-config flags for r_core... '
tmp=`${PKGCONFIG} --cflags r_core 2>/dev/null`
if [ $? != 0 ]; then echo no ; HAVE_PKGCFG_R_CORE=0;
if [ $? != 0 ]; then echo no ; HAVE_PKGCFG_R_CORE=0;
R2_CFLAGS='';R2_LDFLAGS='';
echo 'This package is required'
exit 1
else
R2_CFLAGS=$tmp;
else
R2_CFLAGS=$tmp;
tmp=`${PKGCONFIG} --libs r_core 2>/dev/null`
if [ $? = 0 ]; then
echo yes; HAVE_PKGCFG_R_CORE=1;
if [ $? = 0 ]; then
echo yes; HAVE_PKGCFG_R_CORE=1;
R2_LDFLAGS=$tmp; fi; fi
check_library() {
VAR=$1
@@ -324,18 +332,26 @@ if [ $? = 0 ]; then
echo yes
else
eval ${VAR}=0
echo no ; fi }
check_library HAVE_LIB_EWF ewf 0
echo no
if [ "${_REQUIRED}" = 1 ]; then
echo "this library is required."
do_remove
exit 1
fi
fi
}
check_library HAVE_LIB_EWF ewf 0
[ -z "${PKGCONFIG}" ] && PKGCONFIG=pkg-config
echo 'Using PKGCONFIG: '${PKGCONFIG}
printf 'checking pkg-config flags for libewf... '
tmp=`${PKGCONFIG} --cflags libewf 2>/dev/null`
if [ $? != 0 ]; then echo no ; HAVE_PKGCFG_LIBEWF=0;
else
EWF_CFLAGS=$tmp;
if [ $? != 0 ]; then echo no ; HAVE_PKGCFG_LIBEWF=0;
EWF_CFLAGS='';EWF_LDFLAGS='';
else
EWF_CFLAGS=$tmp;
tmp=`${PKGCONFIG} --libs libewf 2>/dev/null`
if [ $? = 0 ]; then
echo yes; HAVE_PKGCFG_LIBEWF=1;
if [ $? = 0 ]; then
echo yes; HAVE_PKGCFG_LIBEWF=1;
EWF_LDFLAGS=$tmp; fi; fi
if [ "$HAVE_PKGCFG_LIBEWF" = "1" ]; then
HAVE_LIB_EWF="1"
@@ -344,33 +360,33 @@ HAVE_LIB_EWF="0"; fi
if [ "$WANT_EWF" = "0" ]; then
HAVE_LIB_EWF="0"; fi
[ -z "${PKGCONFIG}" ] && PKGCONFIG=pkg-config
echo 'Using PKGCONFIG: '${PKGCONFIG}
printf 'checking pkg-config flags for unicorn... '
tmp=`${PKGCONFIG} --cflags unicorn 2>/dev/null`
if [ $? != 0 ]; then echo no ; HAVE_PKGCFG_UNICORN=0;
else
UC_CFLAGS=$tmp;
if [ $? != 0 ]; then echo no ; HAVE_PKGCFG_UNICORN=0;
UC_CFLAGS='';UC_LDFLAGS='';
else
UC_CFLAGS=$tmp;
tmp=`${PKGCONFIG} --libs unicorn 2>/dev/null`
if [ $? = 0 ]; then
echo yes; HAVE_PKGCFG_UNICORN=1;
if [ $? = 0 ]; then
echo yes; HAVE_PKGCFG_UNICORN=1;
UC_LDFLAGS=$tmp; fi; fi
check_library HAVE_LIB_YARA yara 0
check_library HAVE_LIB_YARA yara 0
[ -z "${PKGCONFIG}" ] && PKGCONFIG=pkg-config
echo 'Using PKGCONFIG: '${PKGCONFIG}
printf 'checking pkg-config flags for yara... '
tmp=`${PKGCONFIG} --cflags yara 2>/dev/null`
if [ $? != 0 ]; then echo no ; HAVE_PKGCFG_YARA=0;
else
YARA_CFLAGS=$tmp;
if [ $? != 0 ]; then echo no ; HAVE_PKGCFG_YARA=0;
YARA_CFLAGS='';YARA_LDFLAGS='';
else
YARA_CFLAGS=$tmp;
tmp=`${PKGCONFIG} --libs yara 2>/dev/null`
if [ $? = 0 ]; then
echo yes; HAVE_PKGCFG_YARA=1;
if [ $? = 0 ]; then
echo yes; HAVE_PKGCFG_YARA=1;
YARA_LDFLAGS=$tmp; fi; fi
SEDFLAGS=" -e '"
COUNT=0
for A in ${ENVWORDS} ; do
[ "${A}" = VPATH ] && continue
[ "${A}" = srcdir ] && continue
[ "${A}" = srcdir ] && continue
eval "VAR=\$${A}"
VAR="`echo ${VAR} | sed -e 's/\,/\\\,/g'`"
[ $COUNT = 10 ] && COUNT=0 && SEDFLAGS="${SEDFLAGS}' -e '"
@@ -401,7 +417,7 @@ if [ "$VALUE" = 0 ]; then ## FALSE
MARK="##${A}##"
if [ -n "`grep \"${MARK}\" ${SD_TARGET}.tmp`" ]; then
mv ${SD_TARGET}.tmp ${SD_TARGET}.tmp2
cat ${SD_TARGET}.tmp2 | MARK=$MARK awk 'BEGIN{a=0;}{if($1==ENVIRON["MARK"]){if(a)a=0;else a=1}else{if(!a)print;}}' > ${SD_TARGET}.tmp
cat ${SD_TARGET}.tmp2 | MARK=$MARK $AWK 'BEGIN{a=0;}{if($1==ENVIRON["MARK"]){if(a)a=0;else a=1}else{if(!a)print;}}' > ${SD_TARGET}.tmp
fi
fi
done
+1 -1
View File
@@ -1,5 +1,5 @@
PKGNAME radare2-extras
VERSION 1.0
VERSION 4.0.0
CONTACT pancake ; [email protected]
REPORT PREFIX ;
+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env node
const fs = require('fs');
if (process.argv.length > 2) {
walkTheLines(process.argv[2]);
} else {
console.error('Usage: r2crash.js [crashlog]');
process.exit(1);
}
function walkTheLines(file) {
const lines = fs.readFileSync(file).toString().split('\n');
lines.forEach(walkLine);
}
// global state is bad
var threadId = 0;
var mode = '';
function walkLine(line) {
switch (mode) {
case 'thread-state':
mode = parseThreadState(line);
break;
default:
if (line.startsWith('Crashed Thread')) {
const threadId = +line.substring(20).trim().split(/ /)[0];
console.error("# tid", threadId);
}
break;
}
if (line.startsWith('Thread ') && line.indexOf('Thread State') !== -1) {
mode = 'thread-state';
}
}
function parseThreadState(line) {
if (line.trim() === '') {
return '';
}
const regpairs = line.replace(/: /g,':').replace(/\ \ */g,' ').trim().split(/ /);
for (let rp of regpairs) {
const rv = rp.split(':');
console.log('ar', rv[0], '=', rv[1]);
}
return 'thread-state';
}
+613
View File
@@ -0,0 +1,613 @@
Process: Twitter [46000]
Path: /Applications/Twitter.app/Contents/MacOS/Twitter
Identifier: com.twitter.twitter-mac
Version: 4.3.2 (5002734)
App Item ID: 409789998
App External ID: 821012958
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Twitter [46000]
User ID: 501
Date/Time: 2018-01-28 19:26:40.932 +0100
OS Version: Mac OS X 10.13.2 (17C88)
Report Version: 12
Anonymous UUID: 824E4619-C89D-460F-CA58-EEDCCDFC4890
Sleep/Wake UUID: 312CC193-CFF9-445F-BFE8-FB4128F12753
Time Awake Since Boot: 230000 seconds
Time Since Wake: 2100 seconds
System Integrity Protection: disabled
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Illegal instruction: 4
Termination Reason: Namespace SIGNAL, Code 0x4
Terminating Process: exc handler [0]
Application Specific Information:
Crashing on exception: NSConcreteMutableAttributedString initWithString:: nil value
Application Specific Backtrace 1:
0 CoreFoundation 0x00007fff2dbd100b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fff547afc76 objc_exception_throw + 48
2 CoreFoundation 0x00007fff2dc62c9d +[NSException raise:format:] + 205
3 Foundation 0x00007fff2fc4d9c8 -[NSConcreteMutableAttributedString initWithString:] + 129
4 Twitter 0x000000010f70d3d6 Twitter + 431062
5 Twitter 0x000000010f70c564 Twitter + 427364
6 AppKit 0x00007fff2b9d87c8 _NSViewLayout + 587
7 AppKit 0x00007fff2b1d3323 -[NSView _layoutSubtreeWithOldSize:] + 437
8 AppKit 0x00007fff2b1d359c -[NSView _layoutSubtreeWithOldSize:] + 1070
9 AppKit 0x00007fff2b1d359c -[NSView _layoutSubtreeWithOldSize:] + 1070
10 AppKit 0x00007fff2b1d359c -[NSView _layoutSubtreeWithOldSize:] + 1070
11 AppKit 0x00007fff2b1d359c -[NSView _layoutSubtreeWithOldSize:] + 1070
12 AppKit 0x00007fff2b1d359c -[NSView _layoutSubtreeWithOldSize:] + 1070
13 AppKit 0x00007fff2b1d359c -[NSView _layoutSubtreeWithOldSize:] + 1070
14 AppKit 0x00007fff2b1d359c -[NSView _layoutSubtreeWithOldSize:] + 1070
15 AppKit 0x00007fff2b1d359c -[NSView _layoutSubtreeWithOldSize:] + 1070
16 AppKit 0x00007fff2b9df524 -[NSView _layoutSubtreeIfNeededAndAllowTemporaryEngine:] + 1380
17 AppKit 0x00007fff2b26e480 -[NSView _sendViewWillDrawInRect:clipRootView:] + 47
18 AppKit 0x00007fff2b26d301 -[NSView displayIfNeeded] + 1142
19 AppKit 0x00007fff2b3cfbb1 -[NSProgressIndicator startAnimation:] + 246
20 AppKit 0x00007fff2b3cfce1 -[NSProgressIndicator viewDidUnhide] + 169
21 AppKit 0x00007fff2b1ebc59 -[NSView _recursiveLostHiddenAncestor] + 127
i2 AppKit 0x00007fff2b1ebd0e -[NSView _recursiveLostHiddenAncestor] + 308
23 AppKit 0x00007fff2b1ebd0e -[NSView _recursiveLostHiddenAncestor] + 308
24 AppKit 0x00007fff2b164aa1 -[NSView(NSInternal) _setHidden:setNeedsDisplay:] + 326
25 AppKit 0x00007fff2b2c9b6c -[NSView prepareForReuse] + 55
26 AppKit 0x00007fff2b30ac0c -[NSTableRowView prepareForReuse] + 70
27 Foundation 0x00007fff2fc5f33a -[NSISEngine withBehaviors:performModifications:] + 131
28 AppKit 0x00007fff2b10e5a1 -[NSView(NSConstraintBasedLayout) _withAutomaticEngineOptimizationDisabled:] + 70
29 AppKit 0x00007fff2b300236 -[NSTableRowData _prepareViewForReuse:] + 81
30 AppKit 0x00007fff2b231fd1 -[NSTableRowData makeViewWithIdentifier:owner:] + 312
31 AppKit 0x00007fff2b231e70 -[NSTableView makeViewWithIdentifier:owner:] + 58
32 Twitter 0x000000010f891959 Twitter + 2021721
33 Twitter 0x000000010f835012 Twitter + 1642514
34 AppKit 0x00007fff2b2ba8da -[NSTableView(NSTableViewViewBased) _delegateRowViewForRow:] + 64
35 AppKit 0x00007fff2b2313e9 -[NSTableView(NSTableViewViewBased) makeRowViewForRow:] + 121
36 AppKit 0x00007fff2bb1e59e -[NSTableRowData _preparedRowViewForRow:storageHandler:] + 118
37 AppKit 0x00007fff2b2312e5 -[NSTableRowData _addRowViewForVisibleRow:withPriorView:] + 392
38 AppKit 0x00007fff2b2310a8 -[NSTableRowData _addRowViewForVisibleRow:withPriorRowIndex:inDictionary:withRowAnimation:] + 416
39 AppKit 0x00007fff2bb20741 -[NSTableRowData _updateVisibleRowEntries] + 1720
40 AppKit 0x00007fff2b22fda6 -[NSTableRowData updateVisibleRowViews] + 294
41 AppKit 0x00007fff2b3d924e -[NSTableRowData prepareContentInRect:] + 106
42 AppKit 0x00007fff2b3d8d46 -[NSTableView prepareContentInRect:] + 303
43 AppKit 0x00007fff2b9d9519 -[NSView _updateSuggestedContentRectToValue:] + 616
44 AppKit 0x00007fff2b32268c -[NSView _updateSuggestedContentRect] + 100
45 AppKit 0x00007fff2b36c40e -[NSView _updateSuggestedContentRectForVisibleRectChange] + 219
46 AppKit 0x00007fff2b24478b -[NSScrollView(NSRulerSupport) _handleBoundsChangeForSubview:] + 364
47 AppKit 0x00007fff2b206ca7 -[NSView _postBoundsChangeNotification] + 60
48 AppKit 0x00007fff2b206c00 -[NSView translateOriginToPoint:] + 261
49 AppKit 0x00007fff2b20679b -[NSClipView _immediateScrollToPoint:] + 536
50 AppKit 0x00007fff2b2064bf -[NSClipView scrollToPoint:] + 232
51 AppKit 0x00007fff2b241f8f -[NSScrollView scrollClipView:toPoint:] + 75
52 AppKit 0x00007fff2b1ecd49 -[NSClipView _scrollTo:animateScroll:flashScrollerKnobs:] + 1273
53 AppKit 0x00007fff2b40d149 -[NSScrollView _doScroller:hitPart:multiplier:] + 1323
54 AppKit 0x00007fff2b8c575a -[NSApplication(NSResponder) sendAction:to:from:] + 312
55 AppKit 0x00007fff2b36b933 -[NSControl sendAction:to:] + 86
56 AppKit 0x00007fff2b40cb80 -[NSScroller sendAction:to:] + 91
57 AppKit 0x00007fff2b40c995 -[NSScroller(NSScrollerPrivate) _scrollByDelta:] + 842
58 AppKit 0x00007fff2b40bd4b -[NSScrollingBehaviorLegacy _scrollView:smoothScrollWithEvent:] + 2746
59 AppKit 0x00007fff2b40ae16 -[NSScrollingBehaviorLegacy scrollView:scrollWheelWithEvent:] + 1177
60 Twitter 0x000000010f7c7e59 Twitter + 1195609
61 AppKit 0x00007fff2b40eee5 __71-[NSScrollingBehaviorLegacy _latchAcceleratedScrollEventsToScrollView:]_block_invoke + 282
62 AppKit 0x00007fff2b298366 _NSSendEventToObservers + 337
63 AppKit 0x00007fff2b8c152a -[NSApplication(NSEvent) sendEvent:] + 70
64 AppKit 0x00007fff2b122d9d -[NSApplication run] + 812
65 AppKit 0x00007fff2b0f1f1a NSApplicationMain + 804
66 libdyld.dylib 0x00007fff5539f115 start + 1
67 ??? 0x0000000000000001 0x0 + 1
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 com.apple.AppKit 0x00007fff2b458794 -[NSApplication _crashOnException:] + 109
1 com.apple.AppKit 0x00007fff2b45867c -[NSApplication reportException:] + 953
2 com.twitter.twitter-mac 0x000000010f9205fd 0x10f6a4000 + 2606589
3 com.apple.AppKit 0x00007fff2b122e2e -[NSApplication run] + 957
4 com.apple.AppKit 0x00007fff2b0f1f1a NSApplicationMain + 804
5 libdyld.dylib 0x00007fff5539f115 start + 1
Thread 1:: com.twitter.crashlytics.mac.MachExceptionServer
0 libsystem_kernel.dylib 0x00007fff554f09d2 write + 10
1 com.twitter.twitter-mac 0x000000010f91f68a 0x10f6a4000 + 2602634
2 com.twitter.twitter-mac 0x000000010f90ea54 0x10f6a4000 + 2533972
3 libsystem_pthread.dylib 0x00007fff5562a6c1 _pthread_body + 340
4 libsystem_pthread.dylib 0x00007fff5562a56d _pthread_start + 377
5 libsystem_pthread.dylib 0x00007fff55629c5d thread_start + 13
Thread 2:: com.apple.NSEventThread
0 libsystem_kernel.dylib 0x00007fff554e57c2 mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff554e4cdc mach_msg + 60
2 com.apple.CoreFoundation 0x00007fff2db4c355 __CFRunLoopServiceMachPort + 341
3 com.apple.CoreFoundation 0x00007fff2db4b6a7 __CFRunLoopRun + 1783
4 com.apple.CoreFoundation 0x00007fff2db4ad23 CFRunLoopRunSpecific + 483
5 com.apple.AppKit 0x00007fff2b26b3c8 _NSEventThread + 184
6 libsystem_pthread.dylib 0x00007fff5562a6c1 _pthread_body + 340
7 libsystem_pthread.dylib 0x00007fff5562a56d _pthread_start + 377
8 libsystem_pthread.dylib 0x00007fff55629c5d thread_start + 13
Thread 3:: com.apple.NSURLConnectionLoader
0 libsystem_kernel.dylib 0x00007fff554e57c2 mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff554e4cdc mach_msg + 60
2 com.apple.CoreFoundation 0x00007fff2db4c355 __CFRunLoopServiceMachPort + 341
3 com.apple.CoreFoundation 0x00007fff2db4b6a7 __CFRunLoopRun + 1783
4 com.apple.CoreFoundation 0x00007fff2db4ad23 CFRunLoopRunSpecific + 483
5 com.apple.CFNetwork 0x00007fff2ccc3f84 -[__CoreSchedulingSetRunnable runForever] + 722
6 com.apple.Foundation 0x00007fff2fc38e48 __NSThread__start__ + 1197
7 libsystem_pthread.dylib 0x00007fff5562a6c1 _pthread_body + 340
8 libsystem_pthread.dylib 0x00007fff5562a56d _pthread_start + 377
9 libsystem_pthread.dylib 0x00007fff55629c5d thread_start + 13
Thread 4:: com.apple.coreaudio.AQClient
0 libsystem_kernel.dylib 0x00007fff554e57c2 mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff554e4cdc mach_msg + 60
2 com.apple.CoreFoundation 0x00007fff2db4c355 __CFRunLoopServiceMachPort + 341
3 com.apple.CoreFoundation 0x00007fff2db4b6a7 __CFRunLoopRun + 1783
4 com.apple.CoreFoundation 0x00007fff2db4ad23 CFRunLoopRunSpecific + 483
5 com.apple.audio.toolbox.AudioToolbox 0x00007fff2c4f61aa GenericRunLoopThread::Entry(void*) + 158
6 com.apple.audio.toolbox.AudioToolbox 0x00007fff2c4f5eb9 CAPThread::Entry(CAPThread*) + 77
7 libsystem_pthread.dylib 0x00007fff5562a6c1 _pthread_body + 340
8 libsystem_pthread.dylib 0x00007fff5562a56d _pthread_start + 377
9 libsystem_pthread.dylib 0x00007fff55629c5d thread_start + 13
Thread 5:
0 libsystem_kernel.dylib 0x00007fff554ef562 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff5562a06a _pthread_wqthread + 1035
2 libsystem_pthread.dylib 0x00007fff55629c4d start_wqthread + 13
Thread 6:
0 libsystem_kernel.dylib 0x00007fff554ef562 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff5562a26f _pthread_wqthread + 1552
2 libsystem_pthread.dylib 0x00007fff55629c4d start_wqthread + 13
Thread 7:
0 libsystem_kernel.dylib 0x00007fff554ef562 __workq_kernreturn + 10
1 libsystem_pthread.dylib 0x00007fff5562a06a _pthread_wqthread + 1035
2 libsystem_pthread.dylib 0x00007fff55629c4d start_wqthread + 13
Thread 8:: Dispatch queue: com.apple.CFNetwork.Connection
0 libsystem_blocks.dylib 0x00007fff553ed991 _Block_release + 99
1 libdispatch.dylib 0x00007fff55365d50 _dispatch_client_callout + 8
2 libdispatch.dylib 0x00007fff5537a20c _dispatch_queue_serial_drain + 635
3 libdispatch.dylib 0x00007fff5536d0fd _dispatch_queue_invoke + 373
4 libdispatch.dylib 0x00007fff5537a06f _dispatch_queue_serial_drain + 222
5 libdispatch.dylib 0x00007fff5536d0fd _dispatch_queue_invoke + 373
6 libdispatch.dylib 0x00007fff5537af02 _dispatch_root_queue_drain_deferred_wlh + 332
7 libdispatch.dylib 0x00007fff5537ed16 _dispatch_workloop_worker_thread + 880
8 libsystem_pthread.dylib 0x00007fff5562a033 _pthread_wqthread + 980
9 libsystem_pthread.dylib 0x00007fff55629c4d start_wqthread + 13
Thread 9:
0 libsystem_pthread.dylib 0x00007fff55629c40 start_wqthread + 0
1 ??? 0xa8fafa6ba58200f2 0 + 12176319882794762482
Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x00007fe8a52f2200 rbx: 0x0000600002e42c40 rcx: 0x0000000000000000 rdx: 0x0000000000001bbb
rdi: 0x0000000008000101 rsi: 0x00007fe8a54dd5a1 rbp: 0x00007ffee055b910 rsp: 0x00007ffee055b900
r8: 0x0000000000000000 r9: 0x0000000000000000 r10: 0x00007ffee055b408 r11: 0xffffffffffe167ff
r12: 0x00007ffee055b910 r13: 0x0000600000126180 r14: 0x00007fff547a1e80 r15: 0x00007ffee055b920
rip: 0x00007fff2b458794 rfl: 0x0000000000010206 cr2: 0x000070000ac9a628
Logical CPU: 2
Error Code: 0x00000000
Trap Number: 6
Binary Images:
0x10f6a4000 - 0x10fac2ff7 +com.twitter.twitter-mac (4.3.2 - 5002734) <3BC0BF69-D205-3845-9A00-492B8F015F12> /Applications/Twitter.app/Contents/MacOS/Twitter
0x10fbec000 - 0x10fc48ff7 +com.growl.growlframework (2.0.1 - 2.0.1) <6C20B93B-75B2-30A4-8267-8C81BF90872B> /Applications/Twitter.app/Contents/Frameworks/Growl.framework/Versions/A/Growl
0x113705000 - 0x113709fff com.apple.audio.AppleHDAHALPlugIn (280.12 - 280.12) <9ACA0127-E687-3885-9475-1D5E4DD83168> /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn
0x113b49000 - 0x114083ff7 com.apple.driver.AppleIntelBDWGraphicsGLDriver (10.30.12 - 10.3.0) <E227A086-C662-335C-8B36-EA875AD6478F> /System/Library/Extensions/AppleIntelBDWGraphicsGLDriver.bundle/Contents/MacOS/AppleIntelBDWGraphicsGLDriver
0x11796a000 - 0x1179b498f dyld (519.2.2) <6695F30B-4E88-3C0B-9867-7D738C44A3E6> /usr/lib/dyld
0x124585000 - 0x124af0fff com.apple.audio.codecs.Components (7.0 - 7.0) <7233F241-5DC2-38E5-9156-2D825117075B> /System/Library/Components/AudioCodecs.component/Contents/MacOS/AudioCodecs
0x124bfe000 - 0x124da4ff7 com.apple.audio.units.Components (1.14 - 1.14) <5AE65A6C-EF2F-37AC-9DDD-4ABB69E78EF2> /System/Library/Components/CoreAudio.component/Contents/MacOS/CoreAudio
0x7fff261ee000 - 0x7fff2653cff7 com.apple.RawCamera.bundle (8.02.0 - 1017.2.2) <C799730B-C745-3775-BCE7-C67B8BD97FDB> /System/Library/CoreServices/RawCamera.bundle/Contents/MacOS/RawCamera
0x7fff2781a000 - 0x7fff278a6ff7 com.apple.driver.AppleIntelBDWGraphicsMTLDriver (10.30.12 - 10.3.0) <7A1AD3EA-2D09-381F-A080-CC108AE459DB> /System/Library/Extensions/AppleIntelBDWGraphicsMTLDriver.bundle/Contents/MacOS/AppleIntelBDWGraphicsMTLDriver
0x7fff29d11000 - 0x7fff29eecff7 com.apple.avfoundation (2.0 - 1528.24) <E4CE97EA-94C7-3CC4-B768-15AA25E76A83> /System/Library/Frameworks/AVFoundation.framework/Versions/A/AVFoundation
0x7fff29eed000 - 0x7fff29fa7ff7 com.apple.audio.AVFAudio (1.0 - ???) <E7DFCDAF-97A8-314F-BBED-76B9C5041E38> /System/Library/Frameworks/AVFoundation.framework/Versions/A/Frameworks/AVFAudio.framework/Versions/A/AVFAudio
0x7fff29fa9000 - 0x7fff2a0acff3 com.apple.AVKit (1.1 - 440.5.1) <11682387-4506-3294-8355-6130128A0C68> /System/Library/Frameworks/AVKit.framework/Versions/A/AVKit
0x7fff2a0ad000 - 0x7fff2a0adfff com.apple.Accelerate (1.11 - Accelerate 1.11) <5AA750F5-D633-32BA-B7F3-4F651FB1761E> /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate
0x7fff2a0ae000 - 0x7fff2a0c4fe3 libCGInterfaces.dylib (417) <27E09D39-51B5-3297-BE33-0DB1736B833A> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vImage.framework/Versions/A/Libraries/libCGInterfaces.dylib
0x7fff2a0c5000 - 0x7fff2a5c3fc3 com.apple.vImage (8.1 - ???) <310976EE-E12D-39D7-8F58-6EE924E08576> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vImage.framework/Versions/A/vImage
0x7fff2a5c4000 - 0x7fff2a71efcb libBLAS.dylib (1211.30.1) <0DB0D952-BCF4-3479-BA2F-785FB1A57479> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
0x7fff2a71f000 - 0x7fff2a74dfef libBNNS.dylib (37) <49EB4DBA-877C-3D41-90A2-C3D982C72A54> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBNNS.dylib
0x7fff2a74e000 - 0x7fff2ab0eff7 libLAPACK.dylib (1211.30.1) <2D4E4446-6B63-350C-BD68-A1B8FBE99539> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib
0x7fff2ab0f000 - 0x7fff2ab24ff7 libLinearAlgebra.dylib (1211.30.1) <6C68F41D-1398-3AFE-BE72-C0ECA1B24BDC> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLinearAlgebra.dylib
0x7fff2ab25000 - 0x7fff2ab2aff3 libQuadrature.dylib (3) <3D6BF66A-55B2-3692-BAC7-DEB0C676ED29> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libQuadrature.dylib
0x7fff2ab2b000 - 0x7fff2ab89fff libSparse.dylib (79.1.1) <7AD0F8A8-FD36-36FE-B83D-58648EBD0027> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libSparse.dylib
0x7fff2ab8a000 - 0x7fff2ab9dfff libSparseBLAS.dylib (1211.30.1) <42506F6F-0F38-322E-9903-C1DB66E4DA05> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libSparseBLAS.dylib
0x7fff2ab9e000 - 0x7fff2ad4afc3 libvDSP.dylib (622.20.8) <6FFCA52B-7D60-326A-ADF2-601F39A8685A> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvDSP.dylib
0x7fff2ad4b000 - 0x7fff2adfbfef libvMisc.dylib (622.20.8) <54F90047-879F-3260-8604-6E453149B49E> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvMisc.dylib
0x7fff2adfc000 - 0x7fff2adfcfff com.apple.Accelerate.vecLib (3.11 - vecLib 3.11) <8A96A8ED-7B88-3D17-8D17-41D224E0EC90> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/vecLib
0x7fff2adfd000 - 0x7fff2ae54ff7 com.apple.Accounts (113 - 113) <02AC0AF3-D620-340E-BE52-CD31119F9CD8> /System/Library/Frameworks/Accounts.framework/Versions/A/Accounts
0x7fff2ae55000 - 0x7fff2b0ebfff com.apple.AddressBook.framework (11.0 - 1808.6) <F6D3B5FE-46C5-31E6-8D30-2DE805D883AA> /System/Library/Frameworks/AddressBook.framework/Versions/A/AddressBook
0x7fff2b0ec000 - 0x7fff2bf49fff com.apple.AppKit (6.9 - 1561.20.106) <7A71ACCF-2DF5-3557-BB22-3A9FC9F71CCF> /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
0x7fff2bf9b000 - 0x7fff2bf9bfff com.apple.ApplicationServices (48 - 50) <7627DBD6-497B-3AB7-9B63-F0532EDF09B8> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
0x7fff2bf9c000 - 0x7fff2c002fff com.apple.ApplicationServices.ATS (377 - 445) <CDF5F6D7-4E7D-3D28-9FBA-1B53AD9FA8F8> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/ATS
0x7fff2c09b000 - 0x7fff2c1bdfff libFontParser.dylib (222.1.2) <11BD5EEF-AF18-33FB-B114-DD611932E822> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources/libFontParser.dylib
0x7fff2c1be000 - 0x7fff2c208ff7 libFontRegistry.dylib (221) <A22F82C0-B4FE-3DB5-B968-79B28257DF2F> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources/libFontRegistry.dylib
0x7fff2c2ad000 - 0x7fff2c2e0ff7 libTrueTypeScaler.dylib (222.1.2) <33C245B4-E1AD-3C89-B735-5A5610E547C8> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources/libTrueTypeScaler.dylib
0x7fff2c34a000 - 0x7fff2c34eff3 com.apple.ColorSyncLegacy (4.13.0 - 1) <42C25E85-1CF3-3DEC-A434-BE69F68F4318> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ColorSyncLegacy.framework/Versions/A/ColorSyncLegacy
0x7fff2c3ee000 - 0x7fff2c440ff7 com.apple.HIServices (1.22 - 622) <2E83CD6F-ED98-3C29-BD0A-8525E38AB5DB> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices
0x7fff2c441000 - 0x7fff2c44ffff com.apple.LangAnalysis (1.7.0 - 1.7.0) <71A9C815-AC55-3E36-A618-F6778F5119AD> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LangAnalysis.framework/Versions/A/LangAnalysis
0x7fff2c450000 - 0x7fff2c49cfff com.apple.print.framework.PrintCore (13 - 503) <A69E2BAD-2B66-38CC-9D3A-0A0EBC41341D> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/PrintCore
0x7fff2c49d000 - 0x7fff2c4d7fff com.apple.QD (3.12 - 403) <38D8106A-4FFA-3FE9-9999-714CADD7EE9C> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/QD.framework/Versions/A/QD
0x7fff2c4d8000 - 0x7fff2c4e4fff com.apple.speech.synthesis.framework (7.2.1 - 7.2.1) <BA7EDC49-E216-3D96-A7B7-8C76B862D484> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynthesis.framework/Versions/A/SpeechSynthesis
0x7fff2c4e5000 - 0x7fff2c770ff7 com.apple.audio.toolbox.AudioToolbox (1.14 - 1.14) <71699B6E-8B94-39E2-801F-8467C2B5B621> /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox
0x7fff2c772000 - 0x7fff2c772fff com.apple.audio.units.AudioUnit (1.14 - 1.14) <28C7FC0C-D2E5-3703-916F-866A0F823229> /System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit
0x7fff2ca87000 - 0x7fff2ce19fff com.apple.CFNetwork (893.13.1 - 893.13.1) <567231F4-4080-3B2D-8349-9177BD358804> /System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork
0x7fff2ce2e000 - 0x7fff2ce2efff com.apple.Carbon (158 - 158) <FCD7A9FF-5E53-3B0C-8A52-691C11B2A0C5> /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
0x7fff2ce2f000 - 0x7fff2ce32ffb com.apple.CommonPanels (1.2.6 - 98) <39C8EBA3-EEB2-335B-8A88-D6C64BAA112F> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CommonPanels.framework/Versions/A/CommonPanels
0x7fff2ce33000 - 0x7fff2d138ff7 com.apple.HIToolbox (2.1.1 - 910.4) <ADBE7A1B-0402-369C-A6F3-494E8CACD619> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox
0x7fff2d139000 - 0x7fff2d13cffb com.apple.help (1.3.8 - 64) <18D02016-119A-33E8-AEB0-E9466BA4AD56> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Help.framework/Versions/A/Help
0x7fff2d13d000 - 0x7fff2d142fff com.apple.ImageCapture (9.0 - 9.0) <2DE590E5-DF0E-3962-A2BE-06EBC79B3D72> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/ImageCapture.framework/Versions/A/ImageCapture
0x7fff2d143000 - 0x7fff2d1d8ffb com.apple.ink.framework (10.9 - 220) <D8AECAE3-9FD2-32E3-B659-026F33650BB2> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Ink.framework/Versions/A/Ink
0x7fff2d1d9000 - 0x7fff2d1f3ff7 com.apple.openscripting (1.7 - 174) <66899B51-ADFD-360D-88E9-B52439F531B4> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/OpenScripting.framework/Versions/A/OpenScripting
0x7fff2d214000 - 0x7fff2d215fff com.apple.print.framework.Print (12 - 267) <E4CBAAFC-9045-38AC-9F93-8C931DDED9D8> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Print.framework/Versions/A/Print
0x7fff2d216000 - 0x7fff2d218ff7 com.apple.securityhi (9.0 - 55006) <E7668200-B4CB-3612-96B8-D57E94077787> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SecurityHI.framework/Versions/A/SecurityHI
0x7fff2d219000 - 0x7fff2d21ffff com.apple.speech.recognition.framework (6.0.3 - 6.0.3) <1F10ED1F-12C7-39AC-88A0-43A1338F9316> /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SpeechRecognition.framework/Versions/A/SpeechRecognition
0x7fff2d32c000 - 0x7fff2d32cfff com.apple.Cocoa (6.11 - 22) <F1AED1E8-ACC2-31F0-B85E-17E41167FC88> /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa
0x7fff2d33a000 - 0x7fff2d3f3ff7 com.apple.ColorSync (4.13.0 - 546) <A5E013D9-7305-3026-879E-4D1F038A430D> /System/Library/Frameworks/ColorSync.framework/Versions/A/ColorSync
0x7fff2d580000 - 0x7fff2d613ff7 com.apple.audio.CoreAudio (4.3.0 - 4.3.0) <4DE794D4-F018-31E8-B3CE-CF8DBE68D14E> /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio
0x7fff2d67a000 - 0x7fff2d6a3ffb com.apple.CoreBluetooth (1.0 - 1) <942F88A5-AD68-3359-90D5-6F1A3311C51A> /System/Library/Frameworks/CoreBluetooth.framework/Versions/A/CoreBluetooth
0x7fff2d6a4000 - 0x7fff2d9f8fe7 com.apple.CoreData (120 - 849.2) <4407C44B-34CC-3D23-AEDF-AD866D414EBF> /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
0x7fff2d9f9000 - 0x7fff2dac5fff com.apple.CoreDisplay (1.0 - 81.7) <CE6B9237-B33D-3D8F-8C1C-4F57BD810D24> /System/Library/Frameworks/CoreDisplay.framework/Versions/A/CoreDisplay
0x7fff2dac6000 - 0x7fff2df66fff com.apple.CoreFoundation (6.9 - 1450.16) <23F8373A-FA3F-37A2-BA5B-70061BFCCD21> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
0x7fff2df68000 - 0x7fff2e575fef com.apple.CoreGraphics (2.0 - 1129.5) <F37BFBD2-CC21-3521-B034-9D4D36197487> /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics
0x7fff2e577000 - 0x7fff2e866fff com.apple.CoreImage (13.0.0 - 579.2.9) <B5661FF7-7558-308E-A3B7-C280F7A1DA78> /System/Library/Frameworks/CoreImage.framework/Versions/A/CoreImage
0x7fff2e867000 - 0x7fff2e8d2ff7 com.apple.corelocation (2237.0.22) <0E78BBE7-9016-3A12-88EB-425EFE69E643> /System/Library/Frameworks/CoreLocation.framework/Versions/A/CoreLocation
0x7fff2eaf5000 - 0x7fff2ebd5ff7 com.apple.CoreMedia (1.0 - 2267.40.5) <AE634D2B-FEB5-3669-80CC-F1C238698D44> /System/Library/Frameworks/CoreMedia.framework/Versions/A/CoreMedia
0x7fff2ebd6000 - 0x7fff2ec24fff com.apple.CoreMediaIO (812.0 - 4993) <1D78D2AE-626B-3D0C-83EA-EA385682F3F3> /System/Library/Frameworks/CoreMediaIO.framework/Versions/A/CoreMediaIO
0x7fff2ec25000 - 0x7fff2ec25fff com.apple.CoreServices (822.19 - 822.19) <0C60B639-4CC4-3F57-BC5E-DB71EB75F7F4> /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
0x7fff2ec26000 - 0x7fff2ec9affb com.apple.AE (735.1 - 735.1) <D0C73200-90A7-3FD1-A6EC-97055AA367E2> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/AE
0x7fff2ec9b000 - 0x7fff2ef72ff7 com.apple.CoreServices.CarbonCore (1178.2 - 1178.2) <A1FE74F8-953B-371E-A8AC-E87B30FB79C6> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore
0x7fff2ef73000 - 0x7fff2efa7ff7 com.apple.DictionaryServices (1.2 - 284) <3FCEE280-8DD0-37C9-BFD4-7BA87AAFC8EF> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/DictionaryServices.framework/Versions/A/DictionaryServices
0x7fff2efa8000 - 0x7fff2efb0ff3 com.apple.CoreServices.FSEvents (1239 - 1239) <7BBC5CB7-DBC8-316B-99B0-781827159A2F> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/FSEvents.framework/Versions/A/FSEvents
0x7fff2efb1000 - 0x7fff2f169ff7 com.apple.LaunchServices (822.19 - 822.19) <F3AC96C3-0B52-3AA9-9DA8-288BBC523C07> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices
0x7fff2f16a000 - 0x7fff2f219ff7 com.apple.Metadata (10.7.0 - 1191.2.6) <FB66B298-D55D-398A-BEDB-CB7B82956AE5> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Metadata
0x7fff2f21a000 - 0x7fff2f277ff7 com.apple.CoreServices.OSServices (822.19 - 822.19) <408FB1A4-58E9-34D4-8022-A9EEC8502762> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices
0x7fff2f278000 - 0x7fff2f2e6fff com.apple.SearchKit (1.4.0 - 1.4.0) <14053F88-2C76-35CA-9FC1-2A9BC0B63F88> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SearchKit.framework/Versions/A/SearchKit
0x7fff2f2e7000 - 0x7fff2f30bffb com.apple.coreservices.SharedFileList (71.4 - 71.4) <4AA6DCF5-BAF8-36FA-A8B0-EDF518EFEF14> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SharedFileList.framework/Versions/A/SharedFileList
0x7fff2f5b5000 - 0x7fff2f703ffb com.apple.CoreText (352.0 - 578.12) <DA0BC559-277A-32BA-91EA-FD2F02EA186F> /System/Library/Frameworks/CoreText.framework/Versions/A/CoreText
0x7fff2f704000 - 0x7fff2f73eff3 com.apple.CoreVideo (1.8 - 279.2) <A8FC5325-D092-3A28-A1CF-5C94B8101F71> /System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo
0x7fff2f73f000 - 0x7fff2f7c9ffb com.apple.framework.CoreWLAN (13.0 - 1339) <FFA24EBB-75A1-3B33-9B26-96BDAF758CC0> /System/Library/Frameworks/CoreWLAN.framework/Versions/A/CoreWLAN
0x7fff2f957000 - 0x7fff2f962ff7 com.apple.DirectoryService.Framework (10.13 - 207) <79F272D7-48AE-3D1E-AC5B-3CEB5F16E7D5> /System/Library/Frameworks/DirectoryService.framework/Versions/A/DirectoryService
0x7fff2f963000 - 0x7fff2fa1dfff com.apple.DiscRecording (9.0.3 - 9030.4.5) <2094BAC4-4F37-3741-B9BD-60158A63C503> /System/Library/Frameworks/DiscRecording.framework/Versions/A/DiscRecording
0x7fff2fa44000 - 0x7fff2fa49fff com.apple.DiskArbitration (2.7 - 2.7) <44836CE9-A9ED-3017-972A-7A0A3D6B472B> /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration
0x7fff2fc0a000 - 0x7fff2ffcffff com.apple.Foundation (6.9 - 1450.16) <7FEC6610-70EA-3A8D-8EC4-7E99BAF1E312> /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
0x7fff3003f000 - 0x7fff3006ffff com.apple.GSS (4.0 - 2.0) <3B4B4509-B5A3-396B-9C71-80BAE84476FA> /System/Library/Frameworks/GSS.framework/Versions/A/GSS
0x7fff30181000 - 0x7fff30284ff3 com.apple.Bluetooth (6.0.2 - 6.0.2f2) <AFC4A40B-AE56-3C53-A2B1-D0D9C335E21D> /System/Library/Frameworks/IOBluetooth.framework/Versions/A/IOBluetooth
0x7fff302e4000 - 0x7fff3037ffff com.apple.framework.IOKit (2.0.2 - 1445.31.1) <7556086A-EFAF-3262-9822-6F666CFC6655> /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
0x7fff30381000 - 0x7fff30388ffb com.apple.IOSurface (209.2.2 - 209.2.2) <6D35A601-1C47-37BE-AD31-F8EB88F67573> /System/Library/Frameworks/IOSurface.framework/Versions/A/IOSurface
0x7fff30389000 - 0x7fff303deff3 com.apple.ImageCaptureCore (7.0 - 7.0) <CBE349D4-2C8B-31F5-B5ED-B8E978DA9245> /System/Library/Frameworks/ImageCaptureCore.framework/Versions/A/ImageCaptureCore
0x7fff303df000 - 0x7fff30556ff7 com.apple.ImageIO.framework (3.3.0 - 1713) <DB207AD2-06B5-3065-976B-F53C477D79C0> /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
0x7fff30557000 - 0x7fff3055bffb libGIF.dylib (1713) <C65B2846-1B94-3BB3-BBBF-5A9E5054CE1E> /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libGIF.dylib
0x7fff3055c000 - 0x7fff30643fff libJP2.dylib (1713) <8323253E-278A-3486-801A-83E143C19712> /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJP2.dylib
0x7fff30644000 - 0x7fff30667ff7 libJPEG.dylib (1713) <2D846A18-D8AF-3573-803B-BEABCBAC38D1> /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib
0x7fff30943000 - 0x7fff30969feb libPng.dylib (1713) <546F41CE-185C-31A0-B61C-1012AA932624> /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libPng.dylib
0x7fff3096a000 - 0x7fff3096cffb libRadiance.dylib (1713) <31787C46-4A2B-3CDF-95E9-EC1BD4794917> /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libRadiance.dylib
0x7fff3096d000 - 0x7fff309bafeb libTIFF.dylib (1713) <5319B2E1-83D2-30C7-A7BC-A0CE0B07885D> /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib
0x7fff30b76000 - 0x7fff316dcff7 com.apple.JavaScriptCore (13604 - 13604.4.7.1.3) <3ACE94F3-B9B6-38FD-9CE7-7B44F374C143> /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/JavaScriptCore
0x7fff316f4000 - 0x7fff3170dff7 com.apple.Kerberos (3.0 - 1) <CAF075C0-4C24-3ACE-9AE6-77BEFDEA3622> /System/Library/Frameworks/Kerberos.framework/Versions/A/Kerberos
0x7fff3170e000 - 0x7fff31743fff com.apple.LDAPFramework (2.4.28 - 194.5) <8419BDB5-12DF-3BC9-871D-7A270E080249> /System/Library/Frameworks/LDAP.framework/Versions/A/LDAP
0x7fff319c5000 - 0x7fff319ccfff com.apple.MediaAccessibility (1.0 - 114) <D72C593A-AC32-3419-AB86-6B07217EBFD5> /System/Library/Frameworks/MediaAccessibility.framework/Versions/A/MediaAccessibility
0x7fff319e2000 - 0x7fff31a6effb com.apple.MediaPlayer (1.0 - 1.0) <76758A48-DB40-3331-8517-07D9A445836D> /System/Library/Frameworks/MediaPlayer.framework/Versions/A/MediaPlayer
0x7fff31a6f000 - 0x7fff32088ff7 com.apple.MediaToolbox (1.0 - 2267.40.5) <BC84C8E1-FC56-3996-9110-E1BEF85587F7> /System/Library/Frameworks/MediaToolbox.framework/Versions/A/MediaToolbox
0x7fff3208a000 - 0x7fff32109fff com.apple.Metal (124.7 - 124.7) <C266564D-21B5-3FD9-92D5-03974F3186C4> /System/Library/Frameworks/Metal.framework/Versions/A/Metal
0x7fff32126000 - 0x7fff3213bfff com.apple.MetalPerformanceShaders.MPSCore (1.0 - 1) <D4BCBA84-AD1B-33DC-99F3-16F9E5E50906> /System/Library/Frameworks/MetalPerformanceShaders.framework/Frameworks/MPSCore.framework/Versions/A/MPSCore
0x7fff3213c000 - 0x7fff321a7fef com.apple.MetalPerformanceShaders.MPSImage (1.0 - 1) <E504EC97-FAD7-36DC-B151-6F89AB911E3A> /System/Library/Frameworks/MetalPerformanceShaders.framework/Frameworks/MPSImage.framework/Versions/A/MPSImage
0x7fff321a8000 - 0x7fff321cbfff com.apple.MetalPerformanceShaders.MPSMatrix (1.0 - 1) <A5B6F6FC-A19A-32C0-A999-98B6688760C7> /System/Library/Frameworks/MetalPerformanceShaders.framework/Frameworks/MPSMatrix.framework/Versions/A/MPSMatrix
0x7fff321cc000 - 0x7fff3224cff7 com.apple.MetalPerformanceShaders.MPSNeuralNetwork (1.0 - 1) <D0D8F13F-ACD4-3B61-BE54-121CCB05ECF4> /System/Library/Frameworks/MetalPerformanceShaders.framework/Frameworks/MPSNeuralNetwork.framework/Versions/A/MPSNeuralNetwork
0x7fff3224d000 - 0x7fff3224dff7 com.apple.MetalPerformanceShaders.MetalPerformanceShaders (1.0 - 1) <2E8723FC-AA53-3596-B6A4-220A378B7A5A> /System/Library/Frameworks/MetalPerformanceShaders.framework/Versions/A/MetalPerformanceShaders
0x7fff33256000 - 0x7fff33262ffb com.apple.NetFS (6.0 - 4.0) <81B22AE7-7094-30F2-BF41-84CA05EDB95B> /System/Library/Frameworks/NetFS.framework/Versions/A/NetFS
0x7fff333e2000 - 0x7fff33418ffb com.apple.notificationcenter (1.0 - 639.10) <EA67E1F8-9506-3336-8F84-FD3512F321B7> /System/Library/Frameworks/NotificationCenter.framework/Versions/A/NotificationCenter
0x7fff3604a000 - 0x7fff36052fef libcldcpuengine.dylib (2.8.7) <DD781325-D94E-3AD7-8D6C-817FB3068917> /System/Library/Frameworks/OpenCL.framework/Versions/A/Libraries/libcldcpuengine.dylib
0x7fff36053000 - 0x7fff360a0ffb com.apple.opencl (2.8.12 - 2.8.12) <0AACB21D-AAC4-337C-8FF6-A8F6196614EE> /System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL
0x7fff360a1000 - 0x7fff360bdffb com.apple.CFOpenDirectory (10.13 - 207) <7664F745-96E0-3F9F-964B-6014928902FB> /System/Library/Frameworks/OpenDirectory.framework/Versions/A/Frameworks/CFOpenDirectory.framework/Versions/A/CFOpenDirectory
0x7fff360be000 - 0x7fff360c9fff com.apple.OpenDirectory (10.13 - 207) <1550BB27-D605-398C-8670-48700C86D674> /System/Library/Frameworks/OpenDirectory.framework/Versions/A/OpenDirectory
0x7fff37248000 - 0x7fff3724afff libCVMSPluginSupport.dylib (16.4.2) <A967BC8B-ABB3-393F-BF34-BD32B45831F7> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCVMSPluginSupport.dylib
0x7fff3724b000 - 0x7fff3724fff7 libCoreFSCache.dylib (162.4) <B325B709-0C81-357A-B9F1-6E0027B64F9B> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCoreFSCache.dylib
0x7fff37250000 - 0x7fff37254fff libCoreVMClient.dylib (162.4) <B129DB84-39BA-34E4-9FB7-20A020A1BB86> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCoreVMClient.dylib
0x7fff37255000 - 0x7fff3725dfff libGFXShared.dylib (16.4.2) <07F1D947-F79B-3608-9080-E4DBFE13AF1D> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGFXShared.dylib
0x7fff3725e000 - 0x7fff37269fff libGL.dylib (16.4.2) <97D6871A-BAF1-33DD-9ED7-BE7BB437F378> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
0x7fff3726a000 - 0x7fff372a5fe7 libGLImage.dylib (16.4.2) <3E2802DF-4998-31DB-B3A2-65720DE919A5> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLImage.dylib
0x7fff372a6000 - 0x7fff37412fff libGLProgrammability.dylib (16.4.2) <3505EF20-FA3D-321B-8C11-D9CA74656F30> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLProgrammability.dylib
0x7fff37413000 - 0x7fff37451ffb libGLU.dylib (16.4.2) <ECABCFAB-E400-3667-8EE1-586C07E0E214> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib
0x7fff37dc9000 - 0x7fff37dd7ffb com.apple.opengl (16.4.2 - 16.4.2) <C8C31EF5-8DB4-336F-A87C-5D520C7EFDC5> /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
0x7fff37dd8000 - 0x7fff37f6fffb GLEngine (16.4.2) <8F35484D-9C09-3D79-9825-7E73661326D4> /System/Library/Frameworks/OpenGL.framework/Versions/A/Resources/GLEngine.bundle/GLEngine
0x7fff37f70000 - 0x7fff37f98ffb GLRendererFloat (16.4.2) <463BD481-6E1A-3EFC-A93B-C7E9292F76ED> /System/Library/Frameworks/OpenGL.framework/Versions/A/Resources/GLRendererFloat.bundle/GLRendererFloat
0x7fff3814f000 - 0x7fff3829bfff com.apple.QTKit (7.7.3 - 3014) <CF2818E6-E215-3C24-A2AC-1B5F8AD7E398> /System/Library/Frameworks/QTKit.framework/Versions/A/QTKit
0x7fff3829c000 - 0x7fff38501ff7 com.apple.imageKit (3.0 - 1040) <5A1261EA-76C5-386C-9F46-06EE804E2234> /System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/ImageKit.framework/Versions/A/ImageKit
0x7fff38502000 - 0x7fff385eeff3 com.apple.PDFKit (1.0 - 677.4) <B5E41E73-0F19-3026-A30E-121F66A38019> /System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/PDFKit.framework/Versions/A/PDFKit
0x7fff385ef000 - 0x7fff38b01ff7 com.apple.QuartzComposer (5.1 - 364) <D99600D5-C066-3D49-8641-369A69300D16> /System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/QuartzComposer.framework/Versions/A/QuartzComposer
0x7fff38b02000 - 0x7fff38b25fff com.apple.quartzfilters (1.10.0 - 1.10.0) <8CBE10F3-828F-373C-B92A-A5289CBCF77A> /System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/QuartzFilters.framework/Versions/A/QuartzFilters
0x7fff38b26000 - 0x7fff38c1dff7 com.apple.QuickLookUIFramework (5.0 - 743.7) <53CAEAD9-0C1D-3CFB-866A-21F4745544D7> /System/Library/Frameworks/Quartz.framework/Versions/A/Frameworks/QuickLookUI.framework/Versions/A/QuickLookUI
0x7fff38c1e000 - 0x7fff38c1efff com.apple.quartzframework (1.5 - 21) <3F3BE91F-A032-3E92-ACEA-E2DFEC999E93> /System/Library/Frameworks/Quartz.framework/Versions/A/Quartz
0x7fff38c1f000 - 0x7fff38e67fff com.apple.QuartzCore (1.11 - 584.8.94) <8D6B5735-852F-36D3-9349-C423582F743B> /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore
0x7fff38e68000 - 0x7fff38ebfff7 com.apple.QuickLookFramework (5.0 - 743.7) <0CB6717C-CCE2-3591-A31E-A8EF01DD4FC8> /System/Library/Frameworks/QuickLook.framework/Versions/A/QuickLook
0x7fff39084000 - 0x7fff3909afff com.apple.SafariServices.framework (13604 - 13604.4.7.1.3) <4DA6B5BD-0F79-3E34-9206-58A0FF3C01D2> /System/Library/Frameworks/SafariServices.framework/Versions/A/SafariServices
0x7fff396a0000 - 0x7fff399b7fff com.apple.security (7.0 - 58286.31.2) <D31B36DF-8956-3205-BFBA-98732DA715E5> /System/Library/Frameworks/Security.framework/Versions/A/Security
0x7fff399b8000 - 0x7fff39a42ff7 com.apple.securityfoundation (6.0 - 55185.30.4) <A1201529-3718-31C4-9D9E-BBD2A04B6751> /System/Library/Frameworks/SecurityFoundation.framework/Versions/A/SecurityFoundation
0x7fff39a43000 - 0x7fff39a73ff3 com.apple.securityinterface (10.0 - 55109.30.2) <B305DA7D-7866-3194-B498-F9995D232486> /System/Library/Frameworks/SecurityInterface.framework/Versions/A/SecurityInterface
0x7fff39a74000 - 0x7fff39a77ffb com.apple.xpc.ServiceManagement (1.0 - 1) <B11C3C64-6FE7-3A78-B583-D790B7CCE95A> /System/Library/Frameworks/ServiceManagement.framework/Versions/A/ServiceManagement
0x7fff39e1c000 - 0x7fff39e8cff3 com.apple.SystemConfiguration (1.17 - 1.17) <3C6B2BB9-43AB-39AD-8027-38E30A8A4186> /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration
0x7fff3a041000 - 0x7fff3a3baff7 com.apple.VideoToolbox (1.0 - 2267.40.5) <CC88FFB3-5DBE-33C0-AF8D-2C915D915A24> /System/Library/Frameworks/VideoToolbox.framework/Versions/A/VideoToolbox
0x7fff3a662000 - 0x7fff3ab7bfe3 libwebrtc.dylib (7604.4.7.1.3) <777100A8-D98C-3DC1-931C-BBC689345FA2> /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/Frameworks/libwebrtc.dylib
0x7fff3ab7c000 - 0x7fff3c018fff com.apple.WebCore (13604 - 13604.4.7.1.3) <FD0252AD-1BF9-30EE-BF2E-4409722582EB> /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/WebCore
0x7fff3c019000 - 0x7fff3c20aff7 com.apple.WebKitLegacy (13604 - 13604.4.7.1.3) <91DD2BFE-AA52-38AD-920C-D21D22ECA1B3> /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebKitLegacy.framework/Versions/A/WebKitLegacy
0x7fff3c20b000 - 0x7fff3c5fafff com.apple.WebKit (13604 - 13604.4.7.1.3) <E9C0A9B5-5331-3FDE-9587-968A86981D53> /System/Library/Frameworks/WebKit.framework/Versions/A/WebKit
0x7fff3ca6a000 - 0x7fff3caf6ff7 com.apple.APFS (1.0 - 1) <834EAD5F-0C4E-3C33-A654-8E1670CEC457> /System/Library/PrivateFrameworks/APFS.framework/Versions/A/APFS
0x7fff3d704000 - 0x7fff3d72cfff com.apple.framework.Apple80211 (13.0 - 1345) <BD86685B-6221-300D-9A97-119285C43DE9> /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Apple80211
0x7fff3d72e000 - 0x7fff3d73dff7 com.apple.AppleFSCompression (96.30.2 - 1.0) <CFA90544-68EB-3CCE-A8F7-1B03974F3B85> /System/Library/PrivateFrameworks/AppleFSCompression.framework/Versions/A/AppleFSCompression
0x7fff3d73e000 - 0x7fff3d822ff7 com.apple.AppleGVAFramework (11.3.7 - 11.3.7) <EB9E64AF-AFF6-3747-8F0E-E77377328143> /System/Library/PrivateFrameworks/AppleGVA.framework/Versions/A/AppleGVA
0x7fff3d879000 - 0x7fff3d8c1ff3 com.apple.AppleJPEG (1.0 - 1) <8BBD5180-5BF9-33DB-8B91-974B1D0AECFB> /System/Library/PrivateFrameworks/AppleJPEG.framework/Versions/A/AppleJPEG
0x7fff3d8d4000 - 0x7fff3d8f2ff3 com.apple.aps.framework (4.0 - 4.0) <932274E4-DCD5-30D5-9AC7-58CEF4571EB3> /System/Library/PrivateFrameworks/ApplePushService.framework/Versions/A/ApplePushService
0x7fff3d8f3000 - 0x7fff3d8fbff3 com.apple.AppleSRP (5.0 - 1) <4CEC34CF-63E3-3023-B61B-F8D133698534> /System/Library/PrivateFrameworks/AppleSRP.framework/Versions/A/AppleSRP
0x7fff3d8fc000 - 0x7fff3d924fff com.apple.applesauce (1.0 - ???) <32FF4851-2F68-35BA-835F-91856A20C323> /System/Library/PrivateFrameworks/AppleSauce.framework/Versions/A/AppleSauce
0x7fff3d9ed000 - 0x7fff3d9f0ff3 com.apple.AppleSystemInfo (3.1.5 - 3.1.5) <A6795AC1-D528-3A2F-9C43-14EBFC57B7D6> /System/Library/PrivateFrameworks/AppleSystemInfo.framework/Versions/A/AppleSystemInfo
0x7fff3d9f1000 - 0x7fff3da41ff7 com.apple.AppleVAFramework (5.0.39 - 5.0.39) <4B830521-2A54-3116-8103-127E631FEDC8> /System/Library/PrivateFrameworks/AppleVA.framework/Versions/A/AppleVA
0x7fff3e110000 - 0x7fff3e117ff7 com.apple.coreservices.BackgroundTaskManagement (1.0 - 57.1) <47B6301F-D908-3811-BB9E-DA16D9B29A34> /System/Library/PrivateFrameworks/BackgroundTaskManagement.framework/Versions/A/BackgroundTaskManagement
0x7fff3e118000 - 0x7fff3e19fff7 com.apple.backup.framework (1.9.2 - 1.9.2) <40C6CFA8-4013-3AFB-97CE-8A09388FA343> /System/Library/PrivateFrameworks/Backup.framework/Versions/A/Backup
0x7fff3e215000 - 0x7fff3e251fff com.apple.bom (14.0 - 194.2) <ED2FFB9D-4DA4-322B-89C0-102D790649CD> /System/Library/PrivateFrameworks/Bom.framework/Versions/A/Bom
0x7fff3e86f000 - 0x7fff3e89cfff com.apple.CalendarAgentLink (8.0 - 250) <55B60B04-2EAA-3F22-88EF-1602129D5294> /System/Library/PrivateFrameworks/CalendarAgentLink.framework/Versions/A/CalendarAgentLink
0x7fff3ef63000 - 0x7fff3efb2ff3 com.apple.ChunkingLibrary (188 - 188) <84E024A0-5F95-3A30-A60B-102343AE46B7> /System/Library/PrivateFrameworks/ChunkingLibrary.framework/Versions/A/ChunkingLibrary
0x7fff3fb2e000 - 0x7fff3fb37ff3 com.apple.CommonAuth (4.0 - 2.0) <11B2D184-36B8-3624-B1AD-7B6037D76160> /System/Library/PrivateFrameworks/CommonAuth.framework/Versions/A/CommonAuth
0x7fff3fb4c000 - 0x7fff3fb61ff7 com.apple.commonutilities (8.0 - 900) <518FBC2C-0AF3-39DF-B454-526311796A49> /System/Library/PrivateFrameworks/CommonUtilities.framework/Versions/A/CommonUtilities
0x7fff3fce5000 - 0x7fff3fd45fff com.apple.AddressBook.ContactsFoundation (8.0 - ???) <9B39DF3E-5B7F-3467-AC17-23258F76A376> /System/Library/PrivateFrameworks/ContactsFoundation.framework/Versions/A/ContactsFoundation
0x7fff3fd46000 - 0x7fff3fd68fff com.apple.contacts.ContactsPersistence (1.0 - 2330.3) <B7EA2D0A-8A43-3E9C-A7D2-E9585064C328> /System/Library/PrivateFrameworks/ContactsPersistence.framework/Versions/A/ContactsPersistence
0x7fff3fdc8000 - 0x7fff401a8fff com.apple.CoreAUC (249.0.0 - 249.0.0) <7F406271-A215-3C75-BDAA-B9611BA2822E> /System/Library/PrivateFrameworks/CoreAUC.framework/Versions/A/CoreAUC
0x7fff401a9000 - 0x7fff401d9ff7 com.apple.CoreAVCHD (5.9.0 - 5900.4.1) <D0879D8F-488A-3D46-BC50-AD7B0642C0E8> /System/Library/PrivateFrameworks/CoreAVCHD.framework/Versions/A/CoreAVCHD
0x7fff401f0000 - 0x7fff4021dfff com.apple.CoreAnalytics.CoreAnalytics (1.0 - 1) <2D7C7B8C-C9C8-3F32-B43E-E792CD88A77D> /System/Library/PrivateFrameworks/CoreAnalytics.framework/Versions/A/CoreAnalytics
0x7fff403d4000 - 0x7fff403ddff7 com.apple.frameworks.CoreDaemon (1.3 - 1.3) <0A87A91C-A2CF-3BB1-9038-7F610111BC30> /System/Library/PrivateFrameworks/CoreDaemon.framework/Versions/B/CoreDaemon
0x7fff40544000 - 0x7fff40554ff7 com.apple.CoreEmoji (1.0 - 69.3) <A4357F5C-0C38-3A61-B456-D7321EB2CEE5> /System/Library/PrivateFrameworks/CoreEmoji.framework/Versions/A/CoreEmoji
0x7fff40e0f000 - 0x7fff40e25ff7 com.apple.CoreMediaAuthoring (2.2 - 956) <A5003E93-68B3-3A0E-8252-454CC4CFEC4D> /System/Library/PrivateFrameworks/CoreMediaAuthoring.framework/Versions/A/CoreMediaAuthoring
0x7fff40f67000 - 0x7fff40fc4ff7 com.apple.CoreNLP (1.0 - 130.4.1) <1F329E38-E7D0-3455-981B-48F434C9E8CC> /System/Library/PrivateFrameworks/CoreNLP.framework/Versions/A/CoreNLP
0x7fff4114d000 - 0x7fff41152ff7 com.apple.CoreOptimization (1.0 - 1) <785B622B-8F7D-3B4D-83AF-EB98CB79FFF6> /System/Library/PrivateFrameworks/CoreOptimization.framework/Versions/A/CoreOptimization
0x7fff41153000 - 0x7fff411f8ff7 com.apple.CorePDF (4.0 - 414) <353C8875-F5A0-37B0-82CF-CAFCE1A95D50> /System/Library/PrivateFrameworks/CorePDF.framework/Versions/A/CorePDF
0x7fff41298000 - 0x7fff412a0ff7 com.apple.CorePhoneNumbers (1.0 - 1) <9966298D-C45D-39FC-8CC4-58288F50D3F8> /System/Library/PrivateFrameworks/CorePhoneNumbers.framework/Versions/A/CorePhoneNumbers
0x7fff412a1000 - 0x7fff412fdfff com.apple.CorePrediction (1.0 - 1) <B1E687BA-4E62-321B-8C87-D37C540A5A68> /System/Library/PrivateFrameworks/CorePrediction.framework/Versions/A/CorePrediction
0x7fff4142a000 - 0x7fff4145bff3 com.apple.CoreServicesInternal (309.1 - 309.1) <EB09CAFC-AE9B-3257-BE45-5471D9F64AAD> /System/Library/PrivateFrameworks/CoreServicesInternal.framework/Versions/A/CoreServicesInternal
0x7fff417aa000 - 0x7fff4183bfff com.apple.CoreSymbolication (63075) <2458D96C-1C31-34F8-93F0-73DB0042CB30> /System/Library/PrivateFrameworks/CoreSymbolication.framework/Versions/A/CoreSymbolication
0x7fff418be000 - 0x7fff419f2fff com.apple.coreui (2.1 - 492.2) <FE0B32BC-958D-3445-866E-A3905626396D> /System/Library/PrivateFrameworks/CoreUI.framework/Versions/A/CoreUI
0x7fff419f3000 - 0x7fff41afeff3 com.apple.CoreUtils (5.3 - 530.57) <1DE5249E-35C5-3B13-BA5B-0C1AA4E17CDD> /System/Library/PrivateFrameworks/CoreUtils.framework/Versions/A/CoreUtils
0x7fff41b53000 - 0x7fff41bb7fff com.apple.framework.CoreWiFi (13.0 - 1339) <1741FD6D-3DF2-3D2D-9B56-92A6AA0D1146> /System/Library/PrivateFrameworks/CoreWiFi.framework/Versions/A/CoreWiFi
0x7fff41bb8000 - 0x7fff41bc7ff7 com.apple.CrashReporterSupport (10.13 - 1) <6B5B2B78-15D2-363F-BE34-8F9226E79E24> /System/Library/PrivateFrameworks/CrashReporterSupport.framework/Versions/A/CrashReporterSupport
0x7fff41c44000 - 0x7fff41c53ff7 com.apple.framework.DFRFoundation (1.0 - 191.1) <09E9A14C-E7A8-3386-8323-270FA28BFB81> /System/Library/PrivateFrameworks/DFRFoundation.framework/Versions/A/DFRFoundation
0x7fff41c56000 - 0x7fff41c5affb com.apple.DSExternalDisplay (3.1 - 380) <BEC07C7C-F3AC-3CF3-B13E-3EBFD6224C0D> /System/Library/PrivateFrameworks/DSExternalDisplay.framework/Versions/A/DSExternalDisplay
0x7fff41c9f000 - 0x7fff41cdfffb com.apple.datadetectors (5.0 - 376) <612C677D-BB71-35D2-BBF3-EA9EC51ADF12> /System/Library/PrivateFrameworks/DataDetectors.framework/Versions/A/DataDetectors
0x7fff41ce0000 - 0x7fff41d56fff com.apple.datadetectorscore (7.0 - 590.3) <792593BC-21C7-3E0C-929E-067CD725FCBD> /System/Library/PrivateFrameworks/DataDetectorsCore.framework/Versions/A/DataDetectorsCore
0x7fff41da4000 - 0x7fff41de4ff7 com.apple.DebugSymbols (141 - 141) <99562E28-0E56-3F6F-93A1-EF997A5E1F87> /System/Library/PrivateFrameworks/DebugSymbols.framework/Versions/A/DebugSymbols
0x7fff41de5000 - 0x7fff41f14fff com.apple.desktopservices (1.12.2 - 1.12.2) <8E068AF7-FB72-38E2-948E-6C13F359C69D> /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv
0x7fff41f73000 - 0x7fff41f74ff7 com.apple.diagnosticlogcollection (10.0 - 1000) <DFD57FDB-CB78-3FB0-B49B-4586F9E0DFC1> /System/Library/PrivateFrameworks/DiagnosticLogCollection.framework/Versions/A/DiagnosticLogCollection
0x7fff42006000 - 0x7fff420d8ff7 com.apple.DiskImagesFramework (480.30.2 - 480.30.2) <251D047D-D79A-3300-8DFC-D6D6D4D0015D> /System/Library/PrivateFrameworks/DiskImages.framework/Versions/A/DiskImages
0x7fff420d9000 - 0x7fff42150ff7 com.apple.DiskManagement (11.2 - 1339) <0B17E79A-0BF6-3FD8-8AD0-A8498545030F> /System/Library/PrivateFrameworks/DiskManagement.framework/Versions/A/DiskManagement
0x7fff42151000 - 0x7fff4215cff7 com.apple.DisplayServicesFW (3.1 - 380) <FB1FBB24-7FD5-3B57-8D3C-39F953F8A9BB> /System/Library/PrivateFrameworks/DisplayServices.framework/Versions/A/DisplayServices
0x7fff421e4000 - 0x7fff421e6ff7 com.apple.EFILogin (2.0 - 2) <5B6E5A73-C2B2-3188-ADE9-C29CE29BB225> /System/Library/PrivateFrameworks/EFILogin.framework/Versions/A/EFILogin
0x7fff42932000 - 0x7fff4294afff com.apple.Engram (1.0 - 1) <93DC8AE3-B3F7-326E-93DB-C85A2BFD3C3F> /System/Library/PrivateFrameworks/Engram.framework/Versions/A/Engram
0x7fff42c88000 - 0x7fff430b6fff com.apple.vision.FaceCore (3.3.2 - 3.3.2) <80C97AD7-D5C2-311A-B268-4AA60CAD6CED> /System/Library/PrivateFrameworks/FaceCore.framework/Versions/A/FaceCore
0x7fff44d1e000 - 0x7fff44d1efff libmetal_timestamp.dylib (802.3.14) <D2CD48A8-5989-32AC-B64B-76E29D4E2449> /System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/3802/Libraries/libmetal_timestamp.dylib
0x7fff4637e000 - 0x7fff46389ff7 libGPUSupportMercury.dylib (16.4.2) <F5BA5D7A-FD23-3416-B9B3-7EABFD4279D5> /System/Library/PrivateFrameworks/GPUSupport.framework/Versions/A/Libraries/libGPUSupportMercury.dylib
0x7fff46726000 - 0x7fff4674bff3 com.apple.GenerationalStorage (2.0 - 285) <07E7BC5F-8EF2-34FC-9EEC-B4E61EAAFA9A> /System/Library/PrivateFrameworks/GenerationalStorage.framework/Versions/A/GenerationalStorage
0x7fff46763000 - 0x7fff47087fff com.apple.GeoServices (1.0 - 1359.22.9.1.19) <0D30FD8E-BAED-3383-AF27-965D3A09B05E> /System/Library/PrivateFrameworks/GeoServices.framework/Versions/A/GeoServices
0x7fff470ca000 - 0x7fff470d9fff com.apple.GraphVisualizer (1.0 - 5) <0A93C5DE-0D28-312E-8764-6B0FB805ED91> /System/Library/PrivateFrameworks/GraphVisualizer.framework/Versions/A/GraphVisualizer
0x7fff47151000 - 0x7fff471c5fff com.apple.Heimdal (4.0 - 2.0) <ACC132E5-97F1-3B36-AD7B-4E6CC077E691> /System/Library/PrivateFrameworks/Heimdal.framework/Versions/A/Heimdal
0x7fff4725f000 - 0x7fff47371ff3 com.apple.ids (10.0 - 1000) <3BAA60B0-8F63-3570-B276-01EF45B9B4DF> /System/Library/PrivateFrameworks/IDS.framework/Versions/A/IDS
0x7fff47372000 - 0x7fff47450ff3 com.apple.idsfoundation (10.0 - 1000) <22E80DC0-4246-3B6B-903F-D1D191E615F8> /System/Library/PrivateFrameworks/IDSFoundation.framework/Versions/A/IDSFoundation
0x7fff47957000 - 0x7fff479bdff3 com.apple.imfoundation (10.0 - 1000) <32799DD1-91A2-3093-8D8C-4F4988560FC2> /System/Library/PrivateFrameworks/IMFoundation.framework/Versions/A/IMFoundation
0x7fff47a77000 - 0x7fff47a7effb com.apple.IOAccelerator (376.6 - 376.6) <A47129CC-F386-3C31-AD66-C19A70615A50> /System/Library/PrivateFrameworks/IOAccelerator.framework/Versions/A/IOAccelerator
0x7fff47a82000 - 0x7fff47a99fff com.apple.IOPresentment (1.0 - 32.1) <B95F06EA-9D5D-311D-9912-978AE42ECFCE> /System/Library/PrivateFrameworks/IOPresentment.framework/Versions/A/IOPresentment
0x7fff47e63000 - 0x7fff47e88fff com.apple.IconServices (97.4 - 97.4) <C84A6CA5-8C50-3288-8572-CC3DABF5BBCE> /System/Library/PrivateFrameworks/IconServices.framework/Versions/A/IconServices
0x7fff47f92000 - 0x7fff47f95ff3 com.apple.InternationalSupport (1.0 - 1) <5AB382FD-BF81-36A1-9565-61F1FD398ECA> /System/Library/PrivateFrameworks/InternationalSupport.framework/Versions/A/InternationalSupport
0x7fff48003000 - 0x7fff48013ffb com.apple.IntlPreferences (2.0 - 227) <0FF7209B-0E4D-3411-B325-03938B7C0938> /System/Library/PrivateFrameworks/IntlPreferences.framework/Versions/A/IntlPreferences
0x7fff4811d000 - 0x7fff48212fff com.apple.LanguageModeling (1.0 - 159.3.1) <9B08E18E-69B4-3413-A03A-EF5AE4BE6277> /System/Library/PrivateFrameworks/LanguageModeling.framework/Versions/A/LanguageModeling
0x7fff48213000 - 0x7fff48255ff7 com.apple.Lexicon-framework (1.0 - 33.2) <5CC5E8EE-62A1-3EA5-B300-A39ABD0CF12D> /System/Library/PrivateFrameworks/Lexicon.framework/Versions/A/Lexicon
0x7fff48259000 - 0x7fff48260ff7 com.apple.LinguisticData (1.0 - 238.3) <228AF7CA-649A-3E24-BBC7-8A24B39B3FC4> /System/Library/PrivateFrameworks/LinguisticData.framework/Versions/A/LinguisticData
0x7fff48347000 - 0x7fff4834cfff com.apple.LoginUICore (4.0 - 4.0) <A5F2EF2E-0999-376D-83EF-1B66171C5723> /System/Library/PrivateFrameworks/LoginUIKit.framework/Versions/A/Frameworks/LoginUICore.framework/Versions/A/LoginUICore
0x7fff48398000 - 0x7fff483b5ff3 com.apple.LookupFramework (1.2 - 239) <ACECB15D-1C21-3D3D-A4C5-F9736090E741> /System/Library/PrivateFrameworks/Lookup.framework/Versions/A/Lookup
0x7fff48a84000 - 0x7fff48a87fff com.apple.Mangrove (1.0 - 1) <13832222-8A6B-3790-8914-BE874B5ED4DD> /System/Library/PrivateFrameworks/Mangrove.framework/Versions/A/Mangrove
0x7fff48b10000 - 0x7fff48b12ff7 com.apple.marco (10.0 - 1000) <86E99D5C-D56D-3874-B465-833A9B40DE88> /System/Library/PrivateFrameworks/Marco.framework/Versions/A/Marco
0x7fff48ba0000 - 0x7fff48bd3ff7 com.apple.MediaKit (16 - 871) <47A5B872-4139-315D-A047-581F9C485D15> /System/Library/PrivateFrameworks/MediaKit.framework/Versions/A/MediaKit
0x7fff48bd4000 - 0x7fff48e18ff7 com.apple.MediaRemote (1.0 - 1) <ADDC2917-76C0-3F07-8DBF-746C9CA6A9BE> /System/Library/PrivateFrameworks/MediaRemote.framework/Versions/A/MediaRemote
0x7fff48e19000 - 0x7fff48e38ff3 com.apple.MediaServices (1.0 - 1) <2CA740A6-7E26-3865-8A5B-C2912665D01C> /System/Library/PrivateFrameworks/MediaServices.framework/Versions/A/MediaServices
0x7fff48eac000 - 0x7fff48f15ff7 com.apple.gpusw.MetalTools (1.0 - 1) <F77943BC-0466-3700-BEDF-CDD13125D36A> /System/Library/PrivateFrameworks/MetalTools.framework/Versions/A/MetalTools
0x7fff48f1d000 - 0x7fff48f32ff3 com.apple.MobileAssets (1.0 - 437.30.17) <9C014350-D76E-3143-ACFF-F3D1B2668988> /System/Library/PrivateFrameworks/MobileAsset.framework/Versions/A/MobileAsset
0x7fff49089000 - 0x7fff490a1ff3 com.apple.MobileKeyBag (2.0 - 1.0) <170AD2F3-9D3E-3FF6-BA02-60C48C1E6724> /System/Library/PrivateFrameworks/MobileKeyBag.framework/Versions/A/MobileKeyBag
0x7fff4912d000 - 0x7fff49155fff com.apple.MultitouchSupport.framework (1204.13 - 1204.13) <6C5D778D-4AB7-39A4-989B-2E8D2D57B3A0> /System/Library/PrivateFrameworks/MultitouchSupport.framework/Versions/A/MultitouchSupport
0x7fff493ba000 - 0x7fff493c5fff com.apple.NetAuth (6.2 - 6.2) <5C6F492A-28EF-3A0E-B573-6F3D60CFF0C7> /System/Library/PrivateFrameworks/NetAuth.framework/Versions/A/NetAuth
0x7fff493d2000 - 0x7fff4949fff7 com.apple.Network (1.0 - 1) <3C391F45-3801-3C27-8D89-FDE554156CDD> /System/Library/PrivateFrameworks/Network.framework/Versions/A/Network
0x7fff4abc7000 - 0x7fff4ac07ffb com.apple.PerformanceAnalysis (1.183.1 - 183.1) <2BE359F2-DCE6-3E33-BA99-964507A3F540> /System/Library/PrivateFrameworks/PerformanceAnalysis.framework/Versions/A/PerformanceAnalysis
0x7fff4ac7f000 - 0x7fff4ac7fff7 com.apple.PhoneNumbers (1.0 - 1) <DB9AC990-BA10-3BAC-8109-3C71E9D45BE2> /System/Library/PrivateFrameworks/PhoneNumbers.framework/Versions/A/PhoneNumbers
0x7fff4c66b000 - 0x7fff4c690fff com.apple.pluginkit.framework (1.0 - 1) <D627D78B-BEDA-3E53-B5F8-B3805F1C4D2A> /System/Library/PrivateFrameworks/PlugInKit.framework/Versions/A/PlugInKit
0x7fff4c98f000 - 0x7fff4c9e2fff com.apple.ProtectedCloudStorage (1.0 - 1) <8C4D5271-406F-3455-88FA-995A95D6D4A1> /System/Library/PrivateFrameworks/ProtectedCloudStorage.framework/Versions/A/ProtectedCloudStorage
0x7fff4c9e3000 - 0x7fff4ca01fff com.apple.ProtocolBuffer (1 - 259) <D047A3FE-C7A8-3CAA-9891-6232BA88C247> /System/Library/PrivateFrameworks/ProtocolBuffer.framework/Versions/A/ProtocolBuffer
0x7fff4cb6e000 - 0x7fff4cb83ff3 com.apple.QuickLookThumbnailing (1.0 - 1) <0771325B-BBAD-3865-B2A3-BE7089641C52> /System/Library/PrivateFrameworks/QuickLookThumbnailing.framework/Versions/A/QuickLookThumbnailing
0x7fff4cb84000 - 0x7fff4cb8cff3 com.apple.RTCReporting (9.32.35.1 - 9.32.35.1) <A62555BF-C5C0-3CD8-BBFA-DB6D0F25722B> /System/Library/PrivateFrameworks/RTCReporting.framework/Versions/A/RTCReporting
0x7fff4cbd5000 - 0x7fff4cbe0fff com.apple.xpc.RemoteServiceDiscovery (1.0 - 1205.30.29) <E2AEA0D7-23E6-3198-96EF-2F1F8ACD98B4> /System/Library/PrivateFrameworks/RemoteServiceDiscovery.framework/Versions/A/RemoteServiceDiscovery
0x7fff4cbe1000 - 0x7fff4cc04ffb com.apple.RemoteViewServices (2.0 - 125) <AEDBCE8C-88B7-315A-9F81-3E068F0D3EDC> /System/Library/PrivateFrameworks/RemoteViewServices.framework/Versions/A/RemoteViewServices
0x7fff4cc05000 - 0x7fff4cc16ffb com.apple.xpc.RemoteXPC (1.0 - 1205.30.29) <1FD53EC6-A9E9-3AEC-86A7-C52729D1A135> /System/Library/PrivateFrameworks/RemoteXPC.framework/Versions/A/RemoteXPC
0x7fff4e51d000 - 0x7fff4e62dff7 com.apple.Sharing (972.6 - 972.6) <2F72F828-7A05-345F-8ABA-1EDADACA4D57> /System/Library/PrivateFrameworks/Sharing.framework/Versions/A/Sharing
0x7fff4e657000 - 0x7fff4e658fff com.apple.performance.SignpostNotification (1.0 - 1) <D4C967BA-92C6-3BAB-AFB5-59F98B35F921> /System/Library/PrivateFrameworks/SignpostNotification.framework/Versions/A/SignpostNotification
0x7fff4f355000 - 0x7fff4f5effff com.apple.SkyLight (1.600.0 - 312.23.4) <390012E0-39E3-3D18-8271-D447990FDD21> /System/Library/PrivateFrameworks/SkyLight.framework/Versions/A/SkyLight
0x7fff4fda0000 - 0x7fff4fdadff7 com.apple.SpeechRecognitionCore (4.0.13 - 4.0.13) <AC026FB9-78F8-31F9-BB80-619D5378DB70> /System/Library/PrivateFrameworks/SpeechRecognitionCore.framework/Versions/A/SpeechRecognitionCore
0x7fff50246000 - 0x7fff5026dff7 com.apple.StreamingZip (1.0 - 1) <F06F4CDC-138C-3991-A987-7C7332BE4508> /System/Library/PrivateFrameworks/StreamingZip.framework/Versions/A/StreamingZip
0x7fff5093f000 - 0x7fff509c3fe7 com.apple.Symbolication (9.0 - 63079.1) <177BC9CA-E6AE-3B40-806F-0080C0CDFF29> /System/Library/PrivateFrameworks/Symbolication.framework/Versions/A/Symbolication
0x7fff50c85000 - 0x7fff50cb1fff com.apple.framework.SystemAdministration (1.0 - 1.0) <6AE03DE8-E5C1-38E5-B788-0A763CAACDC2> /System/Library/PrivateFrameworks/SystemAdministration.framework/Versions/A/SystemAdministration
0x7fff50eb4000 - 0x7fff50ebbff3 com.apple.TCC (1.0 - 1) <C807D3F0-FE20-3FC0-8D61-306477ABEBC4> /System/Library/PrivateFrameworks/TCC.framework/Versions/A/TCC
0x7fff510c8000 - 0x7fff51185ff7 com.apple.TextureIO (3.7 - 3.7) <C98BFACA-7807-3DCA-945D-58EBA2B723C8> /System/Library/PrivateFrameworks/TextureIO.framework/Versions/A/TextureIO
0x7fff511d6000 - 0x7fff511f1ffb com.apple.ToneKit (1.0 - 1) <A0242052-983B-3726-B5BD-D2E672CEFE2F> /System/Library/PrivateFrameworks/ToneKit.framework/Versions/A/ToneKit
0x7fff511f2000 - 0x7fff51219fff com.apple.ToneLibrary (1.0 - 1) <7EEABD7F-D0CB-327E-A772-ACF406B9C8F2> /System/Library/PrivateFrameworks/ToneLibrary.framework/Versions/A/ToneLibrary
0x7fff51229000 - 0x7fff5122afff com.apple.TrustEvaluationAgent (2.0 - 31) <39F533B2-211E-3635-AF47-23F27749FF4A> /System/Library/PrivateFrameworks/TrustEvaluationAgent.framework/Versions/A/TrustEvaluationAgent
0x7fff51230000 - 0x7fff513dfff3 com.apple.UIFoundation (1.0 - 546.1.1) <2B50EBBC-9221-31BC-92A9-7ED0A4A46E2D> /System/Library/PrivateFrameworks/UIFoundation.framework/Versions/A/UIFoundation
0x7fff520a8000 - 0x7fff52177ff7 com.apple.ViewBridge (343.2 - 343.2) <DD3D1ED5-DF9E-3C48-8897-0B84B0AD2377> /System/Library/PrivateFrameworks/ViewBridge.framework/Versions/A/ViewBridge
0x7fff5253c000 - 0x7fff52762ff7 libAWDSupportFramework.dylib (749.13) <B8711178-CE8C-3786-A269-E83710A1B71D> /System/Library/PrivateFrameworks/WirelessDiagnostics.framework/Versions/A/Libraries/libAWDSupportFramework.dylib
0x7fff52763000 - 0x7fff52774fff libprotobuf-lite.dylib (749.13) <9344E035-93AA-3197-8033-93348005AFF5> /System/Library/PrivateFrameworks/WirelessDiagnostics.framework/Versions/A/Libraries/libprotobuf-lite.dylib
0x7fff52775000 - 0x7fff527d7fff libprotobuf.dylib (749.13) <EA5D182D-2E4B-3DF3-BEED-ADEF1FE4EBC5> /System/Library/PrivateFrameworks/WirelessDiagnostics.framework/Versions/A/Libraries/libprotobuf.dylib
0x7fff527d8000 - 0x7fff5281bff7 com.apple.awd (1.0 - 919) <60D12A36-C579-348F-B84C-E25F20C422E0> /System/Library/PrivateFrameworks/WirelessDiagnostics.framework/Versions/A/WirelessDiagnostics
0x7fff52b22000 - 0x7fff52b24ffb com.apple.loginsupport (1.0 - 1) <5E2C4AA7-066D-3FDB-B0E1-4CDAF287392C> /System/Library/PrivateFrameworks/login.framework/Versions/A/Frameworks/loginsupport.framework/Versions/A/loginsupport
0x7fff52b25000 - 0x7fff52b3afff com.apple.login (3.0 - 3.0) <140118A7-8FB9-35C5-92FA-BD79C9C32309> /System/Library/PrivateFrameworks/login.framework/Versions/A/login
0x7fff52b65000 - 0x7fff52b92fff com.apple.contacts.vCard (1.0 - 2330.3) <02AB9DF0-0471-3FDA-8EC6-27C72E00DD75> /System/Library/PrivateFrameworks/vCard.framework/Versions/A/vCard
0x7fff52c88000 - 0x7fff52cbbfff libclosured.dylib (519.2.2) <48051216-5647-3643-B979-B77D0FD20011> /usr/lib/closure/libclosured.dylib
0x7fff52d5b000 - 0x7fff52d94ff7 libCRFSuite.dylib (41) <AB2DA745-F22C-30CF-81D4-35DD716463B8> /usr/lib/libCRFSuite.dylib
0x7fff52d95000 - 0x7fff52da0fff libChineseTokenizer.dylib (28) <D30A7DB6-058F-3286-9583-60C9EEB77A6E> /usr/lib/libChineseTokenizer.dylib
0x7fff52da1000 - 0x7fff52e2eff7 libCoreStorage.dylib (546) <B495D87B-FE21-3C14-9017-F02D9CA226D5> /usr/lib/libCoreStorage.dylib
0x7fff52e32000 - 0x7fff52e33ff3 libDiagnosticMessagesClient.dylib (104) <9712E980-76EE-3A89-AEA6-DF4BAF5C0574> /usr/lib/libDiagnosticMessagesClient.dylib
0x7fff52e6a000 - 0x7fff53034ff3 libFosl_dynamic.dylib (17.7) <B2476843-7FA7-3E62-B79F-2B15FE557E63> /usr/lib/libFosl_dynamic.dylib
0x7fff5306c000 - 0x7fff5306cfff libOpenScriptingUtil.dylib (174) <203D2C39-61BB-3713-A502-2D17B04A42AC> /usr/lib/libOpenScriptingUtil.dylib
0x7fff53195000 - 0x7fff53199ffb libScreenReader.dylib (562.13) <21638ECC-87BF-3CC5-B2D8-6F7883F5FDCA> /usr/lib/libScreenReader.dylib
0x7fff5319a000 - 0x7fff5319bff3 libSystem.B.dylib (1252) <5EDEEA85-0387-31EE-9D9B-DA1B75E7AEF3> /usr/lib/libSystem.B.dylib
0x7fff5319c000 - 0x7fff53219fff libTelephonyUtilDynamic.dylib (3086.2) <47109727-F31F-3777-BD41-1DED1B8C96DC> /usr/lib/libTelephonyUtilDynamic.dylib
0x7fff5321a000 - 0x7fff5321bfff libThaiTokenizer.dylib (2.2) <04AC7CD4-BD9A-3B1D-8CEB-9E2030B6B667> /usr/lib/libThaiTokenizer.dylib
0x7fff5322e000 - 0x7fff5322efff libapple_crypto.dylib (109.30.8) <E0162198-C97F-3286-9FF7-254D23F6FD04> /usr/lib/libapple_crypto.dylib
0x7fff5322f000 - 0x7fff53245ff7 libapple_nghttp2.dylib (1.24) <01402BC4-4822-3676-9C80-50D83F816424> /usr/lib/libapple_nghttp2.dylib
0x7fff53246000 - 0x7fff53270ff3 libarchive.2.dylib (54) <8FC28DD8-E315-3C3E-95FE-D1D2CBE49888> /usr/lib/libarchive.2.dylib
0x7fff53271000 - 0x7fff532f2fdf libate.dylib (1.13.1) <178ACDAD-DE7E-346C-A613-1CBF7929AC07> /usr/lib/libate.dylib
0x7fff532f6000 - 0x7fff532f6ff3 libauto.dylib (187) <A05C7900-F8C7-3E75-8D3F-909B40C19717> /usr/lib/libauto.dylib
0x7fff532f7000 - 0x7fff533aeff7 libboringssl.dylib (109.30.8) <E62E3E83-BA8A-3CCE-8E71-84FB184FBBB5> /usr/lib/libboringssl.dylib
0x7fff533af000 - 0x7fff533bfff3 libbsm.0.dylib (39) <770B341F-3BB7-3123-B53C-F2D58868A963> /usr/lib/libbsm.0.dylib
0x7fff533c0000 - 0x7fff533cdffb libbz2.1.0.dylib (38) <0A5086BB-4724-3C14-979D-5AD4F26B5B45> /usr/lib/libbz2.1.0.dylib
0x7fff533ce000 - 0x7fff53424fff libc++.1.dylib (400.9) <FCF5E1F6-2B04-3545-8004-F3AB32FED172> /usr/lib/libc++.1.dylib
0x7fff53425000 - 0x7fff53449ff7 libc++abi.dylib (400.7) <217656D5-BC40-37FF-B322-91CB2AAD4F34> /usr/lib/libc++abi.dylib
0x7fff5344b000 - 0x7fff5345bfff libcmph.dylib (6) <A5509EE8-7E00-3224-8814-015B077A3CF5> /usr/lib/libcmph.dylib
0x7fff5345c000 - 0x7fff53472fff libcompression.dylib (47) <E64D4416-DFBF-314B-BBB9-BED23C3A251C> /usr/lib/libcompression.dylib
0x7fff5371f000 - 0x7fff53737ff7 libcoretls.dylib (155) <DFE2454F-2FE3-3B2B-A22B-422947C34C69> /usr/lib/libcoretls.dylib
0x7fff53738000 - 0x7fff53739ffb libcoretls_cfhelpers.dylib (155) <D3F4B882-40C1-3CD4-927B-0E0ED6031D0B> /usr/lib/libcoretls_cfhelpers.dylib
0x7fff538d2000 - 0x7fff53a62fff libcrypto.35.dylib (22) <067CFC21-249D-392D-ADE1-785100BF0F83> /usr/lib/libcrypto.35.dylib
0x7fff53bfd000 - 0x7fff53c08ff7 libcsfde.dylib (546) <B6F6340A-F874-38BD-A7BB-FFADEBA54789> /usr/lib/libcsfde.dylib
0x7fff53c09000 - 0x7fff53c5fff3 libcups.2.dylib (462.1) <B78448A0-9C97-3D4A-823E-EBE37B2B7CA6> /usr/lib/libcups.2.dylib
0x7fff53c8a000 - 0x7fff53cdeffb libcurl.4.dylib (105.30.2) <DB7326B0-DE38-392D-AAFA-E81BE0EDE99E> /usr/lib/libcurl.4.dylib
0x7fff53ce1000 - 0x7fff53ce8ff3 libdscsym.dylib (183.1) <2DE012BF-CE9A-3BDF-9A2D-55D66B51AA35> /usr/lib/libdscsym.dylib
0x7fff53d9d000 - 0x7fff53d9dfff libenergytrace.dylib (16) <A92AB8B8-B986-3CE6-980D-D55090FEF387> /usr/lib/libenergytrace.dylib
0x7fff53dcf000 - 0x7fff53dd3ff7 libgermantok.dylib (17) <379C5DC6-BEDB-378D-B09C-A63D297EAA6D> /usr/lib/libgermantok.dylib
0x7fff53dd4000 - 0x7fff53dd9ff3 libheimdal-asn1.dylib (520.30.1) <14DC1451-6E22-3A48-80CB-5D33DC0F8C3B> /usr/lib/libheimdal-asn1.dylib
0x7fff53e05000 - 0x7fff53ef6ff7 libiconv.2.dylib (51) <0772997F-4109-38A1-91ED-0F3F16AE99E5> /usr/lib/libiconv.2.dylib
0x7fff53ef7000 - 0x7fff5411effb libicucore.A.dylib (59152.0.1) <281C39FD-0C9A-3EB2-A407-36D4CCE938E5> /usr/lib/libicucore.A.dylib
0x7fff5416b000 - 0x7fff5416cfff liblangid.dylib (128) <39C39393-0D05-301D-93B2-F224FC4949AA> /usr/lib/liblangid.dylib
0x7fff5416d000 - 0x7fff54186ffb liblzma.5.dylib (10) <3D419A50-961F-37D2-8A01-3DC7AB7B8D18> /usr/lib/liblzma.5.dylib
0x7fff54187000 - 0x7fff5419dff7 libmarisa.dylib (9) <D6D2D55D-1D2E-3442-B152-B18803C0ABB4> /usr/lib/libmarisa.dylib
0x7fff5419e000 - 0x7fff5424dfff libmecab.1.0.0.dylib (779.7.6) <F179766A-0448-37A6-9AD0-99E2FF2C0AD9> /usr/lib/libmecab.1.0.0.dylib
0x7fff5424e000 - 0x7fff54476ff7 libmecabra.dylib (779.7.6) <7808C544-161E-37CE-9D42-F368C82A180D> /usr/lib/libmecabra.dylib
0x7fff5464e000 - 0x7fff54725ffb libnetwork.dylib (1229.30.11) <2A9846DE-C063-3340-89D1-D5DAC2B8A08A> /usr/lib/libnetwork.dylib
0x7fff5479b000 - 0x7fff54b897e7 libobjc.A.dylib (723) <93A92316-DE1E-378C-8891-99720B50D075> /usr/lib/libobjc.A.dylib
0x7fff54b8a000 - 0x7fff54b8bff7 libodfde.dylib (24) <1BBC519E-EF89-38F3-B226-70F086670D0F> /usr/lib/libodfde.dylib
0x7fff54b9c000 - 0x7fff54ba0fff libpam.2.dylib (22) <7B4D2CE2-1438-387A-9802-5CEEFBF26F86> /usr/lib/libpam.2.dylib
0x7fff54ba3000 - 0x7fff54bd7fff libpcap.A.dylib (79.20.1) <FA13918B-A247-3181-B256-9B852C7BA316> /usr/lib/libpcap.A.dylib
0x7fff54c56000 - 0x7fff54c72ffb libresolv.9.dylib (65) <E8F3415B-4472-3202-8901-41FD87981DB2> /usr/lib/libresolv.9.dylib
0x7fff54cad000 - 0x7fff54cbffff libsasl2.2.dylib (211) <D9E281A2-D7BA-32CD-8B96-54972B1D9E66> /usr/lib/libsasl2.2.dylib
0x7fff54cc0000 - 0x7fff54cc1ff7 libspindump.dylib (248) <12E8B8BA-072F-39AE-8BC9-7D5840DA80EB> /usr/lib/libspindump.dylib
0x7fff54cc2000 - 0x7fff54e55fe7 libsqlite3.dylib (274.5) <A1DEB5AB-8FE8-332E-A7E5-F493F2223FE3> /usr/lib/libsqlite3.dylib
0x7fff54eb1000 - 0x7fff54f04ffb libssl.35.dylib (22) <4D77B502-E065-3794-90E7-39E83F9683F6> /usr/lib/libssl.35.dylib
0x7fff54fac000 - 0x7fff54fbcff7 libsystemstats.dylib (403.31.1) <9FE5E908-88F1-3593-ADCD-4BC78100DA68> /usr/lib/libsystemstats.dylib
0x7fff54fd9000 - 0x7fff5500efff libtidy.A.dylib (15.18.1) <3E33A53A-53AB-3FD5-BBAB-DFA6A3A90132> /usr/lib/libtidy.A.dylib
0x7fff55026000 - 0x7fff5505ffff libusrtcp.dylib (1229.30.11) <537F14D0-84DF-349F-8EA0-52BB7A241E60> /usr/lib/libusrtcp.dylib
0x7fff55060000 - 0x7fff55063ffb libutil.dylib (51.20.1) <216D18E5-0BAF-3EAF-A38E-F6AC37CBABD9> /usr/lib/libutil.dylib
0x7fff55064000 - 0x7fff55071fff libxar.1.dylib (400) <0316128D-3B47-3052-995D-97B4FE5491DC> /usr/lib/libxar.1.dylib
0x7fff55075000 - 0x7fff5515cfff libxml2.2.dylib (31.7) <49544596-BCF8-3765-8DC5-DB1A9A90EF92> /usr/lib/libxml2.2.dylib
0x7fff5515d000 - 0x7fff55185fff libxslt.1.dylib (15.10) <66682AF6-C2D5-374C-901F-25A3E72814DC> /usr/lib/libxslt.1.dylib
0x7fff55186000 - 0x7fff55198ffb libz.1.dylib (70) <48C67CFC-940D-3857-8DAD-857774605352> /usr/lib/libz.1.dylib
0x7fff55236000 - 0x7fff5523aff7 libcache.dylib (80) <354F3B7D-404E-3398-9EBF-65CA2CE65211> /usr/lib/system/libcache.dylib
0x7fff5523b000 - 0x7fff55245ff3 libcommonCrypto.dylib (60118.30.2) <674286D3-7744-36A3-9AAA-49DFCD97A986> /usr/lib/system/libcommonCrypto.dylib
0x7fff55246000 - 0x7fff5524dfff libcompiler_rt.dylib (62) <4487CFBA-A5D7-3282-9E6B-94CAD7BE507E> /usr/lib/system/libcompiler_rt.dylib
0x7fff5524e000 - 0x7fff55256ffb libcopyfile.dylib (146.30.2) <2C7C67D7-562B-3FFA-973D-BACF4C10E1EC> /usr/lib/system/libcopyfile.dylib
0x7fff55257000 - 0x7fff552dcfff libcorecrypto.dylib (562.30.10) <8A53EFE1-AFCA-3676-BEE1-FA5ED9F0E222> /usr/lib/system/libcorecrypto.dylib
0x7fff55364000 - 0x7fff5539dff7 libdispatch.dylib (913.30.4) <7D0E3183-282B-3FEE-A734-2C0ADC092084> /usr/lib/system/libdispatch.dylib
0x7fff5539e000 - 0x7fff553bbff7 libdyld.dylib (519.2.2) <C50D02BC-A333-3313-B787-02F255A6783F> /usr/lib/system/libdyld.dylib
0x7fff553bc000 - 0x7fff553bcffb libkeymgr.dylib (28) <6D84A96F-C65B-38EC-BDB5-21FD2C97E7B2> /usr/lib/system/libkeymgr.dylib
0x7fff553bd000 - 0x7fff553c9ff3 libkxld.dylib (4570.31.3) <C0DBCF74-E669-3AAD-934F-F07F3FE32908> /usr/lib/system/libkxld.dylib
0x7fff553ca000 - 0x7fff553caff7 liblaunch.dylib (1205.30.29) <E66F58ED-C15E-3DFB-BC22-A861E13918C6> /usr/lib/system/liblaunch.dylib
0x7fff553cb000 - 0x7fff553cfffb libmacho.dylib (900.0.1) <756F2553-07B6-3B42-ACEA-2F0F1A5E8D0F> /usr/lib/system/libmacho.dylib
0x7fff553d0000 - 0x7fff553d2ff3 libquarantine.dylib (86) <6AC8773F-3817-3D82-99C2-01BABB9C3CBB> /usr/lib/system/libquarantine.dylib
0x7fff553d3000 - 0x7fff553d4ff3 libremovefile.dylib (45) <912FA211-DD8C-3C92-8424-21B89F8B10FD> /usr/lib/system/libremovefile.dylib
0x7fff553d5000 - 0x7fff553ecfff libsystem_asl.dylib (356.1.1) <94972913-9DF0-3C78-847C-43E58919E3DA> /usr/lib/system/libsystem_asl.dylib
0x7fff553ed000 - 0x7fff553edfff libsystem_blocks.dylib (67) <F2493BB5-B1C6-3C4D-9F1F-1B402E0F1DB7> /usr/lib/system/libsystem_blocks.dylib
0x7fff553ee000 - 0x7fff55477ff7 libsystem_c.dylib (1244.30.3) <E0136C71-0648-36F0-9F84-82EA2748A8D7> /usr/lib/system/libsystem_c.dylib
0x7fff55478000 - 0x7fff5547bffb libsystem_configuration.dylib (963.30.1) <0F8D0B76-4F7D-34EC-AB6C-50F9465809DA> /usr/lib/system/libsystem_configuration.dylib
0x7fff5547c000 - 0x7fff5547fffb libsystem_coreservices.dylib (51) <21A488D0-2D07-344E-8631-CC8B2A246F35> /usr/lib/system/libsystem_coreservices.dylib
0x7fff55480000 - 0x7fff55481fff libsystem_darwin.dylib (1244.30.3) <2F750CB1-BC26-3FA3-AE59-553EE30D451B> /usr/lib/system/libsystem_darwin.dylib
0x7fff55482000 - 0x7fff55488ff7 libsystem_dnssd.dylib (878.30.4) <EB9BB165-45A4-367C-B33A-688D4F383A95> /usr/lib/system/libsystem_dnssd.dylib
0x7fff55489000 - 0x7fff554d2ff7 libsystem_info.dylib (517.30.1) <7D79E167-4B5C-3833-81EE-3AF3FB53616D> /usr/lib/system/libsystem_info.dylib
0x7fff554d3000 - 0x7fff554f8ff7 libsystem_kernel.dylib (4570.31.3) <D2E842AA-3B8D-31BF-8234-8C1BE11CFE32> /usr/lib/system/libsystem_kernel.dylib
0x7fff554f9000 - 0x7fff55544fcb libsystem_m.dylib (3146) <ABB1B85F-9FFE-31B8-AD4F-E39A30794A93> /usr/lib/system/libsystem_m.dylib
0x7fff55545000 - 0x7fff55564fff libsystem_malloc.dylib (140.1.1) <9F0745FF-B92F-330D-8812-BB74001D1D33> /usr/lib/system/libsystem_malloc.dylib
0x7fff55565000 - 0x7fff55609ff3 libsystem_network.dylib (1229.30.11) <40BAD301-8744-3AD8-A688-E7925C587B00> /usr/lib/system/libsystem_network.dylib
0x7fff5560a000 - 0x7fff55614ffb libsystem_networkextension.dylib (767.30.7) <C5ED4BAB-2480-369D-8AB6-DFB37C15A1EE> /usr/lib/system/libsystem_networkextension.dylib
0x7fff55615000 - 0x7fff5561eff3 libsystem_notify.dylib (172) <98EA3D62-7C86-30DE-8261-D020D2F1EFF3> /usr/lib/system/libsystem_notify.dylib
0x7fff5561f000 - 0x7fff55626ff7 libsystem_platform.dylib (161.20.1) <C049250F-8C35-314D-810F-4E28AEAED983> /usr/lib/system/libsystem_platform.dylib
0x7fff55627000 - 0x7fff55632fff libsystem_pthread.dylib (301.30.1) <ABA848E1-6978-3B42-A3A7-608B2C36FA93> /usr/lib/system/libsystem_pthread.dylib
0x7fff55633000 - 0x7fff55636ff3 libsystem_sandbox.dylib (765.30.4) <A51828BA-26D8-3205-AF3A-DF5C37269468> /usr/lib/system/libsystem_sandbox.dylib
0x7fff55637000 - 0x7fff55638ff3 libsystem_secinit.dylib (30) <F06ADB8F-9E94-34A7-B3C9-2C22FDD14BAD> /usr/lib/system/libsystem_secinit.dylib
0x7fff55639000 - 0x7fff55640ff7 libsystem_symptoms.dylib (820.30.7) <DC3586C2-AA56-3419-88D3-FC0DBF08E3C0> /usr/lib/system/libsystem_symptoms.dylib
0x7fff55641000 - 0x7fff55654ff7 libsystem_trace.dylib (829.30.14) <69EBF017-D40F-30D7-9B0B-BFC862D761A5> /usr/lib/system/libsystem_trace.dylib
0x7fff55656000 - 0x7fff5565bff7 libunwind.dylib (35.3) <6D4FCD49-D2A9-3233-95C7-A7635CE265F2> /usr/lib/system/libunwind.dylib
0x7fff5565c000 - 0x7fff55688ff7 libxpc.dylib (1205.30.29) <F7E5F1BC-614B-39CB-B6CE-92A9C7B7EC0B> /usr/lib/system/libxpc.dylib
External Modification Summary:
Calls made by other processes targeting this process:
task_for_pid: 1
thread_create: 0
thread_set_state: 0
Calls made by this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by all processes on this machine:
task_for_pid: 168737
thread_create: 0
thread_set_state: 387
VM Region Summary:
ReadOnly portion of Libraries: Total=456.2M resident=0K(0%) swapped_out_or_unallocated=456.2M(100%)
Writable regions: Total=432.3M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=432.3M(100%)
VIRTUAL REGION
REGION TYPE SIZE COUNT (non-coalesced)
=========== ======= =======
Accelerate framework 768K 7
Activity Tracing 256K 2
CG backing stores 1172K 4
CG image 1348K 106
CoreAnimation 61.6M 312
CoreGraphics 8K 2
CoreImage 44K 6
CoreUI image data 4404K 75
CoreUI image file 364K 9
Foundation 28K 3
Image IO 6476K 134
Kernel Alloc Once 8K 2
MALLOC 336.3M 94
MALLOC guard page 112K 25
Mach message 8K 3
Memory Tag 242 12K 2
Memory Tag 251 80K 4
SQLite page cache 7680K 8
STACK GUARD 56.0M 10
Stack 12.1M 11
VM_ALLOCATE 688K 22
__DATA 39.4M 347
__FONT_DATA 4K 2
__GLSLBUILTINS 2588K 2
__LINKEDIT 191.6M 9
__TEXT 264.6M 346
__UNICODE 560K 2
libnetwork 384K 16
mapped file 323.2M 46
shared memory 692K 15
=========== ======= =======
TOTAL 1.3G 1596
Model: MacBookPro12,1, BootROM MBP121.0171.B00, 2 processors, Intel Core i5, 2,9 GHz, 16 GB, SMC 2.28f7
Graphics: Intel Iris Graphics 6100, Intel Iris Graphics 6100, Built-In
Memory Module: BANK 0/DIMM0, 8 GB, DDR3, 1867 MHz, 0x02FE, 0x4544464232333241314D412D4A442D460000
Memory Module: BANK 1/DIMM0, 8 GB, DDR3, 1867 MHz, 0x02FE, 0x4544464232333241314D412D4A442D460000
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x133), Broadcom BCM43xx 1.0 (7.77.37.5.1a3)
Bluetooth: Version 6.0.2f2, 3 services, 18 devices, 1 incoming serial ports
Network Service: Wi-Fi, AirPort, en0
Serial ATA Device: APPLE SSD SM0512G, 500,28 GB
USB Device: USB 3.0 Bus
USB Device: Bluetooth USB Host Controller
Thunderbolt Bus: MacBook Pro, Apple Inc., 27.1
+1 -1
View File
@@ -51,7 +51,7 @@ RUN cd /opt/code && \
tar -Jxf ${VALA_TAR}.tar.xz
RUN cd /opt/code/${VALA_TAR}; ./configure --prefix=/usr ; make && make install
# compile radare and bindings
RUN cd /opt/code; git clone https://github.com/radare/radare2.git; cd radare2; ./sys/all.sh
RUN cd /opt/code; git clone https://github.com/radareorg/radare2.git; cd radare2; ./sys/all.sh
#install Go
+1 -1
View File
@@ -28,7 +28,7 @@ RUN cd /opt/code && \
tar -Jxf ${VALA_TAR}.tar.xz
RUN cd /opt/code/${VALA_TAR}; ./configure --prefix=/usr ; make && make install
# compile radare and bindings
RUN cd /opt/code; git clone https://github.com/radare/radare2.git; cd radare2; ./sys/all.sh
RUN cd /opt/code; git clone https://github.com/radareorg/radare2.git; cd radare2; ./sys/all.sh
#install Go
+2 -2
View File
@@ -39,7 +39,7 @@ RUN apt-get install -y python-pip jython
RUN cd /opt/code; wget http://download.gnome.org/sources/vala/0.24/vala-0.24.0.tar.xz; tar -Jxf vala-0.24.0.tar.xz
RUN cd /opt/code/vala-0.24.0; ./configure --prefix=/usr ; make && make install
# compile radare
RUN cd /opt/code; git clone https://github.com/radare/radare2.git; cd radare2; ./sys/all.sh
RUN cd /opt/code; git clone https://github.com/radareorg/radare2.git; cd radare2; ./sys/all.sh
# Clean up APT when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
@@ -48,7 +48,7 @@ RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN cd /opt/code; wget http://download.gnome.org/sources/vala/0.24/vala-0.24.0.tar.xz; tar -Jxf vala-0.24.0.tar.xz
RUN cd /opt/code/vala-0.24.0; ./configure --prefix=/usr ; make && make install
# compile radare
RUN cd /opt/code; git clone https://github.com/radare/radare2.git; cd radare2; ./sys/all.sh
RUN cd /opt/code; git clone https://github.com/radareorg/radare2.git; cd radare2; ./sys/all.sh
#install oracle jre stuffs
+2 -2
View File
@@ -23,7 +23,7 @@ RUN apt-get install -y python-pip jython
RUN cd /opt/code; wget http://download.gnome.org/sources/vala/0.24/vala-0.24.0.tar.xz; tar -Jxf vala-0.24.0.tar.xz
RUN cd /opt/code/vala-0.24.0; ./configure --prefix=/usr ; make && make install
# compile radare
RUN cd /opt/code; git clone https://github.com/radare/radare2.git; cd radare2; ./sys/all.sh
RUN cd /opt/code; git clone https://github.com/radareorg/radare2.git; cd radare2; ./sys/all.sh
# Clean up APT when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
@@ -32,7 +32,7 @@ RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN cd /opt/code; wget http://download.gnome.org/sources/vala/0.24/vala-0.24.0.tar.xz; tar -Jxf vala-0.24.0.tar.xz
RUN cd /opt/code/vala-0.24.0; ./configure --prefix=/usr ; make && make install
# compile radare
RUN cd /opt/code; git clone https://github.com/radare/radare2.git; cd radare2; ./sys/all.sh
RUN cd /opt/code; git clone https://github.com/radareorg/radare2.git; cd radare2; ./sys/all.sh
#install oracle jre stuffs
+21 -2
View File
@@ -1,4 +1,23 @@
include ../options.mk
LIBDWARFPATH=../../libdwarf-code/
LIBDWARFLIB=${LIBDWARFPATH}/libdwarf/
EXTRA_TARGETS+=${LIBDWARFLIB}/libdwarf.a -lelf -lz
CFLAGS+=$(shell pkg-config --cflags r_util)
CFLAGS+=-I${LIBDWARFLIB}
CC_COR=$(CC) -shared $(CFLAGS) -fPIC
CC_LIB=$(LDFLAGS) $(shell pkg-config --libs r_core) $(EXTRA_TARGETS)
all:
gcc -I/usr/include -g ./main.c -o reader -ldwarf -lelf -lz
$(CC_COR) -O2 -o dparser.$(LIBEXT) main.c $(CC_LIB)
install:
cp -f *.$(LIBEXT) $(R2PM_PLUGDIR)
uninstall:
for a in *.$(LIBEXT) ; do rm -f $(R2PM_PLUGDIR)/$$a ; done
clean:
rm -rf reader
rm -f *.$(LIBEXT)
+52
View File
@@ -0,0 +1,52 @@
DPARSER
=======
A r2 core plugin to read struct and its member from the DWARF structure.
Requirements:
-------------
- libdwarf (currently, it is preferred to use `r2pm -i libdwarf`)
- sdb
Compilation:
------------
```make && make install```
Usage:
------
Currently it works like a simple r2 core plugin.
```
iddi path_to_file_having_dwarf_info
idd structname [offset]
iddj structname [offset] // Output in JSON format
iddv structname.member1.submember2 // Print value of submember2 struct which is a member of member1 struct
idda structname.member1.submember2 // Print address of submember2 struct which is a member of member1 struct
iddlg // Print flags in r2 format for all global variables
iddlf // Print flags in r2 format for all functions
iddd[j] structname[.members]* // Print C-Type declaration. Output in JSON format supported
idddl structname[.members]* // Print C-Type declaration with sub structures shown
iddt structname[.members]* // Print type and size
```
Known problems:
---------------
+ Might fail while using with other libdwarf versions
+ Problem in compilation because of libdwarf and sdb source path
Please file an issue if you find any
Things to do:
-------------
- Allow printing of array fields. For example: `struct->field[2]`
- Issue with setting flags for stubs (they should be named differently)
License:
--------
GPL
+2175 -1318
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -1,5 +1,5 @@
NAME=mycpu
R2_PLUGIN_PATH=$(shell r2 -hh|grep LIBR_PLUGINS|awk '{print $$2}')
R2_PLUGIN_PATH=$(shell r2 -hh|grep R2_LIBR_PLUGINS|awk '{print $$2}')
CFLAGS=-g -fPIC $(shell pkg-config --cflags r_asm)
LDFLAGS=-shared $(shell pkg-config --libs r_asm)
OBJS=$(NAME).o
+5 -5
View File
@@ -30,10 +30,10 @@ static int disassemble (RAsm *a, RAsmOp *op, const ut8 *b, int l) {
int idx = (b[0]&0xf)*2;
op->size = 2;
if (idx>=(OPS*2)) {
strcpy (op->buf_asm, "invalid");
r_strbuf_set (&op->buf_asm, "invalid");
return -1;
}
strcpy (op->buf_asm, ops[idx]);
r_strbuf_set (&op->buf_asm, ops[idx]);
if (ops[idx+1]) {
const char *p = ops[idx+1];
arg[0] = 0;
@@ -50,8 +50,8 @@ static int disassemble (RAsm *a, RAsmOp *op, const ut8 *b, int l) {
sprintf (arg, "r%d, %d", b[1]>>4, (char)b[1]&0xf);
}
if (*arg) {
strcat (op->buf_asm, " ");
strcat (op->buf_asm, arg);
r_strbuf_append (&op->buf_asm, " ");
r_strbuf_append (&op->buf_asm, arg);
}
}
return op->size;
@@ -67,7 +67,7 @@ RAsmPlugin r_asm_plugin_mycpu = {
};
#ifndef CORELIB
struct r_lib_struct_t radare_plugin = {
RLibStruct radare_plugin = {
.type = R_LIB_TYPE_ASM,
.data = &r_asm_plugin_mycpu
};
+21
View File
@@ -0,0 +1,21 @@
NAME=jaguar-gpu
R2_PLUGIN_PATH=$(shell r2 -hh|grep R2_LIBR_PLUGINS|awk '{print $$2}')
CFLAGS=-g -fPIC $(shell pkg-config --cflags r_asm)
LDFLAGS=-shared $(shell pkg-config --libs r_asm)
OBJS=$(NAME).o
SO_EXT=$(shell uname|grep -q Darwin && echo dylib || echo so)
LIB=$(NAME).$(SO_EXT)
all: $(LIB)
clean:
rm -f $(LIB) $(OBJS)
$(LIB): $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $(LIB)
install:
cp -f $(LIB) $(R2_PLUGIN_PATH)
uninstall:
rm -f $(R2_PLUGIN_PATH)/$(LIB)
+222
View File
@@ -0,0 +1,222 @@
/*
* Disassembler for the Jaguar GPU/DSP
* Copyright (C) 2018 - Sebastien Alaiwan
*/
#include <r_asm.h>
#include <r_lib.h>
static int read16_BE (const ut8** b)
{
int val = ((*b)[0] << 8) | ((*b)[1] << 0);
(*b) += 2;
return val;
}
static const char* condition (int code)
{
switch (code)
{
case 0: return "mp"; /* always */
case 1: return "nz";
case 2: return "z";
case 4: return "nc";
case 5: return "nc/nz";
case 6: return "nc/z";
case 8: return "c";
case 9: return "c/nz";
case 10: return "c/z";
case 20: return "nn";
case 21: return "nn/nz";
case 22: return "nn/z";
case 24: return "n";
case 25: return "n/nz";
case 26: return "n/z";
case 31: return "never";
default: return "?";
}
};
static int notZero (int val)
{
return val == 0 ? 32 : val;
}
static int disassemble (RAsm *a, RAsmOp *op, const ut8 *b, int l) {
const ut8* p = b; /* read pointer */
const uint word = read16_BE (&p);
const uint opCode = (word >> 10) & 63;
const uint reg1 = (word >> 5) & 31;
const uint reg2 = (word >> 0) & 31;
uint pc = a->pc;
pc += 2;
switch (opCode)
{
case 0: r_strbuf_setf (&op->buf_asm, "add r%d, r%d", reg1, reg2);
break;
case 1: r_strbuf_setf (&op->buf_asm, "addc r%d, r%d", reg1, reg2);
break;
case 2: r_strbuf_setf (&op->buf_asm, "addq 0x%x, r%d", notZero (reg1), reg2);
break;
case 3: r_strbuf_setf (&op->buf_asm, "addqt 0x%x, r%d", notZero (reg1), reg2);
break;
case 4: r_strbuf_setf (&op->buf_asm, "sub r%d, r%d", reg1, reg2);
break;
case 5: r_strbuf_setf (&op->buf_asm, "subc r%d, r%d", reg1, reg2);
break;
case 6: r_strbuf_setf (&op->buf_asm, "subq 0x%x, r%d", notZero (reg1), reg2);
break;
case 7: r_strbuf_setf (&op->buf_asm, "subqt 0x%x, r%d", notZero (reg1), reg2);
break;
case 8: r_strbuf_setf (&op->buf_asm, "neg r%d", reg2);
break;
case 9: r_strbuf_setf (&op->buf_asm, "and r%d, r%d", reg1, reg2);
break;
case 10: r_strbuf_setf (&op->buf_asm, "or r%d, r%d", reg1, reg2);
break;
case 11: r_strbuf_setf (&op->buf_asm, "xor r%d, r%d", reg1, reg2);
break;
case 12: r_strbuf_setf (&op->buf_asm, "not r%d", reg2);
break;
case 13: r_strbuf_setf (&op->buf_asm, "btst 0x%x, r%d", reg1, reg2);
break;
case 14: r_strbuf_setf (&op->buf_asm, "bset 0x%x, r%d", reg1, reg2);
break;
case 15: r_strbuf_setf (&op->buf_asm, "bclr 0x%x, r%d", reg1, reg2);
break;
case 16: r_strbuf_setf (&op->buf_asm, "mult r%d, r%d", reg1, reg2);
break;
case 17: r_strbuf_setf (&op->buf_asm, "imult r%d, r%d", reg1, reg2);
break;
case 18: r_strbuf_setf (&op->buf_asm, "imultn r%d, r%d", reg1, reg2);
break;
case 19: r_strbuf_setf (&op->buf_asm, "resmac r%d", reg2);
break;
case 20: r_strbuf_setf (&op->buf_asm, "imacn r%d, r%d", reg1, reg2);
break;
case 21: r_strbuf_setf (&op->buf_asm, "div r%d, r%d", reg1, reg2);
break;
case 22: r_strbuf_setf (&op->buf_asm, "abs r%d", reg2);
break;
case 23: r_strbuf_setf (&op->buf_asm, "sh r%d, r%d", reg1, reg2);
break;
case 24: r_strbuf_setf (&op->buf_asm, "shlq 0x%x, r%d", 32 - notZero (reg1), reg2);
break;
case 25: r_strbuf_setf (&op->buf_asm, "shrq 0x%x, r%d", notZero (reg1), reg2);
break;
case 26: r_strbuf_setf (&op->buf_asm, "sha r%d, r%d", reg1, reg2);
break;
case 27: r_strbuf_setf (&op->buf_asm, "sharq 0x%x, r%d", notZero (reg1), reg2);
break;
case 28: r_strbuf_setf (&op->buf_asm, "ror r%d, r%d", reg1, reg2);
break;
case 29: r_strbuf_setf (&op->buf_asm, "rorq 0x%x, r%d", notZero (reg1), reg2);
break;
case 30: r_strbuf_setf (&op->buf_asm, "cmp r%d, r%d", reg1, reg2);
break;
case 31: r_strbuf_setf (&op->buf_asm, "cmpq 0x%x, r%d", reg1, reg2);
break;
case 32: r_strbuf_setf (&op->buf_asm, "sat8 r%d", reg2);
break;
case 33: r_strbuf_setf (&op->buf_asm, "sat16 r%d", reg2);
break;
case 34: r_strbuf_setf (&op->buf_asm, "move r%d, r%d", reg1, reg2);
break;
case 35: r_strbuf_setf (&op->buf_asm, "moveq 0x%x, r%d", reg1, reg2);
break;
case 36: r_strbuf_setf (&op->buf_asm, "moveta r%d, r%d", reg1, reg2);
break;
case 37: r_strbuf_setf (&op->buf_asm, "movefa r%d, r%d", reg1, reg2);
break;
case 38:
{
uint low = read16_BE (&p);
uint high = read16_BE (&p);
r_strbuf_setf (&op->buf_asm, "movei 0x%x, r%d", low | (high << 16), reg2);
break;
}
case 39: r_strbuf_setf (&op->buf_asm, "loadb [r%d], r%d", reg1, reg2);
break;
case 40: r_strbuf_setf (&op->buf_asm, "loadw [r%d], r%d", reg1, reg2);
break;
case 41: r_strbuf_setf (&op->buf_asm, "load [r%d], r%d", reg1, reg2);
break;
case 42: r_strbuf_setf (&op->buf_asm, "loadp [r%d], r%d", reg1, reg2);
break;
case 43: r_strbuf_setf (&op->buf_asm, "load [r14+0x%x], r%d", notZero (reg1)*4, reg2);
break;
case 44: r_strbuf_setf (&op->buf_asm, "load [r15+0x%x], r%d", notZero (reg1)*4, reg2);
break;
case 45: r_strbuf_setf (&op->buf_asm, "storeb r%d, [r%d]", reg2, reg1);
break;
case 46: r_strbuf_setf (&op->buf_asm, "storew r%d, [r%d]", reg2, reg1);
break;
case 47: r_strbuf_setf (&op->buf_asm, "store r%d, [r%d]", reg2, reg1);
break;
case 48: r_strbuf_setf (&op->buf_asm, "storep r%d, [r%d]", reg2, reg1);
break;
case 49: r_strbuf_setf (&op->buf_asm, "store r%d, [r14+0x%x]", reg2, notZero (reg1)*4);
break;
case 50: r_strbuf_setf (&op->buf_asm, "store r%d, [r15+0x%x]", reg2, notZero (reg1)*4);
break;
case 51: r_strbuf_setf (&op->buf_asm, "move pc, r%d", reg2);
break;
case 52: r_strbuf_setf (&op->buf_asm, "j%s [r%d]", condition(reg2), reg1);
break;
case 53: r_strbuf_setf (&op->buf_asm, "j%s 0x%.8X", condition(reg2), pc + ((int8_t)(reg1 << 3) >> 2));
break;
case 54: r_strbuf_setf (&op->buf_asm, "mmult r%d, r%d", reg1, reg2);
break;
case 55: r_strbuf_setf (&op->buf_asm, "mtoi r%d, r%d", reg1, reg2);
break;
case 56: r_strbuf_setf (&op->buf_asm, "normi r%d, r%d", reg1, reg2);
break;
case 57: r_strbuf_setf (&op->buf_asm, "nop");
break;
case 58: r_strbuf_setf (&op->buf_asm, "load [r14+r%d], r%d", reg1, reg2);
break;
case 59: r_strbuf_setf (&op->buf_asm, "load [r15+r%d], r%d", reg1, reg2);
break;
case 60: r_strbuf_setf (&op->buf_asm, "store r%d, [r14+r%d]", reg2, reg1);
break;
case 61: r_strbuf_setf (&op->buf_asm, "store r%d, [r15+r%d]", reg2, reg1);
break;
case 62: r_strbuf_setf (&op->buf_asm, "sat24 r%d", reg2);
break;
case 63:
{
if (reg1 == 0)
r_strbuf_setf (&op->buf_asm, "pack r%d", reg2);
else if (reg1 == 1)
r_strbuf_setf (&op->buf_asm, "unpack r%d", reg2);
else
r_strbuf_setf (&op->buf_asm, "invalid");
break;
}
}
op->size = p - b;
r_strbuf_setbin (&op->buf_hex, b, op->size);
return op->size;
}
RAsmPlugin r_asm_plugin_jaguar_gpu = {
.name = "jaguar-gpu",
.arch = "jaguar-gpu",
.author = "Sebastien Alaiwan",
.bits = 32,
.desc = "Disassembler for the Jaguar GPU",
.license = "LGPL3",
.disassemble = &disassemble,
};
#ifndef CORELIB
RLibStruct radare_plugin = {
.type = R_LIB_TYPE_ASM,
.data = &r_asm_plugin_jaguar_gpu
};
#endif
+7
View File
@@ -0,0 +1,7 @@
all:
install:
cp -f r2kaitai ${DESTDIR}/${PREFIX}/bin/r2kaitai
uninstall:
rm -f ${DESTDIR}/${PREFIX}/bin/r2kaitai
+27
View File
@@ -0,0 +1,27 @@
Integrating r2 with Kaitai
==========================
Installation:
$ r2pm -i kaitai-struct-compiler
$ r2pm -i ksv
$ r2pm -i r2kaitai
Demo Session:
$ r2 /bin/ls
> !r2kaitai
archive/lzh
archive/rar
archive/zip
common/vlq_base128_be
common/vlq_base128_le
executable/dos_mz
executable/elf
executable/java_class
executable/mach_o
...
> !r2kaitai executables/mach_o
(... ksv show goes here ...)
+39
View File
@@ -0,0 +1,39 @@
#!/bin/sh
s='$'
showHelp() {
echo "Usage: r2kaitai [signature.ksy] [$s{R2_BLOCK}]"
}
[ "$1" = -h ] && showHelp && exit 0
SIGN="$1"
FILE="$2"
R2PM_GITDIR=`r2pm -H R2PM_GITDIR`
ROOT=${R2PM_GITDIR}/kaitai-struct-compiler/formats
if [ ! -d "${ROOT}" ]; then
echo "Cannot find kaitai-struct-compiler"
echo ' $ r2pm -i kaitai-struct-compiler'
exit 1
fi
if [ -z "$SIGN" ]; then
( cd ${ROOT} && find * -iname '*.ksy' | sed -e 's,.ksy$,,' )
exit 0
fi
if [ ! -f "${ROOT}/${SIGN}.ksy" ]; then
echo "Invalid kaitai signature file"
exit 1
fi
if [ -z "${FILE}" ]; then
FILE="${R2_FILE}"
if [ -z "${FILE}" ]; then
showHelp
exit 1
fi
fi
echo r2pm -r ksv ${FILE} ${R2PM_GITDIR}/kaitai-struct-compiler/formats/${SIGN}.ksy
exec r2pm -r ksv ${FILE} ${ROOT}/${SIGN}.ksy
+1 -1
View File
@@ -11,7 +11,7 @@ ifeq ($(shell uname),Darwin)
KS_LDFLAGS+=-Xlinker -rpath -Xlinker $(R2PM_PREFIX)/lib
endif
ifeq ($(shell uname),Linux)
KS_LDFLAGS+=-Xlinker -Wl,-R$(R2PM_PREFIX)/lib
KS_LDFLAGS+=-Wl,-R$(R2PM_PREFIX)/lib
endif
.PHONY: all clean install uninstall mrproper test
+46 -33
View File
@@ -1,9 +1,10 @@
#!/bin/sh
# This script was automatically generated by ACR v0.10.2
# This script was automatically generated by ACR v1.7.2
# @author: pancake <nopcode.org>
# @url: http://www.nopcode.org
# @repo: git clone https://github.com/radare/acr
[ -z "${AWK}" ] && AWK=awk
do_remove() {
if [ "${ACR_RMFILES}" ]; then
printf "cleaning temporally files... "
@@ -23,7 +24,7 @@ while : ; do
ENVWORDS="${ENVWORDS} $1_CPU $1_OS"
STR=`eval "echo ${S}$1"`
SPLIT_CPU="`echo "$STR" | cut -d - -f 1`"
SPLIT_OS="`echo "$STR" | awk -F - '{
SPLIT_OS="`echo "$STR" | $AWK -F - '{
if ($2=="unknown"){
if (NF<3) { print $2; } else { print $3; }
} else {
@@ -39,7 +40,7 @@ done
}
VPATH=`dirname ${0}`
if [ "${VPATH}" = "." ]; then
if [ "${VPATH}" = "." ]; then
WODIS=current
else
if [ "${VPATH}" = "${PWD}" ]; then
@@ -61,6 +62,7 @@ if [ -e "${VPATH}/config.guess" ]; then
fi
CPU="`uname -m|sed -e 's, ,,g'|cut -d - -f 1`"
OS="`uname -s|tr A-Z a-z`"
uname -r | grep -qE "(Microsoft|WSL)" 2>/dev/null && OS="wsl"
GNU="`uname --help 2>&1 | grep gnu`"
[ "${GNU}" ] && OS="${OS}-gnu"
[ "${CPU}" = ppc ] && CPU="powerpc"
@@ -88,10 +90,11 @@ create_environ() {
: ${DATADIR:="${SPREFIX}/share"}
: ${INFODIR:="${DATADIR}/info"}
: ${MANDIR:="${DATADIR}/man"}
: ${DOCDIR:="${DATADIR}/doc/radare2-keystone"}
: ${LOCALSTATEDIR:="${SPREFIX}/var"}
for A in `echo ${PATH} | sed -e 's,:, ,g'` ; do
[ -e $A/ginstall ] && : ${INSTALL:=$A/ginstall} && break
[ -e $A/install ] && : ${INSTALL:=$A/install} && break
[ -e "$A"/ginstall ] && : ${INSTALL:="$A"/ginstall} && break
[ -e "$A"/install ] && : ${INSTALL:="$A"/install} && break
done
: ${INSTALL_DIR:=${INSTALL} -d}
: ${INSTALL_DATA:=${INSTALL} -m 644}
@@ -102,7 +105,7 @@ done
: ${INSTALL_LIB:=${INSTALL} -m 755 -c}
PKGNAME='radare2-keystone' ; VERSION='0.1' ; CONTACT_MAIL="[email protected]" ; CONTACT_NAME="pancake" ; CONTACT="pancake <[email protected]>" ;
}
show_usage() {
cat <<EOF2
'configure' configures radare2-keystone-0.1 to adapt to many kinds of systems.
@@ -116,27 +119,28 @@ Defaults for the options are specified in brackets.
Configuration:
-h, --help display this help and exit
-V, --version display version information and exit
-r, --report show what libs/programs require to work
-V, --version display version information and exit
Installation directories:
--prefix=PREFIX install arch-independent files in PREFIX [/usr/local]
--exec-prefix=EPREFIX install arch-dependent files in EPREFIX [PREFIX]
--prefix=PREFIX install arch-independent files in PREFIX [/usr/local]
--sandbox=SPREFIX sandbox prefix directory: SPREFIX [PREFIX]
Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--datadir=DIR read-only architecture-independent data [PREFIX/share]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--libdir=DIR object code libraries [EPREFIX/lib]
--libpath=DIR set rpath/libname-path to linker
--docdir=DIR documentation directory [DATADIR/doc/radare2-keystone]
--includedir=DIR C header files [PREFIX/include]
--infodir=DIR info documentation [DATADIR/info]
--libexecdir=DIR program executables [EPREFIX/libexec]
--libdir=DIR object code libraries [EPREFIX/lib]
--libpath=DIR set rpath/libname-path to linker
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--mandir=DIR man documentation [DATADIR/man]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
System types:
--build=BUILD configure for building on BUILD [guessed]
@@ -173,7 +177,7 @@ take_environ() {
}
show_version() {
echo "radare2-keystone-0.1 configuration script done with acr v0.10.2.
echo "radare2-keystone-0.1 configuration script done with acr v1.7.2.
The 'Free Software Foundation' message is only for autodetection.
Originally written by pancake <nopcode.org>."
exit 0
@@ -181,7 +185,7 @@ exit 0
parse_options() {
flag=`echo $1| cut -d = -f 1`
value=`echo $1| awk 'BEGIN{FS="=";}{print $2}'`
value=`echo $1| $AWK 'BEGIN{FS="=";}{print $2}'`
flag2=`echo $flag|cut -f2- -d -| sed -e 's,-,_,g' -e 's,^_,,g'|tr '[a-z]' '[A-Z]'`
if [ "${TARGET_OS}" = "darwin" ]; then
@@ -203,7 +207,7 @@ echo "REQUIRED: libkeystone"
echo "PKG-CONFIG: r_asm"
exit 0
;;
--cache-file)
--cache-file)
# ignored: acr have no cache
;;
--build)
@@ -225,6 +229,8 @@ echo "PKG-CONFIG: r_asm"
SBINDIR="$value"; ;;
--libexecdir)
LIBEXECDIR="$value"; ;;
--docdir)
DOCDIR="$value"; ;;
--datadir)
DATADIR="$value"; ;;
--sysconfdir)
@@ -244,7 +250,7 @@ echo "PKG-CONFIG: r_asm"
--mandir)
MANDIR="$value"; ;;
*) if [ "$value" ]; then eval "`echo $flag2=$value`" ;
*) if [ "$value" ]; then eval "`echo $flag2=$value`" ;
else echo ; echo "WARNING: Unknown flag '$flag'." >&2 ; echo ; fi ;;
esac
}
@@ -261,7 +267,7 @@ parse_options "$1"
shift
done
ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR SYSCONFDIR DATADIR LIBEXECDIR SBINDIR BINDIR EPREFIX PREFIX SPREFIX TARGET HOST BUILD INSTALL INSTALL_LIB INSTALL_MAN INSTALL_PROGRAM INSTALL_PROGRAM_STRIP INSTALL_DIR INSTALL_SCRIPT INSTALL_DATA HOST_OS HOST_CPU BUILD_OS BUILD_CPU TARGET_OS TARGET_CPU PKGNAME VPATH VERSION CONTACT CONTACT_NAME CONTACT_MAIL CC CFLAGS CPPFLAGS LDFLAGS HAVE_LANG_C CXX CXXFLAGS HAVE_LANG_CXX HAVE_LIB_KEYSTONE R2_CFLAGS R2_LDFLAGS HAVE_PKGCFG_R_ASM"
ENVWORDS="MANDIR INFODIR LIBDIR INCLUDEDIR LOCALSTATEDIR SYSCONFDIR DATADIR DOCDIR LIBEXECDIR SBINDIR BINDIR EPREFIX PREFIX SPREFIX TARGET HOST BUILD INSTALL INSTALL_LIB INSTALL_MAN INSTALL_PROGRAM INSTALL_PROGRAM_STRIP INSTALL_DIR INSTALL_SCRIPT INSTALL_DATA HOST_OS HOST_CPU BUILD_OS BUILD_CPU TARGET_OS TARGET_CPU PKGNAME VPATH VERSION CONTACT CONTACT_NAME CONTACT_MAIL CC CFLAGS CPPFLAGS LDFLAGS HAVE_LANG_C CXX CXXFLAGS HAVE_LANG_CXX HAVE_LIB_KEYSTONE R2_CFLAGS R2_LDFLAGS HAVE_PKGCFG_R_ASM"
create_environ
@@ -278,7 +284,7 @@ ACR_RMFILES=" test.c a.out a.exe test.c test.cxx a.out a.exe"
:
COMPILER=CC
printf "checking for c compiler... "
HAVE_LANG_C=1
@@ -325,29 +331,36 @@ if [ $? = 0 ]; then
echo yes
else
eval ${VAR}=0
echo no
echo "this library is required."
do_remove
exit 1 ; fi }
check_library HAVE_LIB_KEYSTONE keystone 1
echo no
if [ "${_REQUIRED}" = 1 ]; then
echo "this library is required."
do_remove
exit 1
fi
fi
}
check_library HAVE_LIB_KEYSTONE keystone 1
[ -z "${PKGCONFIG}" ] && PKGCONFIG=pkg-config
type ${PKGCONFIG} > /dev/null 2>&1 || echo "ERROR: Cannot find PKGCONFIG ${PKGCONFIG}"
echo 'Using PKGCONFIG: '${PKGCONFIG}
printf 'checking pkg-config flags for r_asm... '
tmp=`${PKGCONFIG} --cflags r_asm 2>/dev/null`
if [ $? != 0 ]; then echo no ; HAVE_PKGCFG_R_ASM=0;
if [ $? != 0 ]; then echo no ; HAVE_PKGCFG_R_ASM=0;
R2_CFLAGS='';R2_LDFLAGS='';
echo 'This package is required'
exit 1
else
R2_CFLAGS=$tmp;
else
R2_CFLAGS=$tmp;
tmp=`${PKGCONFIG} --libs r_asm 2>/dev/null`
if [ $? = 0 ]; then
echo yes; HAVE_PKGCFG_R_ASM=1;
if [ $? = 0 ]; then
echo yes; HAVE_PKGCFG_R_ASM=1;
R2_LDFLAGS=$tmp; fi; fi
SEDFLAGS=" -e '"
COUNT=0
for A in ${ENVWORDS} ; do
[ "${A}" = VPATH ] && continue
[ "${A}" = srcdir ] && continue
[ "${A}" = srcdir ] && continue
eval "VAR=\$${A}"
VAR="`echo ${VAR} | sed -e 's/\,/\\\,/g'`"
[ $COUNT = 10 ] && COUNT=0 && SEDFLAGS="${SEDFLAGS}' -e '"
@@ -378,7 +391,7 @@ if [ "$VALUE" = 0 ]; then ## FALSE
MARK="##${A}##"
if [ -n "`grep \"${MARK}\" ${SD_TARGET}.tmp`" ]; then
mv ${SD_TARGET}.tmp ${SD_TARGET}.tmp2
cat ${SD_TARGET}.tmp2 | MARK=$MARK awk 'BEGIN{a=0;}{if($1==ENVIRON["MARK"]){if(a)a=0;else a=1}else{if(!a)print;}}' > ${SD_TARGET}.tmp
cat ${SD_TARGET}.tmp2 | MARK=$MARK $AWK 'BEGIN{a=0;}{if($1==ENVIRON["MARK"]){if(a)a=0;else a=1}else{if(!a)print;}}' > ${SD_TARGET}.tmp
fi
fi
done
+1 -1
View File
@@ -58,7 +58,7 @@ static int keystone_assemble(RAsm *a, RAsmOp *ao, const char *str, ks_arch arch,
}
return -1;
}
memcpy (ao->buf, insn, R_MIN (size, sizeof (ao->buf) -1));
r_asm_op_set_buf (ao, insn, size);
ks_free (insn);
if (ks) {
ks_close (ks);
+55 -4
View File
@@ -4,26 +4,77 @@ bea:
$(MAKE) -C asm bea
$(MAKE) -C anal bea
atombios:
$(MAKE) -C asm atombios
$(MAKE) -C anal atombios
$(MAKE) -C bin atombios
blackfin:
$(MAKE) -C asm blackfin
tab:
$(MAKE) -C asm tab
olly:
$(MAKE) -C asm olly
udis udis86:
$(MAKE) -C asm x86_udis
$(MAKE) -C anal x86_udis
m68k:
$(MAKE) -C asm m68k
$(MAKE) -C anal m68k
$(MAKE) -C asm m68k_net
$(MAKE) -C anal m68k_net
zyan:
$(MAKE) -C asm zyan
evm:
$(MAKE) -C asm evm
$(MAKE) -C anal evm
$(MAKE) -C io evm
$(MAKE) -C debug evm
nios:
$(MAKE) -C asm nios
clean:
$(MAKE) -C asm clean
$(MAKE) -C anal clean
atombios-install:
cp -f asm/p/asm_atombios.$(LIBEXT) $(R2PM_PLUGDIR)
cp -f anal/p/anal_atombios.$(LIBEXT) $(R2PM_PLUGDIR)
cp -f bin/p/bin_atombios.$(LIBEXT) $(R2PM_PLUGDIR)
bea-install:
cp -f asm/p/asm_x86_bea.$(LIBEXT) $(R2PM_PLUGDIR)
cp -f anal/p/anal_x86_bea.$(LIBEXT) $(R2PM_PLUGDIR)
udis86-install udis-install:
cp -f asm/p/asm_x86_udis.$(LIBEXT) $(R2PM_PLUGDIR)
cp -f anal/p/anal_x86_udis.$(LIBEXT) $(R2PM_PLUGDIR)
tab-install:
cp -f asm/p/asm_x86_tab.$(LIBEXT) $(R2PM_PLUGDIR)
olly-install:
cp -f asm/p/asm_x86_olly.$(LIBEXT) $(R2PM_PLUGDIR)
m68k-install:
cp -f asm/p/asm_m68k.$(LIBEXT) $(R2PM_PLUGDIR)
cp -f anal/p/anal_m68k.$(LIBEXT) $(R2PM_PLUGDIR)
cp -f asm/p/asm_m68k_net.$(LIBEXT) $(R2PM_PLUGDIR)
cp -f anal/p/anal_m68k_net.$(LIBEXT) $(R2PM_PLUGDIR)
zyan-install:
cp -f asm/p/asm_x86_zyan.$(LIBEXT) $(R2PM_PLUGDIR)
evm-install:
cp -f asm/p/asm_evm.$(LIBEXT) $(R2PM_PLUGDIR)
cp -f anal/p/anal_evm.$(LIBEXT) $(R2PM_PLUGDIR)
cp -f io/p/io_evm.$(LIBEXT) $(R2PM_PLUGDIR)
cp -f debug/p/debug_evm.$(LIBEXT) $(R2PM_PLUGDIR)
nios-install:
cp -f asm/p/asm_nios.$(LIBEXT) $(R2PM_PLUGDIR)
include ../options.mk
+14 -3
View File
@@ -1,10 +1,21 @@
bea:
cd p ; $(MAKE) anal_x86_bea.$(LIBEXT)
m68k:
cd p ; $(MAKE) anal_m68k.$(LIBEXT)
x86_udis udis udis86:
cd p ; $(MAKE) anal_x86_udis.$(LIBEXT)
m68k_net:
cd p ; $(MAKE) anal_m68k_net.$(LIBEXT)
atombios:
cd p ; $(MAKE) anal_atombios.$(LIBEXT)
evm:
cd p ; $(MAKE) anal_evm.$(LIBEXT)
clean:
rm -f p/anal_x86_bea.$(LIBEXT)
rm -f p/anal_m68k.$(LIBEXT)
rm -f p/anal_m68k_net.$(LIBEXT)
rm -f p/anal_atombios.{$(LIBEXT),o}
include ../../options.mk
+4 -1
View File
@@ -3,6 +3,9 @@ ARCHS=
ARCHS+=x86_bea.mk
#ARCHS+=x86_im.mk
ARCHS+=x86_simple.mk
ARCHS+=m68k.mk
ARCHS+=x86_udis.mk
ARCHS+=m68k_net.mk
ARCHS+=evm.mk
ARCHS+=atombios.mk
include ../../plugs.mk
File diff suppressed because it is too large. Load diff
+638
View File
@@ -0,0 +1,638 @@
#include <string.h>
#include <errno.h>
#include <jansson.h>
#include <r_types.h>
#include <r_lib.h>
#include <r_asm.h>
#include <r_anal.h>
#include <r_util.h>
#include <sdb.h>
#include "evm.h"
struct evm_anal_info {
Sdb *pushs_db;
};
static struct evm_anal_info *evm_ai = NULL;
static unsigned opcodes_types[] = {
[EVM_OP_STOP] = R_ANAL_OP_TYPE_RET,
[EVM_OP_ADD] = R_ANAL_OP_TYPE_ADD,
[EVM_OP_MUL] = R_ANAL_OP_TYPE_MUL,
[EVM_OP_SUB] = R_ANAL_OP_TYPE_SUB,
[EVM_OP_DIV] = R_ANAL_OP_TYPE_DIV,
[EVM_OP_SDIV] = R_ANAL_OP_TYPE_DIV,
[EVM_OP_MOD] = R_ANAL_OP_TYPE_MOD,
[EVM_OP_SMOD] = R_ANAL_OP_TYPE_MOD,
[EVM_OP_ADDMOD] = R_ANAL_OP_TYPE_ADD,
[EVM_OP_MULMOD] = R_ANAL_OP_TYPE_MUL,
[EVM_OP_EXP] = R_ANAL_OP_TYPE_MUL,
[EVM_OP_SIGNEXTEND] = R_ANAL_OP_TYPE_CAST,
[EVM_OP_LT] = R_ANAL_OP_TYPE_COND,
[EVM_OP_GT] = R_ANAL_OP_TYPE_COND,
[EVM_OP_SLT] = R_ANAL_OP_TYPE_COND,
[EVM_OP_SGT] = R_ANAL_OP_TYPE_COND,
[EVM_OP_EQ] = R_ANAL_OP_TYPE_CMP,
[EVM_OP_ISZERO] = R_ANAL_OP_TYPE_CMP,
[EVM_OP_AND] = R_ANAL_OP_TYPE_AND,
[EVM_OP_OR] = R_ANAL_OP_TYPE_OR,
[EVM_OP_XOR] = R_ANAL_OP_TYPE_XOR,
[EVM_OP_NOT] = R_ANAL_OP_TYPE_NOT,
[EVM_OP_BYTE] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_SHA3] = R_ANAL_OP_TYPE_CRYPTO,
[EVM_OP_ADDRESS] = R_ANAL_OP_TYPE_CRYPTO,
[EVM_OP_BALANCE] = R_ANAL_OP_TYPE_CRYPTO,
[EVM_OP_ORIGIN] = R_ANAL_OP_TYPE_CRYPTO,
[EVM_OP_CALLER] = R_ANAL_OP_TYPE_CRYPTO,
[EVM_OP_CALLVALUE] = R_ANAL_OP_TYPE_CRYPTO,
[EVM_OP_CALLDATALOAD] = R_ANAL_OP_TYPE_CRYPTO,
[EVM_OP_CALLDATASIZE] = R_ANAL_OP_TYPE_CRYPTO,
[EVM_OP_CALLDATACOPY] = R_ANAL_OP_TYPE_CRYPTO,
[EVM_OP_CODESIZE] = R_ANAL_OP_TYPE_CRYPTO,
[EVM_OP_CODECOPY] = R_ANAL_OP_TYPE_CRYPTO,
[EVM_OP_GASPRICE] = R_ANAL_OP_TYPE_CRYPTO,
[EVM_OP_EXTCODESIZE] = R_ANAL_OP_TYPE_CRYPTO,
[EVM_OP_EXTCODECOPY] = R_ANAL_OP_TYPE_CRYPTO,
[EVM_OP_RETURNDATASIZE] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_RETURNDATACOPY] = R_ANAL_OP_TYPE_STORE,
[EVM_OP_BLOCKHASH] = R_ANAL_OP_TYPE_CRYPTO,
[EVM_OP_COINBASE] = R_ANAL_OP_TYPE_CRYPTO,
[EVM_OP_TIMESTAMP] = R_ANAL_OP_TYPE_CRYPTO,
[EVM_OP_NUMBER] = R_ANAL_OP_TYPE_CRYPTO,
[EVM_OP_DIFFICULTY] = R_ANAL_OP_TYPE_CRYPTO,
[EVM_OP_GASLIMIT] = R_ANAL_OP_TYPE_CRYPTO,
[EVM_OP_POP] = R_ANAL_OP_TYPE_POP,
[EVM_OP_MLOAD] = R_ANAL_OP_TYPE_LOAD,
[EVM_OP_MSTORE] = R_ANAL_OP_TYPE_STORE,
[EVM_OP_MSTORE8] = R_ANAL_OP_TYPE_STORE,
[EVM_OP_SLOAD] = R_ANAL_OP_TYPE_LOAD,
[EVM_OP_SSTORE] = R_ANAL_OP_TYPE_STORE,
[EVM_OP_JUMP] = R_ANAL_OP_TYPE_JMP,
[EVM_OP_JUMPI] = R_ANAL_OP_TYPE_JMP,
[EVM_OP_PC] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_MSIZE] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_GAS] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_JUMPDEST] = R_ANAL_OP_TYPE_NOP,
[EVM_OP_PUSH1] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH2] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH3] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH4] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH5] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH6] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH7] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH8] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH9] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH10] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH11] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH12] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH13] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH14] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH15] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH16] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH17] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH18] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH19] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH20] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH21] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH22] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH23] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH24] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH25] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH26] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH27] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH28] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH29] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH30] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH31] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_PUSH32] = R_ANAL_OP_TYPE_PUSH,
[EVM_OP_DUP1] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_DUP2] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_DUP3] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_DUP4] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_DUP5] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_DUP6] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_DUP7] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_DUP8] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_DUP9] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_DUP10] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_DUP11] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_DUP12] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_DUP13] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_DUP14] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_DUP15] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_DUP16] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_SWAP1] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_SWAP2] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_SWAP3] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_SWAP4] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_SWAP5] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_SWAP6] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_SWAP7] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_SWAP8] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_SWAP9] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_SWAP10] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_SWAP11] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_SWAP12] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_SWAP13] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_SWAP14] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_SWAP15] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_SWAP16] = R_ANAL_OP_TYPE_MOV,
[EVM_OP_LOG0] = R_ANAL_OP_TYPE_TRAP,
[EVM_OP_LOG1] = R_ANAL_OP_TYPE_TRAP,
[EVM_OP_LOG2] = R_ANAL_OP_TYPE_TRAP,
[EVM_OP_LOG3] = R_ANAL_OP_TYPE_TRAP,
[EVM_OP_LOG4] = R_ANAL_OP_TYPE_TRAP,
[EVM_OP_CREATE] = R_ANAL_OP_TYPE_CRYPTO,
[EVM_OP_CALL] = R_ANAL_OP_TYPE_CRYPTO,
[EVM_OP_CALLCODE] = R_ANAL_OP_TYPE_CRYPTO,
[EVM_OP_RETURN] = R_ANAL_OP_TYPE_RET,
[EVM_OP_DELEGATECALL] = R_ANAL_OP_TYPE_CRYPTO,
[EVM_OP_REVERT] = R_ANAL_OP_TYPE_RET,
[EVM_OP_SELFDESTRUCT] = R_ANAL_OP_TYPE_CRYPTO,
};
struct evm_sigs_info {
RIO *rio;
RIODesc *riodesc;
ut8 *contents;
size_t contents_len;
json_t *root;
Sdb *sigs_db;
Sdb *found_sigs_db;
};
static struct evm_sigs_info *sigs_info = 0;
static int evm_oplen(ut8 opcode) {
int ret;
const EvmOpDef *opdef = &opcodes[opcode];
if (opdef->txt) {
return opdef->len;
}
switch (opcode) {
case EVM_OP_PUSH1:
case EVM_OP_PUSH2:
case EVM_OP_PUSH3:
case EVM_OP_PUSH4:
case EVM_OP_PUSH5:
case EVM_OP_PUSH6:
case EVM_OP_PUSH7:
case EVM_OP_PUSH8:
case EVM_OP_PUSH9:
case EVM_OP_PUSH10:
case EVM_OP_PUSH11:
case EVM_OP_PUSH12:
case EVM_OP_PUSH13:
case EVM_OP_PUSH14:
case EVM_OP_PUSH15:
case EVM_OP_PUSH16:
case EVM_OP_PUSH17:
case EVM_OP_PUSH18:
case EVM_OP_PUSH19:
case EVM_OP_PUSH20:
case EVM_OP_PUSH21:
case EVM_OP_PUSH22:
case EVM_OP_PUSH23:
case EVM_OP_PUSH24:
case EVM_OP_PUSH25:
case EVM_OP_PUSH26:
case EVM_OP_PUSH27:
case EVM_OP_PUSH28:
case EVM_OP_PUSH29:
case EVM_OP_PUSH30:
case EVM_OP_PUSH31:
case EVM_OP_PUSH32:
{
int pushSize = opcode - EVM_OP_PUSH1;
/*
op->imm = 0;
for (i = 0; i < pushSize + 1; i++) {
op->imm <<= 8;
op->imm |= buf[i + 1];
}
settxtf (op, "push%d 0x%x", pushSize + 1, op->imm);
*/
ret = 2 + pushSize;
}
break;
case EVM_OP_DUP1:
case EVM_OP_DUP2:
case EVM_OP_DUP3:
case EVM_OP_DUP4:
case EVM_OP_DUP5:
case EVM_OP_DUP6:
case EVM_OP_DUP7:
case EVM_OP_DUP8:
case EVM_OP_DUP9:
case EVM_OP_DUP10:
case EVM_OP_DUP11:
case EVM_OP_DUP12:
case EVM_OP_DUP13:
case EVM_OP_DUP14:
case EVM_OP_DUP15:
case EVM_OP_DUP16:
{
// settxtf (op, "dup%d", dupSize);
ret = 1;
}
break;
case EVM_OP_SWAP1:
case EVM_OP_SWAP2:
case EVM_OP_SWAP3:
case EVM_OP_SWAP4:
case EVM_OP_SWAP5:
case EVM_OP_SWAP6:
case EVM_OP_SWAP7:
case EVM_OP_SWAP8:
case EVM_OP_SWAP9:
case EVM_OP_SWAP10:
case EVM_OP_SWAP11:
case EVM_OP_SWAP12:
case EVM_OP_SWAP13:
case EVM_OP_SWAP14:
case EVM_OP_SWAP15:
case EVM_OP_SWAP16:
{
// settxtf (op, "swap%d", swapSize);
ret = 1;
}
break;
case EVM_OP_LOG0:
case EVM_OP_LOG1:
case EVM_OP_LOG2:
case EVM_OP_LOG3:
case EVM_OP_LOG4:
{
// settxtf (op, "log%d", logSize);
ret = 1;
}
break;
default:
// settxtf (op, "invalid");
ret = 1;
break;
}
return ret;
}
/* Jumps/calls in EVM are done via first pushing dst value
* on the stack, and then calling a jump/jumpi instruction, for example:
* 0x0000000d push 0x42
* 0x0000000f jumpi
*
* we are storing the value in push instruction to db, but not at the
* addr of the push instruction, but at the addr of next jumpi instruction.
* So in our example we are inserting (0xf, 0x42)
*/
static int evm_add_push_to_db(ut64 addr, const ut8 *buf, int len) {
ut8 opcode = buf[0];
ut64 next_cmd_addr = addr + evm_oplen (opcode);
ut64 dst_addr = 0;
size_t i, push_size;
char key[16] = {0}, value[16] = {0};
push_size = opcode - EVM_OP_PUSH1;
for (i = 0; i < push_size + 1; i++) {
dst_addr <<= 8;
dst_addr |= buf[i + 1];
}
if (evm_ai) {
snprintf (key, sizeof(key) - 1, "%08x", (unsigned) next_cmd_addr);
snprintf (value, sizeof(value) - 1, "%08x", (unsigned) dst_addr);
sdb_set (evm_ai->pushs_db, key, value, 0);
}
return 0;
}
static st64 evm_get_jmp_addr(ut64 addr) {
char key[16] = {0};
const char *value;
unsigned ret;
snprintf (key, sizeof(key) - 1, "%08x", (unsigned) addr);
value = sdb_const_get (evm_ai->pushs_db, key, 0);
if (value) {
sscanf(value, "%08x", &ret);
return ret;
} else {
return -1;
}
}
static int evm_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
ut32 *push4op;
st64 ret;
ut8 opcode;
char sig[64] = {0};
opcode = buf[0];
memset (op, 0, sizeof(RAnalOp));
op->type = opcodes_types[opcode];
if (!op->type) {
op->type = R_ANAL_OP_TYPE_UNK;
}
op->addr = addr;
op->jump = op->fail = -1;
op->ptr = op->val = -1;
r_strbuf_init (&op->esil);
switch (opcode) {
case EVM_OP_JUMP:
case EVM_OP_JUMPI:
op->fail = addr + 1;
if (opcode == EVM_OP_JUMP) {
op->type = R_ANAL_OP_TYPE_JMP;
} else {
op->type = R_ANAL_OP_TYPE_CJMP;
}
ret = evm_get_jmp_addr(addr);
if (ret >= 0) {
op->jump = ret;
} else {
op->type = R_ANAL_OP_TYPE_UJMP;
}
op->eob = true;
break;
case EVM_OP_PC:
break;
case EVM_OP_MSIZE:
break;
case EVM_OP_GAS:
break;
case EVM_OP_JUMPDEST:
break;
case EVM_OP_PUSH1:
case EVM_OP_PUSH2:
case EVM_OP_PUSH3:
case EVM_OP_PUSH4:
evm_add_push_to_db (addr, buf, len);
if (opcode == EVM_OP_PUSH4 && sigs_info && sigs_info->sigs_db) {
push4op = (ut32 *)(buf + 1);
snprintf(sig, sizeof(sig) - 1, "0x%08x", ntohl((unsigned)(*push4op)));
const char *data = sdb_const_get (sigs_info->sigs_db, sig, 0);
if (data) {
char addr_str[16];
char value[1024];
snprintf(addr_str, sizeof(addr_str) - 1, "0x%08x", (unsigned int)addr);
addr_str[16 - 1] = '\0';
snprintf(value, sizeof(value) - 1, "calls a function %s with signature %s",
data, sig);
value[1023] = '\0';
sdb_set(sigs_info->found_sigs_db, addr_str, value, 0);
r_meta_set_string(anal, 'C', addr, data);
}
}
break;
default:
break;
}
op->size = evm_oplen (opcode);
return evm_oplen (opcode);
}
static int evm_load_symbol_map (RAnal *anal, const char *file) {
size_t i;
int ret = 0;
bool rc;
if (sigs_info) {
r_io_close (sigs_info->rio);
r_io_free (sigs_info->rio);
sdb_free (sigs_info->sigs_db);
sdb_free (sigs_info->found_sigs_db);
free (sigs_info->contents);
free (sigs_info);
}
sigs_info = malloc(sizeof(*sigs_info));
memset(sigs_info, 0, sizeof(*sigs_info));
if (!sigs_info) {
ret = -1;
goto out;
}
if (sigs_info) {
sigs_info->rio = r_io_new ();
sigs_info->riodesc = r_io_open (sigs_info->rio, file, R_PERM_R, 0644);
if (!sigs_info->riodesc) {
printf ("Failed to open %s: %s\n", file, strerror (errno));
ret = -1;
goto out_free;
} else {
json_error_t error;
sigs_info->contents_len = r_io_size (sigs_info->rio);
sigs_info->contents = malloc(sigs_info->contents_len + 1);
rc = r_io_read (sigs_info->rio, sigs_info->contents, sigs_info->contents_len);
if (rc == false) {
printf ("Failed to read file\n");
ret = -1;
goto out_close;
}
sigs_info->contents[sigs_info->contents_len] = '\0';
sigs_info->root = json_loads ((const char*)sigs_info->contents, 0, &error);
if (!sigs_info->root) {
printf ("Failed to parse json document on line %d: %s\n",
error.line, error.text);
} else {
printf ("Parsed successfully\n");
sigs_info->sigs_db = sdb_new0 ();
sigs_info->found_sigs_db = sdb_new0 ();
for (i = 0; i < json_array_size (sigs_info->root); i++) {
json_t *elem, *sig, *args, *name;
char *name_str, *sig_str, *args_str, *value;
size_t value_size;
elem = json_array_get (sigs_info->root, i);
if (!elem) {
continue;
}
sig = json_object_get (elem, "sig");
name = json_object_get (elem, "name");
args = json_object_get (elem, "args");
if (!sig || !name || !args) {
continue;
}
sig_str = strdup (json_string_value (sig));
name_str = strdup (json_string_value (name));
args_str = strdup (json_string_value (args));
value_size = strlen(name_str) + strlen(args_str) + 8;
value = malloc(sizeof(char) * value_size);
snprintf(value, value_size - 1, "%s(%s)", name_str, args_str);
sdb_set (sigs_info->sigs_db, sig_str, value, 0);
free (value);
free (args_str);
free (name_str);
free (sig_str);
}
json_decref (sigs_info->root);
free (sigs_info->contents);
sigs_info->root = 0;
sigs_info->contents = 0;
}
}
}
goto out;
out_close:
r_io_close (sigs_info->rio);
out_free:
r_io_free (sigs_info->rio);
sigs_info->rio = NULL;
free (sigs_info);
sigs_info = NULL;
out:
return ret;
}
static int evm_list_found_symbols_cb (void *user, const char *k, const char *v) {
printf ("%s | %s\n", k, v);
return 1;
}
static int evm_list_found_symbols (RAnal *anal) {
if (sigs_info && sigs_info->found_sigs_db) {
sdb_foreach (sigs_info->found_sigs_db, evm_list_found_symbols_cb, NULL);
}
return 0;
}
static void evm_cmd_ext_help () {
printf ("a!l <file path> - Read a JSON file with function signatures\n"
"a!f - List found function signatures\n"
"a!h - Show this help message\n");
}
static int evm_cmd_ext (RAnal *anal, const char *input) {
const char *arg = input;
arg++;
while (*arg == ' ') {
arg++;
}
switch (input[0]) {
case 'l':
printf("here %s\n", arg);
evm_load_symbol_map (anal, arg);
break;
case 'f':
evm_list_found_symbols (anal);
break;
case 'h':
default:
evm_cmd_ext_help ();
return -1;
}
return 0;
}
static int evm_anal_init (void *user) {
if (!evm_ai) {
evm_ai = (struct evm_anal_info*)malloc (sizeof(*evm_ai));
evm_ai->pushs_db = sdb_new0 ();
}
return 0;
}
static int evm_anal_fini (void *user) {
if (evm_ai) {
if (evm_ai->pushs_db) {
sdb_free (evm_ai->pushs_db);
}
free(evm_ai);
evm_ai = NULL;
}
return 0;
}
RAnalPlugin r_anal_plugin_evm = {
.name = "evm",
.desc = "ETHEREUM VM code analysis plugin",
.license = "LGPL3",
.arch = "evm",
.bits = 8,
.op = evm_op,
.init = evm_anal_init,
.fini = evm_anal_fini,
.esil = false,
.cmd_ext = evm_cmd_ext,
};
#ifndef CORELIB
struct r_lib_struct_t radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.data = &r_anal_plugin_evm,
.version = R2_VERSION
};
#endif
File renamed without changes.
+1 -1
View File
@@ -515,7 +515,7 @@ struct r_anal_plugin_t r_anal_plugin_x86_simple = {
.name = "x86.simple",
.desc = "X86 analysis plugin",
.license = "LGPL3",
.arch = R_SYS_ARCH_X86,
.arch = "x86",
.bits = 32,
.init = NULL,
.fini = NULL,
+790
View File
@@ -0,0 +1,790 @@
/* radare - LGPL - Copyright 2009-2016 - nibble, pancake */
#include <r_lib.h>
#include <r_types.h>
#include <r_anal.h>
#include <r_util.h>
#include "udis86/types.h"
#include "udis86/extern.h"
#include "esil.h"
static st64 getval(ud_operand_t *op);
// XXX Copypasta from udis
#define UD_REG_TAB_SIZE (sizeof (ud_reg_tab)/sizeof (*ud_reg_tab))
static const char* ud_reg_tab[] = {
"al", "cl", "dl", "bl",
"ah", "ch", "dh", "bh",
"spl", "bpl", "sil", "dil",
"r8b", "r9b", "r10b", "r11b",
"r12b", "r13b", "r14b", "r15b",
"ax", "cx", "dx", "bx",
"sp", "bp", "si", "di",
"r8w", "r9w", "r10w", "r11w",
"r12w", "r13w", "r14w", "r15w",
"eax", "ecx", "edx", "ebx",
"esp", "ebp", "esi", "edi",
"r8d", "r9d", "r10d", "r11d",
"r12d", "r13d", "r14d", "r15d",
"rax", "rcx", "rdx", "rbx",
"rsp", "rbp", "rsi", "rdi",
"r8", "r9", "r10", "r11",
"r12", "r13", "r14", "r15",
"es", "cs", "ss", "ds",
"fs", "gs",
"cr0", "cr1", "cr2", "cr3",
"cr4", "cr5", "cr6", "cr7",
"cr8", "cr9", "cr10", "cr11",
"cr12", "cr13", "cr14", "cr15",
"dr0", "dr1", "dr2", "dr3",
"dr4", "dr5", "dr6", "dr7",
"dr8", "dr9", "dr10", "dr11",
"dr12", "dr13", "dr14", "dr15",
"mm0", "mm1", "mm2", "mm3",
"mm4", "mm5", "mm6", "mm7",
"st0", "st1", "st2", "st3",
"st4", "st5", "st6", "st7",
"xmm0", "xmm1", "xmm2", "xmm3",
"xmm4", "xmm5", "xmm6", "xmm7",
"xmm8", "xmm9", "xmm10", "xmm11",
"xmm12","xmm13", "xmm14", "xmm15",
"ymm0", "ymm1", "ymm2", "ymm3",
"ymm4", "ymm5", "ymm6", "ymm7",
"ymm8", "ymm9", "ymm10", "ymm11",
"ymm12","ymm13", "ymm14", "ymm15",
"rip"
};
static int getarg(char *src, struct ud *u, st64 mask, int idx, int regsz) {
ud_operand_t *op = &u->operand[idx];
st64 n;
src[0] = 0;
if (!mask) mask = UT64_MAX;
switch (op->type) {
case UD_OP_PTR:
case UD_OP_CONST:
case UD_OP_JIMM:
case UD_OP_IMM:
n = getval (op) & mask;
//mask = UT64_MAX; // uhm?
if (op->type == UD_OP_JIMM) n += u->pc;
if (n>=0 && n<256)
sprintf (src, "%"PFMT64d, n & mask);
else sprintf (src, "0x%"PFMT64x, n&mask);
break;
case UD_OP_REG:
idx = op->base-UD_R_AL;
if (idx>=0 && idx<UD_REG_TAB_SIZE)
strcpy (src, ud_reg_tab[idx]);
break;
case UD_OP_MEM:
n = getval (op);
// TODO ->scale
if (op->base != UD_NONE) {
idx = op->base-UD_R_AL;
if (idx>=0 && idx<UD_REG_TAB_SIZE) {
sprintf (src, "%s", ud_reg_tab[idx]);
src += strlen (src);
if (op->index != UD_NONE) {
idx = op->index - UD_R_AL;
if (idx >= 0 && idx < UD_REG_TAB_SIZE) {
sprintf (src, ",%d,%s,*,+",
op->scale, ud_reg_tab[idx]);
}
src += strlen (src);
}
if (u->mnemonic == UD_Ilea) {
if ((st16)n>0) sprintf (src, ",%"PFMT64d",+", n);
else if ((st16)n<0) sprintf (src, ",%"PFMT64d",-", UT32_MAX-n);
} else if ((st16)n >= -256 && (st16)n < 256) {
char nb = (char)n;
char absn = ((st16)nb<0)? -nb: nb;
if (n==0) sprintf (src, ",[%d]", regsz);
else sprintf (src, ",%d,%c,[%d]",
absn, nb<0?'-':'+', regsz);
} else {
sprintf (src, ",0x%"PFMT64x",+,[%d]",
mask & n, regsz);
}
} else {
/* If UDis86 works properly, it will never reach this point.
* Only useful for debug purposes ("unknown reg" is clearer
* than an empty string, right?)
*/
}
} else sprintf (src, "0x%"PFMT64x",[%d]", n & mask, regsz);
break;
default:
break;
}
return 0;
}
static st64 getval(ud_operand_t *op) {
int bits = op->size;
switch (op->type) {
case UD_OP_PTR:
return (op->lval.ptr.seg<<4) + (op->lval.ptr.off & 0xFFFF);
default:
break;
}
if (!bits) bits = 32;
if (op->signed_lval) { // TODO: honor sign
switch (bits) {
case 8: return (st64)(char) (op->lval.sbyte);
case 16: return (st64)(short) op->lval.uword;
case 32: return (ut64)(ut32)(op->lval.udword&UT32_MAX);
case 64: return op->lval.uqword;
}
} else {
switch (bits) {
case 8: return (st64)(char)(255-op->lval.sbyte); // XXX?
case 16: return (st64)(short) (op->lval.uword& UT16_MAX);
case 32: return (ut64)(ut32)(op->lval.udword & UT32_MAX);
case 64: return op->lval.uqword;
}
}
return 0LL;
}
int x86_udis86_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len) {
const char *pc = anal->bits==64? "rip": anal->bits==32? "eip": "ip";
const char *sp = anal->bits==64? "rsp": anal->bits==32? "esp": "sp";
const char *bp = anal->bits==64? "rbp": anal->bits==32? "ebp": "bp";
int delta, oplen, regsz = 4;
char str[64], src[32], dst[32];
struct ud u;
switch (anal->bits) {
case 64: regsz = 8; break;
case 16: regsz = 2; break;
default:
case 32: regsz = 4; break;
}
UDis86Esil *handler;
UDis86OPInfo info = {0, anal->bits, (1LL << anal->bits) - 1, regsz, 0, pc, sp, bp};
memset (op, '\0', sizeof (RAnalOp));
op->addr = addr;
op->jump = op->fail = -1;
op->ptr = op->val = -1;
ud_init (&u);
ud_set_pc (&u, addr);
ud_set_mode (&u, anal->bits);
ud_set_syntax (&u, NULL);
ud_set_input_buffer (&u, data, len);
ud_disassemble (&u);
op->id = u.mnemonic;
oplen = op->size = ud_insn_len (&u);
r_strbuf_init (&op->esil);
const bool decode = true;
if (decode && (handler = udis86_esil_get_handler (u.mnemonic))) {
info.oplen = oplen;
//if (anal->bits==32)
info.bitmask = UT32_MAX;
if (handler->argc > 0) {
info.n = getval (u.operand);
getarg (dst, &u, info.bitmask, 0, regsz);
if (handler->argc > 1) {
getarg (src, &u, info.bitmask, 1, regsz);
if (handler->argc > 2)
getarg (str, &u, info.bitmask, 2, regsz);
}
}
handler->callback (&info, op, dst, src, str);
}
#if 0
u->pfx_seg = 0;
u->pfx_opr = 0;
u->pfx_adr = 0;
u->pfx_lock = 0;
u->pfx_repne = 0;
u->pfx_rep = 0;
u->pfx_repe = 0;
u->pfx_rex = 0;
u->pfx_str = 0;
#endif
op->prefix = 0;
if (u.pfx_rep) op->prefix |= R_ANAL_OP_PREFIX_REP;
if (u.pfx_repe) op->prefix |= R_ANAL_OP_PREFIX_REP;
if (u.pfx_repne) op->prefix |= R_ANAL_OP_PREFIX_REPNE;
if (u.pfx_lock) op->prefix |= R_ANAL_OP_PREFIX_LOCK;
switch (u.mnemonic) {
case UD_Iinvalid:
oplen = op->size = -1;
return -1;
break;
case UD_Itest:
case UD_Icmp:
op->type = R_ANAL_OP_TYPE_CMP;
// TODO: support 2nd parameter too?
switch (u.operand[0].type) {
case UD_OP_MEM:
op->refptr = u.operand[0].size /8;
switch (u.operand[0].base) {
case UD_R_RIP:
// Self modifying code? relative local vars
switch (u.operand[1].size) {
case 8:
case 16:
case 32: delta = u.operand[1].lval.udword; break;
case 64: delta = u.operand[1].lval.uqword; break;
default: delta = u.operand[1].lval.udword; break;
}
op->ptr = addr + oplen + delta;
break;
case UD_R_RBP:
op->stackop = R_ANAL_STACK_SET;
op->ptr = getval (&u.operand[0]); //-(st64)u.operand[0].lval.sbyte; //getval (&u.operand[0]);
op->ptr = (st64)((char)u.operand[0].lval.sbyte); //getval (&u.operand[0]);
// if positive = arg
// if negative = var
break;
default:
op->ptr = getval (&u.operand[0]);
break;
}
break;
case UD_OP_IMM:
op->ptr = getval (&u.operand[0]);
default:
break;
}
switch (u.operand[1].type) {
case UD_OP_MEM:
op->refptr = u.operand[0].size /8;
switch (u.operand[1].base) {
case UD_R_RIP:
// Self modifying code? relative local vars
delta = u.operand[1].lval.uword;
op->ptr = addr + oplen + delta;
break;
case UD_R_RBP:
op->stackop = R_ANAL_STACK_SET;
op->ptr = getval (&u.operand[1]); //-(st64)u.operand[0].lval.sbyte; //getval (&u.operand[0]);
op->ptr = (st64)((char)u.operand[1].lval.sbyte); //getval (&u.operand[0]);
// if positive = arg
// if negative = var
break;
default:
op->ptr = getval (&u.operand[1]);
break;
}
break;
case UD_OP_IMM:
op->ptr = getval (&u.operand[0]);
default:
break;
}
break;
case UD_Isalc: // ??
// al = cf
break;
case UD_Ixor:
op->type = R_ANAL_OP_TYPE_XOR;
break;
case UD_Ior:
op->type = R_ANAL_OP_TYPE_OR;
break;
case UD_Iand:
op->type = R_ANAL_OP_TYPE_AND;
break;
case UD_Isar:
op->type = R_ANAL_OP_TYPE_SAR;
break;
// XXX: sal ?!?
case UD_Ishl:
op->type = R_ANAL_OP_TYPE_SHL;
break;
case UD_Ishr:
op->type = R_ANAL_OP_TYPE_SHR;
break;
case UD_Irol:
op->type = R_ANAL_OP_TYPE_ROL;
break;
case UD_Iror:
op->type = R_ANAL_OP_TYPE_ROR;
break;
case UD_Iint1:
case UD_Iint3:
op->type = R_ANAL_OP_TYPE_TRAP;
break;
case UD_Iint:
op->type = R_ANAL_OP_TYPE_SWI;
op->val = u.operand[0].lval.uword;
break;
case UD_Ilea:
case UD_Imov:
op->type = R_ANAL_OP_TYPE_MOV;
switch (u.operand[0].type) {
case UD_OP_MEM:
op->refptr = u.operand[0].size/8;
switch (u.operand[0].base) {
case UD_R_RIP:
// Self modifying code? relative local vars
// op->type == 9
//switch (op->size) {
switch (u.operand[0].size) {
case 8:
case 16:
case 32: delta = u.operand[0].lval.udword; break;
case 64: delta = u.operand[0].lval.uqword; break;
default: delta = u.operand[0].lval.udword; break;
}
op->ptr = addr + oplen + delta;
break;
case UD_R_RBP:
op->stackop = R_ANAL_STACK_SET;
op->ptr = getval (&u.operand[0]); //-(st64)u.operand[0].lval.sbyte; //getval (&u.operand[0]);
// op->ptr = (st64)((char)u.operand[0].lval.sbyte); //getval (&u.operand[0]);
// if positive = arg
// if negative = var
break;
default:
/* nothing to do here yet */
op->ptr = getval (&u.operand[1]);
break;
}
break;
default:
switch (u.operand[1].type) {
case UD_OP_MEM:
op->refptr = u.operand[1].size /8;
switch (u.operand[1].base) {
case UD_R_RIP:
switch (u.operand[1].size) {
case 8:
case 16:
case 32: delta = u.operand[1].lval.udword; break;
case 64: delta = u.operand[1].lval.uqword; break;
default: delta = u.operand[1].lval.udword; break;
}
op->ptr = addr + oplen + delta;
break;
case UD_R_RBP:
op->stackop = R_ANAL_STACK_GET;
op->ptr = getval (&u.operand[1]);
// op->ptr = (st64)((char)u.operand[1].lval.sbyte); //getval (&u.operand[0]);
// if positive = arg
// if negative = var
break;
default:
/* nothing to do here yet */
op->ptr = getval (&u.operand[1]); //-(st64)u.operand[0].lval.sbyte; //getval (&u.operand[0]);
break;
}
break;
default:
op->ptr = getval (&u.operand[1]);
// XX
break;
}
break;
}
op->stackptr = regsz;
break;
case UD_Ipush:
case UD_Ipusha:
case UD_Ipushad:
case UD_Ipushfq:
case UD_Ipushfd:
case UD_Ipushfw:
switch (u.operand[0].type) {
case UD_OP_CONST:
case UD_OP_JIMM:
case UD_OP_IMM:
op->type = R_ANAL_OP_TYPE_PUSH;
op->ptr = getval (&u.operand[0]);
break;
case UD_OP_REG:
case UD_OP_PTR:
case UD_OP_MEM:
default:
op->type = R_ANAL_OP_TYPE_UPUSH;
op->ptr = 0;
break;
}
op->stackop = R_ANAL_STACK_INC;
op->stackptr = regsz;
break;
case UD_Ipop:
case UD_Ipopa:
case UD_Ipopad:
case UD_Ipopfw:
case UD_Ipopfd:
case UD_Ipopfq:
op->type = R_ANAL_OP_TYPE_POP;
op->stackop = R_ANAL_STACK_INC;
op->stackptr = -regsz;
break;
case UD_Ileave:
op->type = R_ANAL_OP_TYPE_MOV;
op->stackop = R_ANAL_STACK_INC;
op->stackptr = -regsz;
break;
case UD_Iadd:
case UD_Isub:
op->type = (u.mnemonic==UD_Iadd)? R_ANAL_OP_TYPE_ADD: R_ANAL_OP_TYPE_SUB;
op->ptr = 0;
op->stackptr = 0;
if (u.operand[0].type == UD_OP_REG) {
if (u.operand[0].base == UD_R_RSP) {
int o = (int)getval (&u.operand[1]);
op->stackop = R_ANAL_STACK_INC;
if (u.mnemonic ==UD_Iadd) {
op->stackptr = -o;
} else {
op->stackptr = o;
}
}
if (u.operand[1].type != UD_OP_REG)
op->val = getval (&u.operand[1]);
}
op->stackptr = 4;
break;
case UD_Iadc:
case UD_Iinc:
op->type = R_ANAL_OP_TYPE_ADD;
break;
case UD_Isbb:
case UD_Idec:
op->type = R_ANAL_OP_TYPE_SUB;
break;
case UD_Ijmp:
switch (u.operand[0].type) {
case UD_OP_MEM:
op->ptr = getval (&u.operand[0]);
op->type = R_ANAL_OP_TYPE_UJMP;
break;
case UD_OP_REG:
op->type = R_ANAL_OP_TYPE_UJMP;
break;
default:
op->type = R_ANAL_OP_TYPE_JMP;
if (u.operand[0].type==UD_OP_PTR) {
op->jump = getval (&u.operand[0]);
} else {
if (anal->bits==16) {
// honor segment
op->jump = (addr&0xf0000) + oplen + \
((((addr&0xffff)+getval (&u.operand[0]))&0xffff));
} else {
op->jump = addr + oplen + (int)getval (&u.operand[0]);
}
}
}
break;
case UD_Ije:
case UD_Ijne:
case UD_Ijb:
case UD_Ijbe:
case UD_Ija:
case UD_Ijae:
case UD_Ijs:
case UD_Ijns:
case UD_Ijo:
case UD_Ijno:
case UD_Ijp:
case UD_Ijnp:
case UD_Ijl:
case UD_Ijge:
case UD_Ijle:
case UD_Ijg:
case UD_Ijcxz:
case UD_Iloop:
op->type = R_ANAL_OP_TYPE_CJMP;
op->jump = addr + oplen + (int)getval (&u.operand[0]);
op->fail = addr+oplen;
break;
case UD_Icall:
op->type = R_ANAL_OP_TYPE_CALL;
switch (u.operand[0].type) {
case UD_OP_REG:
op->type = R_ANAL_OP_TYPE_UCALL;
op->jump = 0; // EAX, EBX, ... use anal->reg
break;
case UD_OP_PTR:
op->jump = (int)getval (&u.operand[0]);
break;
case UD_OP_IMM:
case UD_OP_MEM:
default:
op->jump = addr + oplen + (int)getval (&u.operand[0]);
}
op->fail = addr + oplen;
break;
case UD_Ihlt:
op->type = R_ANAL_OP_TYPE_TRAP; //HALT;
break;
case UD_Iin:
case UD_Iout:
op->type = R_ANAL_OP_TYPE_IO;
break;
case UD_Iret:
case UD_Iiretd:
case UD_Iretf:
case UD_Isysret:
op->type = R_ANAL_OP_TYPE_RET;
op->stackop = R_ANAL_STACK_INC;
op->stackptr = -regsz;
break;
case UD_Isyscall:
op->type = R_ANAL_OP_TYPE_SWI;
break;
case UD_Inop:
op->type = R_ANAL_OP_TYPE_NOP;
break;
default:
break;
}
return oplen;
}
static int set_reg_profile(RAnal *anal) {
const char *p = NULL;
switch (anal->bits) {
case 16: p =
"=PC ip\n"
"=SP sp\n"
"=BP bp\n"
"=A0 ax\n"
"=A1 bx\n"
"=A2 cx\n"
"=A3 di\n"
"gpr ip .16 48 0\n"
"gpr ax .16 24 0\n"
"gpr ah .8 24 0\n"
"gpr al .8 25 0\n"
"gpr bx .16 0 0\n"
"gpr bh .8 1 0\n"
"gpr bl .8 0 0\n"
"gpr cx .16 4 0\n"
"gpr ch .8 5 0\n"
"gpr cl .8 4 0\n"
"gpr dx .16 8 0\n"
"gpr dh .8 9 0\n"
"gpr dl .8 8 0\n"
"gpr sp .16 60 0\n"
"gpr bp .16 20 0\n"
"gpr si .16 12 0\n"
"gpr di .16 16 0\n"
"seg cs .16 52 0\n"
"gpr flags .16 56 0\n"
"gpr cf .1 .448 0\n"
"flg pf .1 .449 0\n"
"flg af .1 .450 0\n"
"gpr zf .1 .451 0\n"
"gpr sf .1 .452 0\n"
"flg tf .1 .453 0\n"
"flg if .1 .454 0\n"
"flg df .1 .455 0\n"
"flg of .1 .456 0\n"
"flg flag_r .1 .457 0\n";
#if 0
"drx dr0 .32 0 0\n"
"drx dr1 .32 4 0\n"
"drx dr2 .32 8 0\n"
"drx dr3 .32 12 0\n"
//"drx dr4 .32 16 0\n"
//"drx dr5 .32 20 0\n"
"drx dr6 .32 24 0\n"
"drx dr7 .32 28 0\n"
#endif
break;
case 32: p =
"=PC eip\n"
"=SP esp\n"
"=BP ebp\n"
"=A0 eax\n"
"=A1 ebx\n"
"=A2 ecx\n"
"=A3 edi\n"
"gpr eip .32 48 0\n"
"gpr ip .16 48 0\n"
"gpr oeax .32 44 0\n"
"gpr eax .32 24 0\n"
"gpr ax .16 24 0\n"
"gpr ah .8 24 0\n"
"gpr al .8 25 0\n"
"gpr ebx .32 0 0\n"
"gpr bx .16 0 0\n"
"gpr bh .8 1 0\n"
"gpr bl .8 0 0\n"
"gpr ecx .32 4 0\n"
"gpr cx .16 4 0\n"
"gpr ch .8 5 0\n"
"gpr cl .8 4 0\n"
"gpr edx .32 8 0\n"
"gpr dx .16 8 0\n"
"gpr dh .8 9 0\n"
"gpr dl .8 8 0\n"
"gpr esp .32 60 0\n"
"gpr sp .16 60 0\n"
"gpr ebp .32 20 0\n"
"gpr bp .16 20 0\n"
"gpr esi .32 12 0\n"
"gpr si .16 12 0\n"
"gpr edi .32 16 0\n"
"gpr di .16 16 0\n"
"seg xfs .32 36 0\n"
"seg xgs .32 40 0\n"
"seg xcs .32 52 0\n"
"seg cs .16 52 0\n"
"seg xss .32 52 0\n"
"gpr eflags .32 56 0 c1p.a.zstido.n.rv\n"
"gpr flags .16 56 0\n"
"gpr cf .1 .448 0\n"
"flg flag_p .1 .449 0\n"
"flg flag_a .1 .450 0\n"
"gpr zf .1 .451 0\n"
"gpr sf .1 .452 0\n"
"flg flag_t .1 .453 0\n"
"flg flag_i .1 .454 0\n"
"flg flag_d .1 .455 0\n"
"flg of .1 .456 0\n"
"flg flag_r .1 .457 0\n"
"drx dr0 .32 0 0\n"
"drx dr1 .32 4 0\n"
"drx dr2 .32 8 0\n"
"drx dr3 .32 12 0\n"
//"drx dr4 .32 16 0\n"
//"drx dr5 .32 20 0\n"
"drx dr6 .32 24 0\n"
"drx dr7 .32 28 0\n";
break;
default: p =
"=PC rip\n"
"=SP rsp\n"
"=BP rbp\n"
"=A0 rax\n"
"=A1 rbx\n"
"=A2 rcx\n"
"=A3 rdx\n"
"# no profile defined for x86-64\n"
"gpr r15 .64 0 0\n"
"gpr r15d .32 0 0\n"
"gpr r15w .16 0 0\n"
"gpr r15b .8 0 0\n"
"gpr r14 .64 8 0\n"
"gpr r14d .32 8 0\n"
"gpr r14w .16 8 0\n"
"gpr r14b .8 8 0\n"
"gpr r13 .64 16 0\n"
"gpr r13d .32 16 0\n"
"gpr r13w .16 16 0\n"
"gpr r13b .8 16 0\n"
"gpr r12 .64 24 0\n"
"gpr r12d .32 24 0\n"
"gpr r12w .16 24 0\n"
"gpr r12b .8 24 0\n"
"gpr rbp .64 32 0\n"
"gpr ebp .32 32 0\n"
"gpr bp .16 32 0\n"
"gpr bpl .8 32 0\n"
"gpr rbx .64 40 0\n"
"gpr ebx .32 40 0\n"
"gpr bx .16 40 0\n"
"gpr bl .8 40 0\n"
"gpr r11 .64 48 0\n"
"gpr r11d .32 48 0\n"
"gpr r11w .16 48 0\n"
"gpr r11b .8 48 0\n"
"gpr r10 .64 56 0\n"
"gpr r10d .32 56 0\n"
"gpr r10w .16 56 0\n"
"gpr r10b .8 56 0\n"
"gpr r9 .64 64 0\n"
"gpr r9d .32 64 0\n"
"gpr r9w .16 64 0\n"
"gpr r9b .8 64 0\n"
"gpr r8 .64 72 0\n"
"gpr r8d .32 72 0\n"
"gpr r8w .16 72 0\n"
"gpr r8b .8 72 0\n"
"gpr rax .64 80 0\n"
"gpr eax .32 80 0\n"
"gpr ax .16 80 0\n"
"gpr al .8 80 0\n"
"gpr rcx .64 88 0\n"
"gpr ecx .32 88 0\n"
"gpr cx .16 88 0\n"
"gpr cl .8 88 0\n"
"gpr rdx .64 96 0\n"
"gpr edx .32 96 0\n"
"gpr dx .16 96 0\n"
"gpr dl .8 96 0\n"
"gpr rsi .64 104 0\n"
"gpr esi .32 104 0\n"
"gpr si .16 104 0\n"
"gpr sil .8 104 0\n"
"gpr rdi .64 112 0\n"
"gpr edi .32 112 0\n"
"gpr di .16 112 0\n"
"gpr dil .8 112 0\n"
"gpr oeax .64 120 0\n"
"gpr rip .64 128 0\n"
"seg cs .64 136 0\n"
//"flg eflags .64 144 0\n"
"gpr eflags .32 144 0 c1p.a.zstido.n.rv\n"
"gpr cf .1 .1152 0\n"
"flg flag_p .1 .1153 0\n"
"flg flag_a .1 .1154 0\n"
"gpr zf .1 .1155 0\n"
"gpr sf .1 .1156 0\n"
"flg flag_t .1 .1157 0\n"
"flg flag_i .1 .1158 0\n"
"flg flag_d .1 .1159 0\n"
"flg of .1 .1160 0\n"
"flg flag_r .1 .1161 0\n"
"gpr rsp .64 152 0\n"
"seg ss .64 160 0\n"
"seg fs_base .64 168 0\n"
"seg gs_base .64 176 0\n"
"seg ds .64 184 0\n"
"seg es .64 192 0\n"
"seg fs .64 200 0\n"
"seg gs .64 208 0\n"
"drx dr0 .32 0 0\n"
"drx dr1 .32 4 0\n"
"drx dr2 .32 8 0\n"
"drx dr3 .32 12 0\n"
"drx dr6 .32 24 0\n"
"drx dr7 .32 28 0\n";
break;
}
return r_reg_set_profile_string (anal->reg, p);
}
RAnalPlugin r_anal_plugin_x86_udis = {
.name = "x86.udis",
.desc = "X86 analysis plugin (udis86 backend)",
.license = "LGPL3",
.arch = "x86",
.esil = true,
.bits = 16|32|64,
.op = &x86_udis86_op,
.set_reg_profile = &set_reg_profile,
};
#ifndef CORELIB
RLibStruct radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.data = &r_anal_plugin_x86_udis,
.version = R2_VERSION
};
#endif
+10
View File
@@ -0,0 +1,10 @@
OBJ_ATOMBIOS=anal_atombios.o
OBJ_ATOMBIOS+=../../asm/arch/atombios/atombios.o
STATIC_OBJ+=${OBJ_ATOMBIOS}
TARGET_ATOMBIOS=anal_atombios.${LIBEXT}
ALL_TARGETS+=${TARGET_ATOMBIOS}
${TARGET_ATOMBIOS}: ${OBJ_ATOMBIOS}
${CC} -g $(call libname,anal_atombios) ${LDFLAGS} ${CFLAGS} -o anal_atombios.${LIBEXT} ${OBJ_ATOMBIOS}
+262
View File
@@ -0,0 +1,262 @@
/* radare - LGPL - Copyright 2013-2018 - batchdrake */
#include <r_lib.h>
#include <r_types.h>
#include <r_anal.h>
#include <r_util.h>
#include "udis86/types.h"
#include "udis86/extern.h"
#include "esil_x86_udis.h"
#define RPN
RPN UDIS86_ESIL (nop, ",");
RPN UDIS86_ESIL (jo, "of,?{,%s,%s,=,}", dst, info->pc);
RPN UDIS86_ESIL (jno, "of,!,?{,%s,%s,}", dst, info->pc);
RPN UDIS86_ESIL (jb, "cf,?{,%s,%s,=,}", dst, info->pc);
RPN UDIS86_ESIL (jae, "cf,?{,%s,%s,=,}", dst, info->pc);
// UDIS86_ESIL (je, "?zf,%s=%s", info->pc, dst);
RPN UDIS86_ESIL (je, "zf,?{,%s,%s,=,}", dst, info->pc);
// UDIS86_ESIL (jne, "?!zf,%s=%s", info->pc, dst);
RPN UDIS86_ESIL (jne, "zf,!,?{,%s,%s,=,}", dst, info->pc);
RPN UDIS86_ESIL (ja, "cf,!,zf,!,&,?{,%s,%s,}",dst, info->pc);
RPN UDIS86_ESIL (jbe, "zf,cf,&,?{,%s,%s,=,}", dst, info->pc);
RPN UDIS86_ESIL (js, "sf,?{,%s,%s,=,}", dst, info->pc);
RPN UDIS86_ESIL (jns, "sf,!,?{,%s,%s,=,}", dst, info->pc);
RPN UDIS86_ESIL (jp, "pf,?{,%s,%s,=,}", dst, info->pc);
RPN UDIS86_ESIL (jnp, "pf,!,?{,%s,%s,=,}", dst, info->pc);
RPN UDIS86_ESIL (jl, "of,sf,^,?{,%s,%s,}", dst, info->pc);
RPN UDIS86_ESIL (jge, "of,!,sf,^,?{,%s,%s,}", dst, info->pc);
RPN UDIS86_ESIL (jle, "of,sf,^,zf,|,%s,%s,=", dst, info->pc);
RPN UDIS86_ESIL (jg, "sf,of,!,^,zf,!,&,?{,%s,%s,=,}", dst, info->pc);
RPN UDIS86_ESIL (jcxz, "cx,!,?{,%s,%s,=,}", dst, info->pc);
RPN UDIS86_ESIL (jecxz, "ecx,!,?{,%s,%s,=,}", dst, info->pc);
RPN UDIS86_ESIL (jrcxz, "rcx,!,?{,%s,%s,=,}", dst, info->pc);
// UDIS86_ESIL (jmp, "%s=%s", info->pc, dst);
RPN UDIS86_ESIL (jmp, "%s,%s,=", dst, info->pc);
RPN UDIS86_ESIL (call,
"%d,%s,+,"
"%d,%s,-=,%s,"
"=[],"
"%s,%s,=",
5, info->pc,
info->regsz, info->sp, info->sp,
dst, info->pc);
RPN UDIS86_ESIL (hlt, "hlt,TODO");
RPN UDIS86_ESIL (shl, "%s,%s,<<=,cz,$z,zf,=", src, dst);
RPN UDIS86_ESIL (shr, "%s,%s,>>=,cz,$z,zf,=", src, dst);
RPN UDIS86_ESIL (salc, "%s,%s,<<=,$z,zf,=", src, dst);
RPN UDIS86_ESIL (sar, "%s,%s,>>=,$z,zf,=", src, dst);
RPN UDIS86_ESIL (rol, "%s,%s,<<<=", src, dst);
RPN UDIS86_ESIL (ror, "%s,%s,>>>=", src, dst);
#if 0
RPN UDIS86_ESIL (rol, "%s,1,<<,%s,&,cf,=,%s,%s,>>=,%s,zf,=", src, dst, src, dst, dst)
RPN UDIS86_ESIL (ror, "%s,%d,-,1,<<,%s,&,cf,=,%s,%s,>>=,%s,zf,=", src, info->regsz*8, dst, src, dst, dst)
// UDIS86_ESIL (rol, "cf=%s&(1<<%s),%s>>=%s,zf=%s==0", dst, src, dst, src, dst);
UDIS86_ESIL (ror, "cf=%s&(1<<%d-%s),%s<<<=%s,zf=%s==0", dst, info->regsz * 8, src, dst, src, dst);
#endif
// UDIS86_ESIL (add, "cf=%s<=-%s&%s!=0,of=!((%s^%s)>>%d)&(((%s+%s)^%s)>>%d),%s+=%s,zf=%s==0,sf=%s>>%d", dst, src, src, dst, src, info->bits - 1, dst, src, src, info->bits - 1, dst, src, dst, dst, info->bits - 1);
// XXX: this is wrong coz add [rax], al -> al,[rax+0],= ;;; this is not valid esil
RPN UDIS86_ESIL (add, "%s,%s,+=", src, dst); //cf=%s<=-%s&%s!=0,of=!((%s^%s)>>%d)&(((%s+%s)^%s)>>%d),%s+=%s,zf=%s==0,sf=%s>>%d", dst, src, src, dst, src, info->bits - 1, dst, src, src, info->bits - 1, dst, src, dst, dst, info->bits - 1);
RPN UDIS86_ESIL (inc, "1,%s,+=,z,$z,zf,=", dst);
RPN UDIS86_ESIL (dec, "1,%s,-=,$z,zf,=,$o,of,=,$s,sf,=", dst);
// UDIS86_ESIL (inc, "of=(%s^(%s+1))>>%d,%s++,zf=%s==0,sf=%s>>%d", dst, dst, info->bits - 1, dst, dst, dst, info->bits - 1);
// UDIS86_ESIL (sub, "cf=%s<%s,of=!((%s^%s)>>%d)&(((%s+%s)^%s)>>%d),%s-=%s,zf=%s==0,sf=%s>>%d", dst, src, dst, src, info->bits - 1, dst, src, src, info->bits - 1, dst, src, dst, dst, info->bits - 1);
RPN UDIS86_ESIL (sub, "%s,%s,-=,$c,cf,=,$z,zf,=,$s,sf,=,$o,of,=", src, dst); // TODO: update flags
// UDIS86_ESIL (dec, "of=(%s^(%s-1))>>%d,%s--,zf=%s==0,sf=%s>>%d", dst, dst, info->bits - 1, dst, dst, dst, info->bits - 1);
// UDIS86_ESIL (cmp, "cf=%s<%s,zf=%s==%s", dst, src, dst, src);
RPN UDIS86_ESIL (cmp, "%s,%s,==,$z,zf,=", dst, src);
// UDIS86_ESIL (xor, "%s^=%s,zf=%s==0,sf=%s>>%d,cf=0,of=0", dst, src, dst, dst, info->bits - 1);
RPN UDIS86_ESIL (xor, "%s,%s,^=", dst, src);
// UDIS86_ESIL (or, "%s|=%s,zf=%s==0,sf=%s>>%d,cf=0,of=0", dst, src, dst, dst, info->bits - 1);
RPN UDIS86_ESIL (or, "%s,%s,|=", src, dst);
// UDIS86_ESIL (and, "%s&=%s,zf=%s==0,sf=%s>>%d,cf=0,of=0", dst, src, dst, dst, info->bits - 1);
RPN UDIS86_ESIL (and, "%s,%s,&=", src, dst);
#if 0
RPN UDIS86_ESIL (and, "%s,%s,&=,%s,!,zf,%s,%d,>>,sf,=,0,cf,=,0,of,=",
src, dst, dst, dst, info->bits-1);
#endif
// UDIS86_ESIL (test, "zf=%s&%s==0,sf=%s>>%d,cf=0,of=0", dst, src, dst, info->bits - 1);
RPN UDIS86_ESIL (test, "%s,%s,==,$z,zf,=", dst, src);
// UDIS86_ESIL (syscall, "$");
RPN UDIS86_ESIL (syscall, "$");
// UDIS86_ESIL (int3, "$3");
RPN UDIS86_ESIL (int3, "3,$");
// UDIS86_ESIL (int, "$0x%"PFMT64x, info->n);
RPN UDIS86_ESIL (int, "0x%"PFMT64x",$", info->n);
RPN UDIS86_ESIL (lea, "%s,%s,=", src, dst);
RPN UDIS86_ESIL (movzx, "%s,%s,=", src, dst); // not working? try 0fb63d55380000
RPN UDIS86_ESIL (mov, "%s,%s,=", src, dst);
// UDIS86_ESIL (push, "%s-=%d,%d[%s]=%s", info->sp, info->regsz, info->regsz, info->sp, dst);
RPN UDIS86_ESIL (push, "%s,%d,%s,-=,%s,=[%d]", dst, info->regsz, info->sp, info->sp, info->regsz);
// UDIS86_ESIL (pop, "%s=%d[%s],%s+=%d", dst, info->regsz, info->sp, info->sp, info->regsz);
RPN UDIS86_ESIL (pop, "%s,[%d],%s,=,%d,%s,+=",
info->sp, info->regsz, dst, info->regsz, info->sp);
RPN UDIS86_ESIL (leave, "%s,%s,=,%s,[%d],%s,%d,%s,-=",
info->bp, info->sp, info->sp, info->regsz, info->bp, info->regsz, info->sp);
RPN UDIS86_ESIL (ret, "%s,[%d],%s,=,%d,%s,+=", info->sp, info->regsz, info->pc, info->regsz, info->sp);
RPN UDIS86_ESIL (iretf, "%s,[%d],%s,=,%d,%s,+=", info->sp, info->regsz, info->pc, info->regsz, info->sp);
RPN UDIS86_ESIL (iretd, "%s,[%d],%s,=,%d,%s,+=", info->sp, info->regsz, info->pc, info->regsz, info->sp);
// UDIS86_ESIL (xchg, "%s^=%s,%s^=%s,%s^=%s", dst, src, src, dst, dst, src);
// TODO: add support for rpnesil tmp regs?
//RPN UDIS86_ESIL (xchg, "%s,%s,^=,%s,%s,^=,%s,%s,^=", src, dst, src, src, dst, dst);
RPN UDIS86_ESIL (xchg, "%s,%s,%s,=,%s,=", dst, src, dst, src);
UDIS86_ESIL (xadd, "%s^=%s,%s^=%s,%s^=%s,cf=%s<=-%s&%s!=0,of=!((%s^%s)>>%d)&(((%s+%s)^%s)>>%d),%s+=%s,zf=%s==0,sf=%s>>%d", dst, src, src, dst, dst, src, dst, src, src, dst, src, info->bits - 1, dst, src, src, info->bits - 1, dst, src, dst, dst, info->bits - 1);
UDIS86_ESIL (bt, "cf=%s&(1<<%d)!=0", dst, (int) info->n);
UDIS86_ESIL (btc, "cf=%s&(1<<%d)!=0,%s^=(1<<%d)", dst, (int) info->n, dst, (int) info->n);
UDIS86_ESIL (bts, "cf=%s&(1<<%d)!=0,%s|=(1<<%d)", dst, (int) info->n, dst, (int) info->n);
UDIS86_ESIL (btr, "cf=%s&(1<<%d)!=0,%s&=!(1<<%d)", dst, (int) info->n, dst, (int) info->n);
// UDIS86_ESIL (clc, "cf=0");
RPN UDIS86_ESIL (clc, "0,cf,=");
RPN UDIS86_ESIL (sti, "1,if,="); // interrupt flag
RPN UDIS86_ESIL (cli, "0,if,="); // interrupt flag
// UDIS86_ESIL (cld, "df=0");
RPN UDIS86_ESIL (std, "1,df,=");
RPN UDIS86_ESIL (cld, "0,df,=");
#define IS16 (info->bits==16)
#define IS32 (info->bits==32)
#define IS64 (info->bits==64)
#define RSZ (IS32?4:IS64?8:2)
RPN UDIS86_ESIL (pushad,
"%s"
",$r,%s,-=,%s,=[]"
",$r,%s,-=,%s,=[]"
",$r,%s,-=,%s,=[]"
",$r,%s,-=,%s,=[]"
",$r,%s,-=,%s,=[]"
",$r,%s,-=,%s,=[]"
",$r,%s,-=,%s,=[]"
",$r,%s,-=,%s,=[]",
IS64?
"rdi,rsi,rbp,rsp,rbx,rdx,rcx,rax"
: "edi,esi,ebp,esp,ebx,edx,ecx,eax",
info->sp, info->sp,
info->sp, info->sp,
info->sp, info->sp,
info->sp, info->sp,
info->sp, info->sp,
info->sp, info->sp,
info->sp, info->sp,
info->sp, info->sp
);
RPN UDIS86_ESIL (pusha,
"%s"
",$r,%s,-=,%s,=[]"
",$r,%s,-=,%s,=[]"
",$r,%s,-=,%s,=[]"
",$r,%s,-=,%s,=[]"
",$r,%s,-=,%s,=[]"
",$r,%s,-=,%s,=[]"
",$r,%s,-=,%s,=[]"
",$r,%s,-=,%s,=[]",
IS64?
"rdi,rsi,rbp,rsp,rbx,rdx,rcx,rax"
: "edi,esi,ebp,esp,ebx,edx,ecx,eax",
info->sp, info->sp,
info->sp, info->sp,
info->sp, info->sp,
info->sp, info->sp,
info->sp, info->sp,
info->sp, info->sp,
info->sp, info->sp,
info->sp, info->sp
);
RPN UDIS86_ESIL (popad,
"%s", IS64?
"rsp,[],rdi,="
",8,rsp,+,[],rsi,="
",16,rsp,+,[],rbp,="
",24,rsp,+,[],rsp,="
",32,rsp,+,[],rbx,="
",40,rsp,+,[],rdx,="
",48,rsp,+,[],rcx,="
",56,rsp,+,[],rax,="
",64,rsp,+="
:
"esp,[],edi,="
",4,esp,+,[],esi,="
",8,esp,+,[],ebp,="
",12,esp,+,[],esp,="
",16,esp,+,[],ebx,="
",20,esp,+,[],edx,="
",24,esp,+,[],ecx,="
",28,esp,+,[],eax,="
",32,esp,+="
);
RPN UDIS86_ESIL (popa,
"%s", IS64?
"rsp,[],rdi,="
",8,rsp,+,[],rsi,="
",16,rsp,+,[],rbp,="
",24,rsp,+,[],rsp,="
",32,rsp,+,[],rbx,="
",40,rsp,+,[],rdx,="
",48,rsp,+,[],rcx,="
",56,rsp,+,[],rax,="
",64,rsp,+="
:
"esp,[],edi,="
",4,esp,+,[],esi,="
",8,esp,+,[],ebp,="
",12,esp,+,[],esp,="
",16,esp,+,[],ebx,="
",20,esp,+,[],edx,="
",24,esp,+,[],ecx,="
",28,esp,+,[],eax,="
",32,esp,+="
);
RPN UDIS86_ESIL (cmc, "cf,!=");
RPN UDIS86_ESIL (into, "of,?{,4,$,}");
RPN UDIS86_ESIL (lahf, "%s,ah,=", info->bits == 16 ? "flags" : (info->bits == 32 ? "eflags" : "rflags"));
RPN UDIS86_ESIL (loop, "1,%s,-=,!,?{%s,%s,=,}",
info->bits == 16 ? "cx" : IS32 ? "ecx" : "rcx",
dst, info->pc);
RPN UDIS86_ESIL (loope, "1,%s,-=,zf,?{,%s,%s,}",
info->bits == 16 ? "cx" : IS32 ? "ecx" : "rcx",
dst, info->pc);
RPN UDIS86_ESIL (loopne, "1,%s,-=,zf,!,?{,%s,%s,}",
info->bits == 16 ? "cx" : IS32 ? "ecx" : "rcx",
dst, info->pc);
#define OP(args, inst) [JOIN (UD_I, inst)] = {args, UDIS86_ESIL_HANDLER (inst)}
/* This is the fastest way I can think about to implement this list of handlers */
UDis86Esil udis86_esil_callback_table[ UD_MAX_MNEMONIC_CODE ] = {
OP (0, nop), OP (1, jo), OP (1, jno), OP (1, jb), OP (1, jae),
OP (1, je), OP (1, jne), OP (1, ja), OP (1, jbe), OP (1, js),
OP (1, jns), OP (1, jp), OP (1, jnp), OP (1, jl), OP (1, jge),
OP (1, jle), OP (1, jg), OP (1, jcxz),OP (1, jecxz),OP (1, jrcxz),
OP (1, jmp), OP (1, call), OP (2, shl), OP (2, rol), OP (2, ror),
OP (2, add), OP (1, inc), OP (2, sub), OP (1, dec), OP (2, cmp),
OP (2, xor), OP (2, or), OP (2, and), OP (2, test), OP (0, syscall),
OP (1, int), OP (2, lea), OP (2, mov), OP (1, push), OP (1, pop),
OP (0, leave),OP (0, ret), OP (2, xchg),OP (2, xadd), OP (2, bt),
OP (2, btc), OP (2, bts), OP (2, btr), OP (0, clc), OP (0, cli),
OP (0, cld), OP (0, cmc), OP (0, int3),OP (0, into), OP (0, lahf),
OP (1, loop), OP (1, loope),OP (1, loopne), OP(2,sar), OP (2, salc)
};
UDis86Esil * udis86_esil_get_handler (enum ud_mnemonic_code code) {
if (!udis86_esil_callback_table[code].callback) {
return NULL;
}
return udis86_esil_callback_table + code;
}
+35
View File
@@ -0,0 +1,35 @@
#ifndef _UDIS86_ESIL_H
#define _UDIS86_ESIL_H
#include "udis86/extern.h"
/* This may be useful for other architectures */
#define esilprintf(op, fmt, ...) r_strbuf_setf (&op->esil, fmt, ##__VA_ARGS__)
#define UDIS86_ESIL_ARGUMENTS const UDis86OPInfo *info, RAnalOp *op, const char *dst, const char *src, const char *src2
typedef struct udis86_op_info {
ut64 n;
int bits;
ut64 bitmask;
int regsz;
int oplen;
const char *pc;
const char *sp;
const char *bp;
} UDis86OPInfo;
typedef struct udis86_esil_t {
int argc;
void (*callback) (UDIS86_ESIL_ARGUMENTS);
} UDis86Esil;
#define _JOIN(a1, a2) a1 ## a2
#define JOIN(a1, a2) _JOIN (a1, a2)
#define UDIS86_ESIL_HANDLER(name) JOIN (JOIN (__x86_, name), _to_esil)
#define UDIS86_ESIL_PROTO(name) void UDIS86_ESIL_HANDLER (name) (UDIS86_ESIL_ARGUMENTS)
#define UDIS86_ESIL(name, fmt, ...) UDIS86_ESIL_PROTO (name) { esilprintf (op, fmt, ##__VA_ARGS__); }
UDis86Esil *udis86_esil_get_handler (enum ud_mnemonic_code);
#endif /* _UDIS86_ESIL_H */
+12
View File
@@ -0,0 +1,12 @@
OBJ_evm=anal_evm.o
OBJ_evm+=../../asm/arch/evm/evm.o
CFLAGS+=-I../../asm/arch/evm/
STATIC_OBJ+=${OBJ_evm}
TARGET_evm=anal_evm.${LIBEXT}
ALL_TARGETS+=${TARGET_evm}
LINKFLAGS+=-ljansson
${TARGET_evm}: ${OBJ_evm} ${SHARED_OBJ}
${CC} $(call libname,anal_evm) ${LDFLAGS} ${CFLAGS} -o ${TARGET_evm} ${OBJ_evm} ${LINKFLAGS}
@@ -1,11 +1,11 @@
OBJ_M68K=anal_m68k.o
OBJ_M68K=anal_m68k_net.o
#include ${CURDIR}capstone.mk
STATIC_OBJ+=${OBJ_M68K}
TARGET_M68K=anal_m68k.${LIBEXT}
TARGET_M68K=anal_m68k_net.${LIBEXT}
ALL_TARGETS+=${TARGET_M68K}
${TARGET_M68K}: ${OBJ_M68K}
${CC} $(call libname,anal_m68k) ${LDFLAGS} ${CFLAGS} -o anal_m68k.${LIBEXT} ${OBJ_M68K}
${CC} $(call libname,anal_m68k) ${LDFLAGS} ${CFLAGS} -o anal_m68k_net.${LIBEXT} ${OBJ_M68K}
+23
View File
@@ -0,0 +1,23 @@
OBJ_X86_UDIS86=anal_x86_udis.o
OBJ_ESIL_UDIS86=esil_x86_udis.o
SHARED_X86_UDIS86=../../asm/arch/x86/udis86/decode.o
SHARED_X86_UDIS86+=../../asm/arch/x86/udis86/itab.o
SHARED_X86_UDIS86+=../../asm/arch/x86/udis86/syn-att.o
SHARED_X86_UDIS86+=../../asm/arch/x86/udis86/syn-intel.o
SHARED_X86_UDIS86+=../../asm/arch/x86/udis86/syn.o
SHARED_X86_UDIS86+=../../asm/arch/x86/udis86/udis86.o
SRC_X86_UDIS86=../../asm/arch/x86/udis86/*.c
EXT_SO=$(shell r2 -H LIBEXT)
STATIC_OBJ+=${OBJ_X86_UDIS86} ${OBJ_ESIL_UDIS86}
SHARED_OBJ+=${SHARED_X86_UDIS86}
TARGET_X86_UDIS86=anal_x86_udis.${EXT_SO}
ALL_TARGETS+=${TARGET_X86_UDIS86}
CFLAGS+=-I../../asm/arch/x86 -I../../asm/arch/x86/udis86 -DHAVE_STRING_H=1
${TARGET_X86_UDIS86}: ${OBJ_X86_UDIS86} ${OBJ_ESIL_UDIS86}
${CC} ${CFLAGS} ${LDFLAGS} $(call libname,anal_x86) -lr_reg -lr_anal -lr_util \
$(SRC_X86_UDIS86) -o anal_x86_udis.${EXT_SO} ${OBJ_X86_UDIS86} ${OBJ_ESIL_UDIS86}
+46 -2
View File
@@ -1,18 +1,62 @@
R2PM_PLUGDIR ?=$(HOME)/.config/radare2/plugins
atombios:
cd p ; $(MAKE) asm_atombios.$(LIBEXT)
blackfin:
cd p ; $(MAKE) asm_blackfin.$(LIBEXT)
bea:
cd p ; $(MAKE) asm_x86_bea.$(LIBEXT)
msil:
cd p ; $(MAKE) asm_msil.$(LIBEXT)
x86_udis udis udis86:
cd p ; $(MAKE) asm_x86_udis.$(LIBEXT)
udis86-clean:
rm -rf p/asm_x86_udis.$(LIBEXT)*
tab:
cd p ; $(MAKE) asm_x86_tab.$(LIBEXT)
m68k:
cd p ; $(MAKE) asm_m68k.$(LIBEXT)
swf:
cd p ; $(MAKE) asm_swf.$(LIBEXT)
pyc:
cd p ; $(MAKE) asm_pyc.$(LIBEXT)
olly:
cd p ; $(MAKE) asm_x86_olly.$(LIBEXT)
m68k_net:
$(MAKE) -C p asm_m68k_net.$(LIBEXT)
zyan:
$(MAKE) -C p asm_x86_zyan.$(LIBEXT)
evm:
$(MAKE) -C p asm_evm.$(LIBEXT)
nios:
$(MAKE) -C p asm_nios.$(LIBEXT)
zyan-install: zyan
mkdir -p $(R2PM_PLUGDIR)
cp -f p/asm_x86_zyan.$(LIBEXT) $(R2PM_PLUGDIR)
zyan-uninstall:
$(RM) $(R2PM_PLUGDIR)/asm_x86_zyan.$(LIBEXT)
clean:
rm -f p/asm_x86_bea.$(LIBEXT)
rm -f p/asm_x86_tab.$(LIBEXT)
rm -f p/asm_x86_olly.$(LIBEXT)
rm -f p/asm_m68k.$(LIBEXT)
rm -f p/asm_x86_zyan.$(LIBEXT)
rm -f p/asm_atombios.{$(LIBEXT),o}
rm -f arch/atombios/atombios.o
rm -f p/asm_nios.$(LIBEXT)
include ../../options.mk
+606
View File
@@ -0,0 +1,606 @@
/* radare - LGPL - Copyright 2018 damo22 */
#include <stdio.h>
#include <string.h>
#include <r_types.h>
#include <r_endian.h>
#include "atombios.h"
// FIXME: Globals ugh
static int last_reg_index = INDEX_NONE;
static int last_reg_offset = 0;
static int opt_reg_addresses = 0;
const char *align_source_esil[] = {
"",
"_01",
"_12",
"_23",
"_0",
"_1",
"_2",
"_3"
};
const char *align_byte_esil[] = { "_0", "_1", "_2", "_3" };
const char *align_word_esil[] = { "_01", "_12", "_23", "" };
const char *align_long_esil[] = { "", "", "", "" };
const char *addrtypes_esil[] = {
"0x%04x,r", "p%d", "w%d", "0x%02x,f", "0x%04x,dt", "0x%04x,D_IDunimpl",
"0x%04x,pll", "0x%04x,mc",
"0x%02x", "0x%04x", "0x%08x"
};
const char *align_source[] = {
"XXXX",
"..XX",
".XX.",
"XX..",
"...X",
"..X.",
".X..",
"X..."
};
const char *align_byte[] = { "...X", "..X.", ".X..", "X..." };
const char *align_word[] = { "..XX", ".XX.", "XX..", "?..?" };
const char *align_long[] = { "XXXX", "????", "????", "????" };
const int size_align[] = { 4, 2, 2, 2, 1, 1, 1, 1 };
const char *addrnames[] = { "REG", "PS", "WS", "FB", "ID", "IM", "PLL", "MC", "dec", "hex8", "hex16", "null" };
const char *addrtypes[] = {
"REG[0x%04x]", "PARAM[%d]", "WORK[%d]", "FB[0x%02x]", "DATA[0x%04x]", "0x%04x,<!impl>",
"PLL[0x%04x]", "MC[0x%04x]",
"0x%02x", "0x%04x", "0x%08x"
};
int addrtypes_shift[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
const char *addrtypes_im[] = { NULL, "0x%02x", "0x%04x", NULL, "0x%08x" };
const char *index_command_table[] = {
"ASIC_Init", "GetDisplaySurfaceSize", "ASIC_RegistersInit",
"VRAM_BlockVenderDetection", "SetClocksRatio_DIGxEncoderControl", "MemoryControllerInit",
"EnableCRTCMemReq", "MemoryParamAdjust", "DVOEncoderControl",
"GPIOPinControl", "SetEngineClock", "SetMemoryClock",
"SetPixelClock", "DynamicClockGating", "ResetMemoryDLL",
"ResetMemoryDevice", "MemoryPLLInit", "AdjustDisplayPll",
"AdjustMemoryController", "EnableASIC_StaticPwrMgt", "ASIC_StaticPwrMgtStatusChange_SetUniphyInstance",
"DAC_LoadDetection", "LVTMAEncoderControl", "LCD1OutputControl",
"DAC1EncoderControl", "DAC2EncoderControl", "DVOOutputControl",
"CV1OutputControl", "GetConditionalGoldenSetting_SetCRTC_DPM_State", "TVEncoderControl",
"TMDSAEncoderControl", "LVDSEncoderControl", "TV1OutputControl",
"EnableScaler", "BlankCRTC", "EnableCRTC",
"GetPixelClock", "EnableVGA_Render", "EnableVGA_Access_GetSCLKOverMCLKRatio",
"SetCRTC_Timing", "SetCRTC_OverScan", "SetCRTC_Replication",
"SelectCRTC_Source", "EnableGraphSurfaces", "UpdateCRTC_DoubleBufferRegisters",
"LUT_AutoFill", "EnableHW_IconCursor", "GetMemoryClock",
"GetEngineClock", "SetCRTC_UsingDTDTiming", "ExternalEncoderControl",
"LVTMAOutputControl", "VRAM_BlockDetectionByStrap", "MemoryCleanUp",
"ReadEDIDFromHWAssistedI2C_ProcessI2cChannelTransaction",
"WriteOneByteToHWAssistedI2C", "ReadHWAssistedI2CStatus_HPDInterruptService",
"SpeedFanControl", "PowerConnectorDetection", "MC_Synchronization",
"ComputeMemoryEnginePLL", "MemoryRefreshConversion", "VRAM_GetCurrentInfoBlock",
"DynamicMemorySettings", "MemoryTraining", "EnableSpreadSpectrumOnPPLL",
"TMDSAOutputControl", "SetVoltage", "DAC1OutputControl",
"DAC2OutputControl", "SetupHWAssistedI2CStatus", "ClockSource",
"MemoryDeviceInit", "EnableYUV", "DIG1EncoderControl",
"DIG2EncoderControl", "DIG1TransmitterControl_UNIPHYTransmitterControl",
"DIG2TransmitterControl_LVTMATransmitterControl",
"ProcessAuxChannelTransaction", "DPEncoderService"
};
const char *index_data_table[] = {
"UtilityPipeLine", "MultimediaCapabilityInfo", "MultimediaConfigInfo",
"StandardVESA_Timing", "FirmwareInfo", "DAC_Info",
"LVDS_Info", "TMDS_Info", "AnalogTV_Info",
"SupportedDevicesInfo", "GPIO_I2C_Info", "VRAM_UsageByFirmware",
"GPIO_Pin_LUT", "VESA_ToInternalModeLUT", "ComponentVideoInfo",
"PowerPlayInfo", "CompassionateData", "SaveRestoreInfo_DispDevicePriorityInfo",
"PPLL_SS_Info_SS_Info", "OemInfo", "XTMDS_Info",
"MclkSS_Info", "Object_Info_Object_Header", "IndirectIOAccess",
"MC_InitParameter_AdjustARB_SEQ", "ASIC_VDDC_Info", "ASIC_InternalSS_Info_ASIC_MVDDC_Info",
"TV_VideoMode_DispOutInfo", "VRAM_Info", "MemoryTrainingInfo_ASIC_MVDDQ_Info",
"IntegratedSystemInfo", "ASIC_ProfilingInfo_ASIC_VDDCI_Info",
"VoltageObjectInfo_VRAM_GPIO_DetectionInfo",
"PowerSourceInfo"
};
const char *index_ati_port[] = {
"INDIRECT_IO_MM",
"INDIRECT_IO_PLL",
"INDIRECT_IO_MC",
"INDIRECT_IO_PCIE",
};
const char *index_work_reg[] = {
[WS_QUOTIENT] = "w0",
[WS_REMAINDER] = "w1",
[WS_DATAPTR] = "w2",
[WS_SHIFT] = "w3",
[WS_OR_MASK] = "w4",
[WS_AND_MASK] = "w5",
[WS_FB_WINDOW] = "w6",
[WS_ATTRIBUTES] = "w7",
[WS_REGPTR] = "w8"
};
#define TABENTRY(x) { #x, (index_ ## x), sizeof (index_ ## x) / sizeof (const char **) }
index_table_t index_tables[INDEXTABLE_SIZEOF] = {
{ NULL, NULL, 0 },
TABENTRY (command_table),
TABENTRY (data_table),
TABENTRY (ati_port),
TABENTRY (work_reg),
{ "REG_MM", NULL, 0 },
{ "REG_PLL", NULL, 0 },
{ "REG_MC", NULL, 0 },
{ "REG_PCIE", NULL, 0 },
{ "REG_PCICONFIG", NULL, 0 },
{ "REG_SYSTEMIO", NULL, 0 }
};
const char *get_index (int type, int val)
{
if (type < 0 || val < 0 ||
type >= sizeof (index_tables) / sizeof (const struct index_table_s))
return NULL;
if (! index_tables[type].tab || val >= index_tables[type].len)
return NULL;
return index_tables[type].tab[val];
}
static int op_ds (const ut8 *, char *);
static int op_sdb (const ut8 *, char *);
static int op_0x (const ut8 *, char *);
static int op_1x8 (const ut8 *, char *);
static int op_1x16 (const ut8 *, char *);
static int op_src (const ut8 *, char *);
static int op_dest (const ut8 *, char *);
static int op_destsrc (const ut8 *, char *);
static int op_shift (const ut8 *, char *);
static int op_switch (const ut8 *, char *);
static int op_mask (const ut8 *, char *);
static int op_setpt0 (const ut8 *, char *);
static int op_setpt1 (const ut8 *, char *);
static int op_setrb (const ut8 *, char *);
const optab_t optable[256] = {
{ NULL, NULL, NULL, D_null, 0, 0 },
{ op_destsrc, "move", "=", D_REG, 0, 0 },
{ op_destsrc, "move", "=", D_PS, 0, 0 },
{ op_destsrc, "move", "=", D_WS, 0, 0 },
{ op_destsrc, "move", "=", D_FB, 0, 0 },
{ op_destsrc, "move", "=", D_PLL, 0, 0 },
{ op_destsrc, "move", "=", D_MC, 0, 0 },
{ op_destsrc, "and", "&=", D_REG, 0, 0 },
{ op_destsrc, "and", "&=", D_PS, 0, 0 },
{ op_destsrc, "and", "&=", D_WS, 0, 0 },
{ op_destsrc, "and", "&=", D_FB, 0, 0 },
{ op_destsrc, "and", "&=", D_PLL, 0, 0 },
{ op_destsrc, "and", "&=", D_MC, 0, 0 },
{ op_destsrc, "or", "|=", D_REG, 0, 0 },
{ op_destsrc, "or", "|=", D_PS, 0, 0 },
{ op_destsrc, "or", "|=", D_WS, 0, 0 },
{ op_destsrc, "or", "|=", D_FB, 0, 0 },
{ op_destsrc, "or", "|=", D_PLL, 0, 0 },
{ op_destsrc, "or", "|=", D_MC, 0, 0 },
{ op_shift, "shiftl", "<<=", D_REG, 0, 0 },
{ op_shift, "shiftl", "<<=", D_PS, 0, 0 },
{ op_shift, "shiftl", "<<=", D_WS, 0, 0 },
{ op_shift, "shiftl", "<<=", D_FB, 0, 0 },
{ op_shift, "shiftl", "<<=", D_PLL, 0, 0 },
{ op_shift, "shiftl", "<<=", D_MC, 0, 0 },
{ op_shift, "shiftr", ">>=", D_REG, 0, 0 },
{ op_shift, "shiftr", ">>=", D_PS, 0, 0 },
{ op_shift, "shiftr", ">>=", D_WS, 0, 0 },
{ op_shift, "shiftr", ">>=", D_FB, 0, 0 },
{ op_shift, "shiftr", ">>=", D_PLL, 0, 0 },
{ op_shift, "shiftr", ">>=", D_MC, 0, 0 },
{ op_destsrc, "mul", "*=", D_REG, 0, 0 },
{ op_destsrc, "mul", "*=", D_PS, 0, 0 },
{ op_destsrc, "mul", "*=", D_WS, 0, 0 },
{ op_destsrc, "mul", "*=", D_FB, 0, 0 },
{ op_destsrc, "mul", "*=", D_PLL, 0, 0 },
{ op_destsrc, "mul", "*=", D_MC, 0, 0 },
{ op_destsrc, "div", "/=", D_REG, 0, 0 },
{ op_destsrc, "div", "/=", D_PS, 0, 0 },
{ op_destsrc, "div", "/=", D_WS, 0, 0 },
{ op_destsrc, "div", "/=", D_FB, 0, 0 },
{ op_destsrc, "div", "/=", D_PLL, 0, 0 },
{ op_destsrc, "div", "/=", D_MC, 0, 0 },
{ op_destsrc, "add", "+=", D_REG, 0, 0 },
{ op_destsrc, "add", "+=", D_PS, 0, 0 },
{ op_destsrc, "add", "+=", D_WS, 0, 0 },
{ op_destsrc, "add", "+=", D_FB, 0, 0 },
{ op_destsrc, "add", "+=", D_PLL, 0, 0 },
{ op_destsrc, "add", "+=", D_MC, 0, 0 },
{ op_destsrc, "sub", "-=", D_REG, 0, 0 },
{ op_destsrc, "sub", "-=", D_PS, 0, 0 },
{ op_destsrc, "sub", "-=", D_WS, 0, 0 },
{ op_destsrc, "sub", "-=", D_FB, 0, 0 },
{ op_destsrc, "sub", "-=", D_PLL, 0, 0 },
{ op_destsrc, "sub", "-=", D_MC, 0, 0 },
{ op_setpt1, "set_ati_port", NULL, D_hex16, INDEX_REG_MM, INDEX_ATI_PORT },
{ op_setpt0, "set_pci_port", NULL, D_null, INDEX_REG_PCICONFIG, 0 },
{ op_setpt0, "set_systemio_port", NULL, D_null, INDEX_REG_SYSTEMIO, 0 },
{ op_setrb, "set_reg_block", NULL, D_hex16, 0, 0 },
{ op_src, "set_fb_base", NULL, D_hex16, 0, 0 },
{ op_destsrc, "cmp", "==", D_REG, 0, 0 },
{ op_destsrc, "cmp", "==", D_PS, 0, 0 },
{ op_destsrc, "cmp", "==", D_WS, 0, 0 },
{ op_destsrc, "cmp", "==", D_FB, 0, 0 },
{ op_destsrc, "cmp", "==", D_PLL, 0, 0 },
{ op_destsrc, "cmp", "==", D_MC, 0, 0 },
{ op_switch, "switch", NULL, D_hex16, 0, 0 },
{ op_1x16, "jmp", NULL, D_hex16, 0, 0 },
{ op_1x16, "je ", "==", D_hex16, 0, 0 },
{ op_1x16, "jl ", "<", D_hex16, 0, 0 },
{ op_1x16, "jg ", ">", D_hex16, 0, 0 },
{ op_1x16, "jle", "<=", D_hex16, 0, 0 },
{ op_1x16, "jge", ">=", D_hex16, 0, 0 },
{ op_1x16, "jne", "!=", D_hex16, 0, 0 },
{ op_destsrc, "bitest", "&", D_REG, 0, 0 },
{ op_destsrc, "bitest", "&", D_PS, 0, 0 },
{ op_destsrc, "bitest", "&", D_WS, 0, 0 },
{ op_destsrc, "bitest", "&", D_FB, 0, 0 },
{ op_destsrc, "bitest", "&", D_PLL, 0, 0 },
{ op_destsrc, "bitest", "&", D_MC, 0, 0 },
{ op_1x8, "mdelay", NULL, D_hex8, 0, 0 },
{ op_1x8, "udelay", NULL, D_hex8, 0, 0 },
{ op_1x8, "call", NULL, D_hex8, 0, INDEX_COMMAND_TABLE },
{ op_1x8, "<deprecated> repeat", NULL, D_hex8, 0, 0 },
{ op_dest, "clear", "0", D_REG, 0, 0 },
{ op_dest, "clear", "0", D_PS, 0, 0 },
{ op_dest, "clear", "0", D_WS, 0, 0 },
{ op_dest, "clear", "0", D_FB, 0, 0 },
{ op_dest, "clear", "0", D_PLL, 0, 0 },
{ op_dest, "clear", "0", D_MC, 0, 0 },
{ op_0x, "nop", NULL, D_null, 0, 0 },
{ op_0x, "ret", NULL, D_null, 0, 0 },
{ op_mask, "mask", NULL, D_REG, 0, 0 },
{ op_mask, "mask", NULL, D_PS, 0, 0 },
{ op_mask, "mask", NULL, D_WS, 0, 0 },
{ op_mask, "mask", NULL, D_FB, 0, 0 },
{ op_mask, "mask", NULL, D_PLL, 0, 0 },
{ op_mask, "mask", NULL, D_MC, 0, 0 },
{ op_1x8, "post_card", NULL, D_hex8, 0, 0 },
{ op_1x8, "<!impl> beep", NULL, D_hex8, 0, 0 },
{ op_0x, "<deprecated> save_reg", NULL, D_null, 0, 0 },
{ op_0x, "<deprecated> restore_reg", NULL, D_null, 0, 0 },
{ op_sdb, "set_data_block", NULL, D_hex8, 0, INDEX_DATA_TABLE },
{ op_destsrc, "xor", "^=", D_REG, 0, 0 },
{ op_destsrc, "xor", "^=", D_PS, 0, 0 },
{ op_destsrc, "xor", "^=", D_WS, 0, 0 },
{ op_destsrc, "xor", "^=", D_FB, 0, 0 },
{ op_destsrc, "xor", "^=", D_PLL, 0, 0 },
{ op_destsrc, "xor", "^=", D_MC, 0, 0 },
{ op_destsrc, "shl", "<<=", D_REG, 0, 0 },
{ op_destsrc, "shl", "<<=", D_PS, 0, 0 },
{ op_destsrc, "shl", "<<=", D_WS, 0, 0 },
{ op_destsrc, "shl", "<<=", D_FB, 0, 0 },
{ op_destsrc, "shl", "<<=", D_PLL, 0, 0 },
{ op_destsrc, "shl", "<<=", D_MC, 0, 0 },
{ op_destsrc, "shr", ">>=", D_REG, 0, 0 },
{ op_destsrc, "shr", ">>=", D_PS, 0, 0 },
{ op_destsrc, "shr", ">>=", D_WS, 0, 0 },
{ op_destsrc, "shr", ">>=", D_FB, 0, 0 },
{ op_destsrc, "shr", ">>=", D_PLL, 0, 0 },
{ op_destsrc, "shr", ">>=", D_MC, 0, 0 },
{ op_0x, "<!doc> debug", NULL, D_null, 0, 0 },
{ op_ds, "bindata", NULL, D_null, 0, 0 },
[0x80] = { op_0x, "<!impl> extended", NULL, D_null, 0, 0 },
[0xff] = { op_0x, "<reserved>", NULL, D_null, 0, 0 }
};
int get_table_offset(ut16 *table, int idx) {
int i, last = 0, offset = 0;
static int wrapwarning = 0;
if (! table || ! table[idx])
return 0;
for (i = 0; i <= idx; i++) {
int off = table[i];
if (off) {
if (off < last)
offset += 0x10000;
last = off - 0x8000;
}
}
if (offset && ! wrapwarning++)
printf ("*** Wrap around of table offset - assuming offset\n");
return table[idx] + offset;
}
int sub_dest (const ut8 *d, char *out, int type, int align, int size, int index) {
ut32 val;
int r;
const char *ind;
switch (type) {
case D_REG:
val = *((ut16 *) d);
r = 2;
break;
case D_ID: case D_IM:
out += sprintf (out, "<internal - illegal addrtype %s>", addrnames [type]);
val = 0;
r = 0;
break;
default:
val = *d;
r = 1;
}
if (type == D_WS && (ind = get_index (INDEX_WORK_REG, val)) )
out += sprintf (out, "%s", ind);
else if (r)
out += sprintf (out, addrtypes [type], val << addrtypes_shift[type]);
switch (size) {
case 1:
out += sprintf (out, " [%s]", align_byte[align]);
break;
case 2:
out += sprintf (out, " [%s]", align_word[align]);
break;
case 4:
out += sprintf (out, " [%s]", align_long[align]);
break;
}
if (type == D_REG && (ind = get_index (last_reg_index, val+last_reg_offset)) )
out += sprintf (out, " (%s)", ind);
if (r && (ind = get_index (index, val)) )
out += sprintf (out, " (%s)", ind);
return r;
}
int sub_src (const ut8 *d, char *out, int type, int align, int size, int index) {
ut32 val;
int r;
const char *ind;
switch (type) {
case D_IM:
r = size;
break;
case D_PS: case D_WS: case D_FB: case D_PLL: case D_MC:
r = 1;
break;
case D_REG: case D_ID:
r = 2;
}
switch (r) {
case 1:
val = *d;
break;
case 2:
val = r_read_le16(d);
break;
case 4:
val = r_read_le32(d);
break;
}
if (type == D_IM) {
out += sprintf (out, addrtypes_im [size], val);
} else if (type == D_WS && (ind = get_index (INDEX_WORK_REG, val)) ) {
out += sprintf (out, "%s", ind);
out += sprintf (out, " [%s]", align_source[align]);
} else {
out += sprintf (out, addrtypes [type], val << addrtypes_shift [type]);
out += sprintf (out, " [%s]", align_source[align]);
}
if (type == D_REG && (ind = get_index (last_reg_index, val+last_reg_offset)) )
out += sprintf (out, " (%s)", ind);
if ( (ind = get_index (index, val)) )
out += sprintf (out, " (%s)", ind);
return r;
}
int op_ds (const ut8 *d, char *out) {
const optab_t *op = &optable[d[0]];
ut16 size = r_read_at_le16(d, 1);
out += sprintf (out, "%-5s %d bytes", op->name, size + 2);
return size + 3;
}
int op_sdb (const ut8 *d, char *out) {
const optab_t *op = &optable[d[0]];
const char *ind;
out += sprintf (out, "%-5s ", op->name);
out += sprintf (out, addrtypes [op->desttype],
d[1] << addrtypes_shift [op->desttype]);
if (d[1] == 0xff)
out += sprintf (out, " (this table)");
else if ( (ind = get_index (op->destindex, d[1])) )
out += sprintf (out, " (%s)", ind);
return 2;
}
int op_0x (const ut8 *d, char *out) {
const optab_t *op = &optable[d[0]];
strcpy (out, op->name);
return 1;
}
int op_1x8 (const ut8 *d, char *out) {
const optab_t *op = &optable[d[0]];
const char *ind;
out += sprintf (out, "%-5s ", op->name);
out += sprintf (out, addrtypes [op->desttype],
d[1] << addrtypes_shift [op->desttype]);
if ( (ind = get_index (op->destindex, d[1])) )
out += sprintf (out, " (%s)", ind);
return 2;
}
int op_1x16 (const ut8 *d, char *out) {
const optab_t *op = &optable[d[0]];
const char *ind;
out += sprintf (out, "%-5s ", op->name);
out += sprintf (out, addrtypes [op->desttype],
r_read_at_le16(d, 1) << addrtypes_shift [op->desttype]);
if ( (ind = get_index (op->destindex, d[1])) )
out += sprintf (out, " (%s)", ind);
return 3;
}
int op_src (const ut8 *d, char *out) {
const optab_t *op = &optable[d[0]];
ut8 *t = (ut8 *)&d[1];
int attr = *t++;
out += sprintf (out, "%-5s ", op->name);
t += sub_src (t, out, attr & 0x07, (attr & 0x38) >> 3, size_align[(attr & 0x38)>>3], op->srcindex);
return t - d;
}
int op_dest (const ut8 *d, char *out) {
const optab_t *op = &optable[d[0]];
ut8 *t = (ut8 *)&d[1];
int attr = *t++;
out += sprintf (out, "%-5s ", op->name);
t += sub_src (t, out, op->desttype, (attr & 0x38) >> 3, size_align[(attr & 0x38)>>3], op->destindex);
return t - d;
}
int op_destsrc (const ut8 *d, char *out) {
const optab_t *op = &optable[d[0]];
ut8 *t = (ut8 *)&d[1];
int attr = *t++;
out += sprintf (out, "%-5s ", op->name);
t += sub_dest (t, out, op->desttype, attr >> 6, size_align[(attr & 0x38)>>3], op->destindex);
out += strlen (out);
out += sprintf (out, " <- ");
t += sub_src (t, out, attr & 0x07, (attr & 0x38) >> 3, size_align[(attr & 0x38)>>3], op->srcindex);
return t - d;
}
int op_shift (const ut8 *d, char *out) {
const optab_t *op = &optable[d[0]];
ut8 *t = (ut8 *)&d[1];
int attr = *t++;
out += sprintf (out, "%-5s ", op->name);
t += sub_src (t, out, op->desttype, (attr & 0x38) >> 3, size_align[(attr & 0x38)>>3], op->destindex);
out += strlen (out);
out += sprintf (out, " by %02x", *t++);
return t - d;
}
int op_switch (const ut8 *d, char *out) {
const optab_t *op = &optable[d[0]];
ut8 *t = (ut8 *)&d[1];
int attr = *t++;
out += sprintf (out, "%-5s ", op->name);
t += sub_src (t, out, attr & 0x07, (attr & 0x38) >> 3, size_align[(attr & 0x38)>>3], op->srcindex);
out += strlen (out);
while (t[0] != 0x5a && t[1] != 0x5a) { /* EndOfSwitch: 2x NOP */
if (*t++ != 'c') {
out += sprintf (out, " (missing CASE for switch)");
t -= 3;
break;
}
switch (size_align[(attr & 0x38)>>3]) {
case 1:
out += sprintf (out, " %02x ->", *t++);
break;
case 2:
out += sprintf (out, " %04x ->", r_read_le16(t));
t += 2;
break;
case 4:
out += sprintf (out, " %08x ->", r_read_le32(t));
t += 4;
break;
}
out += sprintf (out, " %04x", r_read_le16(t));
t += 2;
}
t += 2;
return t - d;
}
int op_mask (const ut8 *d, char *out) {
const optab_t *op = &optable[d[0]];
ut8 *t = (ut8 *)&d[1];
int attr = *t++;
out += sprintf (out, "%-5s ", op->name);
t += sub_dest (t, out, op->desttype, attr >> 6, size_align[(attr & 0x38)>>3], op->destindex);
out += strlen (out);
out += sprintf (out, " & ");
t += sub_src (t, out, D_IM, (attr & 0x38) >> 3, size_align[(attr & 0x38)>>3], 0);
out += strlen (out);
out += sprintf (out, " | ");
t += sub_src (t, out, attr & 0x07, (attr & 0x38) >> 3, size_align[(attr & 0x38)>>3], 0);
return t - d;
}
int op_setpt0 (const ut8 *d, char *out) {
const optab_t *op = &optable[d[0]];
last_reg_index = op->srcindex;
/* is never INDEX_REG_MM */
addrtypes_shift[D_REG] = 0;
return op_0x (d, out);
}
int op_setpt1 (const ut8 *d, char *out) {
const optab_t *op = &optable[d[0]];
last_reg_index = op->srcindex + r_read_at_le16(d, 1);
if (last_reg_index == INDEX_REG_MM && opt_reg_addresses)
addrtypes_shift[D_REG] = 2;
else
addrtypes_shift[D_REG] = 0;
return op_1x16 (d, out);
}
int op_setrb (const ut8 *d, char *out) {
const optab_t *op = &optable[d[0]];
last_reg_offset = op->srcindex + r_read_at_le16(d, 1);
return op_1x16 (d, out);
}
/*
void do_data (const ut8 *data, int off, int nr)
{
int len;
const char *comment = NULL;
int frev = data[off+2];
int crev = data[off+3];
data_dumper_t *dt = get_data_dumper (nr, &frev, &crev, &comment);
if (! dt)
return;
if (frev == 0)
fprintf (stdout, " NOTE: General revisionless dumper only.\n");
else if (frev != data[off+2] || crev != data[off+3])
fprintf (stdout, " NOTE: Dumper revision differs. "
"Used: Format Rev. %02x Content Rev. %02x\n", frev, crev);
if (comment)
fprintf (stdout, " NOTE: %s\n", comment);
if (frev == 0 || frev != data[off+2] || crev != data[off+3] || comment)
fputs ("\n", stdout);
len = (*dt) (data+off, data+off, 1);
fprintf (stdout, "\n Total data structure size: %04x\n\n", len);
}
*/
int atombios_inst_len(const ut8 *buf) {
const ut8 *d = buf;
char tmpbuf[1024] = {0}; // can have data table with hugeass instruction
ut8 size = 0;
if (optable[*d].process) {
size = optable[*d].process (d, tmpbuf);
} else {
size = 1;
}
return size;
}
int atombios_disassemble(const ut8 *inbuf, char *outbuf) {
const ut8 *d = inbuf;
ut8 size = 0;
if (optable[*d].process) {
size = optable[*d].process (d, outbuf);
} else {
sprintf (outbuf, "<unknown opcode> %02x", *d);
size = 1;
}
return size;
}
+98
View File
@@ -0,0 +1,98 @@
#ifndef _INCLUDE_ATOMBIOS_H_
#define _INCLUDE_ATOMBIOS_H_
#include <r_types.h>
#define HEADER_OFFSET 0x48
#define ATOM_MAGIC (const ut8 *)"ATOM"
#define N_TABLES_CMD 80
#define N_TABLES_DATA 34
typedef struct index_table_s {
const char *name;
const char **tab;
int len;
} index_table_t;
enum {
WS_QUOTIENT = 0x40,
WS_PRODUCT_LOW32 = 0x40,
WS_REMAINDER,
WS_PRODUCT_HI32_XXX = 0x41,
WS_DATAPTR,
WS_SHIFT,
WS_OR_MASK,
WS_AND_MASK,
WS_FB_WINDOW,
WS_ATTRIBUTES,
WS_REGPTR
};
enum {
D_REG = 0,
D_PS,
D_WS,
D_FB,
D_ID,
D_IM,
D_PLL,
D_MC,
D_hex8,
D_hex16,
D_null
};
enum {
INDEX_NONE = 0,
INDEX_COMMAND_TABLE,
INDEX_DATA_TABLE,
INDEX_ATI_PORT,
INDEX_WORK_REG,
INDEX_REG_MM,
INDEX_REG_PLL,
INDEX_REG_MC,
INDEX_REG_PCIE,
INDEX_REG_PCICONFIG,
INDEX_REG_SYSTEMIO,
INDEXTABLE_SIZEOF
};
typedef struct {
int (*process) (const ut8 *d, char *out);
const char *name;
const char *esilop;
ut8 desttype;
ut8 srcindex;
ut8 destindex;
} optab_t;
int atombios_inst_len(const ut8 *buf);
int atombios_disassemble(const ut8 *inbuf, char *outbuf);
const char *get_index (int type, int val);
extern const char *align_source_esil[];
extern const char *align_byte_esil[];
extern const char *align_word_esil[];
extern const char *align_long_esil[];
extern const char *addrtypes_esil[];
extern const char *align_source[];
extern const char *align_byte[];
extern const char *align_word[];
extern const char *align_long[];
extern const int size_align[];
extern const char *addrnames[];
extern const char *addrtypes[];
extern int addrtypes_shift[];
extern const char *addrtypes_im[];
extern const char *index_command_table[];
extern const char *index_data_table[];
extern const char *index_ati_port[];
extern const char *index_work_reg[];
#define TABENTRY(x) { #x, (index_ ## x), sizeof (index_ ## x) / sizeof (const char **) }
extern index_table_t index_tables[INDEXTABLE_SIZEOF];
extern const optab_t optable[256];
#endif
+255
View File
@@ -0,0 +1,255 @@
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdarg.h>
#include <sys/types.h>
#include "evm.h"
const EvmOpDef opcodes[256] = {
[EVM_OP_STOP] = { "stop", 1 },
[EVM_OP_ADD] = { "add", 1 },
[EVM_OP_MUL] = { "mul", 1 },
[EVM_OP_SUB] = { "sub", 1 },
[EVM_OP_DIV] = { "div", 1 },
[EVM_OP_SDIV] = { "sdiv", 1 },
[EVM_OP_MOD] = { "mod", 1 },
[EVM_OP_SMOD] = { "smod", 1 },
[EVM_OP_ADDMOD] = { "addmod", 1 },
[EVM_OP_MULMOD] = { "mulmod", 1 },
[EVM_OP_EXP] = { "exp", 1 },
[EVM_OP_SIGNEXTEND] = { "signextend", 1 },
[EVM_OP_LT] = { "lt", 1 },
[EVM_OP_GT] = { "gt", 1 },
[EVM_OP_SLT] = { "slt", 1 },
[EVM_OP_SGT] = { "sgt", 1 },
[EVM_OP_EQ] = { "eq", 1 },
[EVM_OP_ISZERO] = { "iszero", 1 },
[EVM_OP_AND] = { "and", 1 },
[EVM_OP_OR] = { "or", 1 },
[EVM_OP_XOR] = { "xor", 1 },
[EVM_OP_NOT] = { "not", 1 },
[EVM_OP_BYTE] = { "byte", 1 },
[EVM_OP_SHA3] = { "sha3", 1 },
[EVM_OP_ADDRESS] = { "address", 1 },
[EVM_OP_BALANCE] = { "balance", 1 },
[EVM_OP_ORIGIN] = { "origin", 1 },
[EVM_OP_CALLER] = { "caller", 1 },
[EVM_OP_CALLVALUE] = { "callvalue", 1 },
[EVM_OP_CALLDATALOAD] = { "calldataload", 1 },
[EVM_OP_CALLDATASIZE] = { "calldatasize", 1 },
[EVM_OP_CALLDATACOPY] = { "calldatacopy", 1 },
[EVM_OP_CODESIZE] = { "codesize", 1 },
[EVM_OP_CODECOPY] = { "codecopy", 1 },
[EVM_OP_GASPRICE] = { "gasprice", 1 },
[EVM_OP_EXTCODESIZE] = { "extcodesize", 1 },
[EVM_OP_EXTCODECOPY] = { "extcodecopy", 1 },
[EVM_OP_RETURNDATASIZE] = { "returndatasize", 1},
[EVM_OP_RETURNDATACOPY] = { "returndatacopy", 1},
[EVM_OP_BLOCKHASH] = { "blockhash", 1 },
[EVM_OP_COINBASE] = { "coinbase", 1 },
[EVM_OP_TIMESTAMP] = { "timestamp", 1 },
[EVM_OP_NUMBER] = { "number", 1 },
[EVM_OP_DIFFICULTY] = { "difficulty", 1 },
[EVM_OP_GASLIMIT] = { "gaslimit", 1 },
[EVM_OP_POP] = { "pop", 1 },
[EVM_OP_MLOAD] = { "mload", 1 },
[EVM_OP_MSTORE] = { "mstore", 1 },
[EVM_OP_MSTORE8] = { "mstore8", 1 },
[EVM_OP_SLOAD] = { "sload", 1 },
[EVM_OP_SSTORE] = { "sstore", 1 },
[EVM_OP_JUMP] = { "jump", 1 },
[EVM_OP_JUMPI] = { "jumpi", 1 },
[EVM_OP_PC] = { "pc", 1 },
[EVM_OP_MSIZE] = { "msize", 1 },
[EVM_OP_GAS] = { "gas", 1 },
[EVM_OP_JUMPDEST] = { "jumpdest", 1 },
// ....
[EVM_OP_CREATE] = { "create", 1 },
[EVM_OP_CALL] = { "call", 1 },
[EVM_OP_CALLCODE] = { "callcode", 1 },
[EVM_OP_RETURN] = { "return", 1 },
[EVM_OP_DELEGATECALL] = { "delegatecall", 1 },
[EVM_OP_STATICCALL] = { "staticcall", 1 },
[EVM_OP_REVERT] = { "revert", 1 },
[EVM_OP_SELFDESTRUCT] = { "selfdestruct", 1 },
};
static void settxtf(EvmOp *op, const char *fmt, ...) {
if (strchr (fmt, '%')) {
va_list ap;
va_start (ap, fmt);
op->txt = op->txt_buf;
vsnprintf (op->txt_buf, sizeof (op->txt_buf), fmt, ap);
va_end (ap);
} else {
op->txt = fmt;
}
}
int evm_asm(const char *str, RStrBuf *buf, int buf_len) {
int i, len = -1;
for (i = 0; i < 0xff; i++) {
const EvmOpDef *opdef = &opcodes[i];
if (opdef->txt) {
if (!strcmp (opdef->txt, str)) {
r_strbuf_appendf (buf, "%d", i);
return 1;
}
}
}
// TODO: add support for: push, swap, dup, log
return len;
}
int evm_dis(EvmOp *op, const unsigned char *buf, int buf_len) {
op->len = 1;
op->op = buf[0];
const EvmOpDef *opdef = &opcodes[buf[0]];
if (opdef->txt) {
op->txt = opdef->txt;
op->len = opdef->len;
if (op->len < 1) {
op->len = 1;
}
return op->len;
}
switch (op->op) {
case EVM_OP_PUSH1:
case EVM_OP_PUSH2:
case EVM_OP_PUSH3:
case EVM_OP_PUSH4:
case EVM_OP_PUSH5:
case EVM_OP_PUSH6:
case EVM_OP_PUSH7:
case EVM_OP_PUSH8:
case EVM_OP_PUSH9:
case EVM_OP_PUSH10:
case EVM_OP_PUSH11:
case EVM_OP_PUSH12:
case EVM_OP_PUSH13:
case EVM_OP_PUSH14:
case EVM_OP_PUSH15:
case EVM_OP_PUSH16:
case EVM_OP_PUSH17:
case EVM_OP_PUSH18:
case EVM_OP_PUSH19:
case EVM_OP_PUSH20:
case EVM_OP_PUSH21:
case EVM_OP_PUSH22:
case EVM_OP_PUSH23:
case EVM_OP_PUSH24:
case EVM_OP_PUSH25:
case EVM_OP_PUSH26:
case EVM_OP_PUSH27:
case EVM_OP_PUSH28:
case EVM_OP_PUSH29:
case EVM_OP_PUSH30:
case EVM_OP_PUSH31:
case EVM_OP_PUSH32:
{
int pushSize = buf[0] - EVM_OP_PUSH1;
char hexbuf[64] = {0};
int res = r_hex_bin2str (buf + 1, pushSize + 1, hexbuf);
if (res < 1 || !*hexbuf) {
strcpy (hexbuf, "0");
}
settxtf (op, "push%d 0x%s", pushSize + 1, hexbuf);
op->len = 2 + pushSize;
}
break;
case EVM_OP_DUP1:
case EVM_OP_DUP2:
case EVM_OP_DUP3:
case EVM_OP_DUP4:
case EVM_OP_DUP5:
case EVM_OP_DUP6:
case EVM_OP_DUP7:
case EVM_OP_DUP8:
case EVM_OP_DUP9:
case EVM_OP_DUP10:
case EVM_OP_DUP11:
case EVM_OP_DUP12:
case EVM_OP_DUP13:
case EVM_OP_DUP14:
case EVM_OP_DUP15:
case EVM_OP_DUP16:
{
int dupSize = buf[0] - EVM_OP_DUP1 + 1;
settxtf (op, "dup%d", dupSize);
op->len = 1;
}
break;
case EVM_OP_SWAP1:
case EVM_OP_SWAP2:
case EVM_OP_SWAP3:
case EVM_OP_SWAP4:
case EVM_OP_SWAP5:
case EVM_OP_SWAP6:
case EVM_OP_SWAP7:
case EVM_OP_SWAP8:
case EVM_OP_SWAP9:
case EVM_OP_SWAP10:
case EVM_OP_SWAP11:
case EVM_OP_SWAP12:
case EVM_OP_SWAP13:
case EVM_OP_SWAP14:
case EVM_OP_SWAP15:
case EVM_OP_SWAP16:
{
int swapSize = buf[0] - EVM_OP_SWAP1 + 1;
settxtf (op, "swap%d", swapSize);
op->len = 1;
}
break;
case EVM_OP_LOG0:
case EVM_OP_LOG1:
case EVM_OP_LOG2:
case EVM_OP_LOG3:
case EVM_OP_LOG4:
{
int logSize = buf[0] - EVM_OP_LOG0;
settxtf (op, "log%d", logSize);
op->len = 1;
}
break;
default:
settxtf (op, "invalid");
op->len = 0;
break;
}
return op->len;
}
typedef const unsigned char *buf_t;
#if HAS_MAIN
int main() {
#if 0
[1] 6060 PUSH1 0x60
[3] 6040 PUSH1 0x40
[4] 52 MSTORE
[5] 36 CALLDATASIZE
[6] 15 ISZERO// WRONG ?? should be 11
[9] PUSH2 0x00da
[10] JUMPI
[12] PUSH1 0xe0
[14] PUSH1 0x02
[15] EXP
#endif
int i;
EvmOp op = {
0
};
buf_t b = (buf_t) "\x60\x60\x60\x40\x52\x36\x15\x61\x00\xda\x57\x60\xe0\x60\x02";
for (i = 0; i < sizeof (b); i++) {
evm_dis (&op, b + i, sizeof (b) - i);
printf ("len=%d op=0x%02x %s\n", op.len, op.op, op.txt);
if (op.len < 1) {
break;
}
i += op.len - 1;
}
return 0;
}
#endif
+166
View File
@@ -0,0 +1,166 @@
#ifndef EVM_EVM_H
#define EVM_EVM_H
#include <r_util.h>
typedef enum {
EVM_OP_STOP = 0x00,
EVM_OP_ADD,
EVM_OP_MUL,
EVM_OP_SUB,
EVM_OP_DIV,
EVM_OP_SDIV,
EVM_OP_MOD,
EVM_OP_SMOD,
EVM_OP_ADDMOD,
EVM_OP_MULMOD,
EVM_OP_EXP,
EVM_OP_SIGNEXTEND,
EVM_OP_LT = 0x10,
EVM_OP_GT,
EVM_OP_SLT,
EVM_OP_SGT,
EVM_OP_EQ,
EVM_OP_ISZERO,
EVM_OP_AND,
EVM_OP_OR,
EVM_OP_XOR,
EVM_OP_NOT,
EVM_OP_BYTE,
EVM_OP_SHA3 = 0x20,
EVM_OP_ADDRESS = 0x30,
EVM_OP_BALANCE,
EVM_OP_ORIGIN,
EVM_OP_CALLER,
EVM_OP_CALLVALUE,
EVM_OP_CALLDATALOAD,
EVM_OP_CALLDATASIZE,
EVM_OP_CALLDATACOPY,
EVM_OP_CODESIZE,
EVM_OP_CODECOPY,
EVM_OP_GASPRICE,
EVM_OP_EXTCODESIZE,
EVM_OP_EXTCODECOPY,
EVM_OP_RETURNDATASIZE,
EVM_OP_RETURNDATACOPY,
EVM_OP_BLOCKHASH = 0x40,
EVM_OP_COINBASE,
EVM_OP_TIMESTAMP,
EVM_OP_NUMBER,
EVM_OP_DIFFICULTY,
EVM_OP_GASLIMIT,
EVM_OP_POP = 0x50,
EVM_OP_MLOAD,
EVM_OP_MSTORE,
EVM_OP_MSTORE8,
EVM_OP_SLOAD,
EVM_OP_SSTORE,
EVM_OP_JUMP,
EVM_OP_JUMPI,
EVM_OP_PC,
EVM_OP_MSIZE,
EVM_OP_GAS,
EVM_OP_JUMPDEST,
EVM_OP_PUSH1 = 0x60,
EVM_OP_PUSH2,
EVM_OP_PUSH3,
EVM_OP_PUSH4,
EVM_OP_PUSH5,
EVM_OP_PUSH6,
EVM_OP_PUSH7,
EVM_OP_PUSH8,
EVM_OP_PUSH9,
EVM_OP_PUSH10,
EVM_OP_PUSH11,
EVM_OP_PUSH12,
EVM_OP_PUSH13,
EVM_OP_PUSH14,
EVM_OP_PUSH15,
EVM_OP_PUSH16,
EVM_OP_PUSH17,
EVM_OP_PUSH18,
EVM_OP_PUSH19,
EVM_OP_PUSH20,
EVM_OP_PUSH21,
EVM_OP_PUSH22,
EVM_OP_PUSH23,
EVM_OP_PUSH24,
EVM_OP_PUSH25,
EVM_OP_PUSH26,
EVM_OP_PUSH27,
EVM_OP_PUSH28,
EVM_OP_PUSH29,
EVM_OP_PUSH30,
EVM_OP_PUSH31,
EVM_OP_PUSH32,
EVM_OP_DUP1,
EVM_OP_DUP2,
EVM_OP_DUP3,
EVM_OP_DUP4,
EVM_OP_DUP5,
EVM_OP_DUP6,
EVM_OP_DUP7,
EVM_OP_DUP8,
EVM_OP_DUP9,
EVM_OP_DUP10,
EVM_OP_DUP11,
EVM_OP_DUP12,
EVM_OP_DUP13,
EVM_OP_DUP14,
EVM_OP_DUP15,
EVM_OP_DUP16,
EVM_OP_SWAP1,
EVM_OP_SWAP2,
EVM_OP_SWAP3,
EVM_OP_SWAP4,
EVM_OP_SWAP5,
EVM_OP_SWAP6,
EVM_OP_SWAP7,
EVM_OP_SWAP8,
EVM_OP_SWAP9,
EVM_OP_SWAP10,
EVM_OP_SWAP11,
EVM_OP_SWAP12,
EVM_OP_SWAP13,
EVM_OP_SWAP14,
EVM_OP_SWAP15,
EVM_OP_SWAP16,
EVM_OP_LOG0 = 0xa0,
EVM_OP_LOG1,
EVM_OP_LOG2,
EVM_OP_LOG3,
EVM_OP_LOG4,
EVM_OP_CREATE = 0xf0,
EVM_OP_CALL,
EVM_OP_CALLCODE,
EVM_OP_RETURN,
EVM_OP_DELEGATECALL,
EVM_OP_STATICCALL = 0xfa,
EVM_OP_REVERT = 0xfd,
EVM_OP_SELFDESTRUCT = 0xff
} EvmOpcodes;
typedef struct EvmOp {
EvmOpcodes op;
int len;
const char *txt;
char txt_buf[32];
} EvmOp;
typedef struct {
const char *txt;
int len;
} EvmOpDef;
extern const EvmOpDef opcodes[256];
int evm_dis(EvmOp *op, const unsigned char *buf, int buf_len);
int evm_asm(const char *str, RStrBuf *buf, int buf_len);
#endif /* EVM_EVM_H */
+1
View File
@@ -274,6 +274,7 @@ extern int print_insn_mn10300 (bfd_vma, disassemble_info *);
extern int print_insn_moxie (bfd_vma, disassemble_info *);
extern int print_insn_msp430 (bfd_vma, disassemble_info *);
extern int print_insn_mt (bfd_vma, disassemble_info *);
extern int print_insn_nios (bfd_vma, disassemble_info *);
extern int print_insn_ns32k (bfd_vma, disassemble_info *);
extern int print_insn_openrisc (bfd_vma, disassemble_info *);
extern int print_insn_pdp11 (bfd_vma, disassemble_info *);
+57
View File
@@ -0,0 +1,57 @@
/* NIOS ELF support for BFD.
Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#ifndef _ELF_NIOS_H
#define _ELF_NIOS_H
#include "elf/reloc-macros.h"
/* Relocations. */
START_RELOC_NUMBERS (elf_nios_reloc_type)
RELOC_NUMBER (R_NIOS_NONE, 0)
RELOC_NUMBER (R_NIOS_32, 1)
RELOC_NUMBER (R_NIOS_LO16_LO5, 2)
RELOC_NUMBER (R_NIOS_LO16_HI11, 3)
RELOC_NUMBER (R_NIOS_HI16_LO5, 4)
RELOC_NUMBER (R_NIOS_HI16_HI11, 5)
RELOC_NUMBER (R_NIOS_PCREL6, 6)
RELOC_NUMBER (R_NIOS_PCREL8, 7)
RELOC_NUMBER (R_NIOS_PCREL11, 8)
RELOC_NUMBER (R_NIOS_16, 9)
RELOC_NUMBER (R_NIOS_H_LO5, 10)
RELOC_NUMBER (R_NIOS_H_HI11,11)
RELOC_NUMBER (R_NIOS_H_XLO5, 12)
RELOC_NUMBER (R_NIOS_H_XHI11, 13)
RELOC_NUMBER (R_NIOS_H_16, 14)
RELOC_NUMBER (R_NIOS_H_32, 15)
RELOC_NUMBER (R_NIOS_GNU_VTINHERIT, 200)
RELOC_NUMBER (R_NIOS_GNU_VTENTRY, 201)
EMPTY_RELOC (R_NIOS_max)
END_RELOC_NUMBERS
#define EF_NIOS_CPU_16 0x00000001 /* nios16 */
#define EF_NIOS_CPU_32 0x00000002 /* nios32 */
#define EF_NIOS_CPU_MASK 0x00000003 /* specific cpu bits */
#define EF_NIOS_ALL_FLAGS (EF_NIOS_CPU_MASK)
#endif /* _ELF_NIOS_H */
+18
View File
@@ -1927,6 +1927,9 @@ enum bfd_architecture
#define bfd_mach_mn10300 300
#define bfd_mach_am33 330
#define bfd_mach_am33_2 332
bfd_arch_nios,
#define bfd_mach_nios16 0
#define bfd_mach_nios32 1
bfd_arch_fr30,
#define bfd_mach_fr30 0x46523330
bfd_arch_frv,
@@ -3434,6 +3437,21 @@ significant 7 bits of a 23-bit extended address are placed into
the opcode. */
BFD_RELOC_TIC54X_MS7_OF_23,
/* Altera Nios Relocations. */
BFD_RELOC_NIOS_LO16_LO5,
BFD_RELOC_NIOS_LO16_HI11,
BFD_RELOC_NIOS_HI16_LO5,
BFD_RELOC_NIOS_HI16_HI11,
BFD_RELOC_NIOS_PCREL6,
BFD_RELOC_NIOS_PCREL8,
BFD_RELOC_NIOS_PCREL11,
BFD_RELOC_NIOS_H_LO5,
BFD_RELOC_NIOS_H_HI11,
BFD_RELOC_NIOS_H_XLO5,
BFD_RELOC_NIOS_H_XHI11,
BFD_RELOC_NIOS_H_16,
BFD_RELOC_NIOS_H_32,
/* This is a 48 bit reloc for the FR30 that stores 32 bits. */
BFD_RELOC_FR30_48,
+150
View File
@@ -0,0 +1,150 @@
/* <ctype.h> replacement macros.
Copyright (C) 2000-2018 Free Software Foundation, Inc.
Contributed by Zack Weinberg <[email protected]>.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
Libiberty is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with libiberty; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
Boston, MA 02110-1301, USA. */
/* This is a compatible replacement of the standard C library's <ctype.h>
with the following properties:
- Implements all isxxx() macros required by C99.
- Also implements some character classes useful when
parsing C-like languages.
- Does not change behavior depending on the current locale.
- Behaves properly for all values in the range of a signed or
unsigned char.
To avoid conflicts, this header defines the isxxx functions in upper
case, e.g. ISALPHA not isalpha. */
#ifndef SAFE_CTYPE_H
#define SAFE_CTYPE_H
/* Determine host character set. */
#define HOST_CHARSET_UNKNOWN 0
#define HOST_CHARSET_ASCII 1
#define HOST_CHARSET_EBCDIC 2
#if '\n' == 0x0A && ' ' == 0x20 && '0' == 0x30 \
&& 'A' == 0x41 && 'a' == 0x61 && '!' == 0x21
# define HOST_CHARSET HOST_CHARSET_ASCII
#else
# if '\n' == 0x15 && ' ' == 0x40 && '0' == 0xF0 \
&& 'A' == 0xC1 && 'a' == 0x81 && '!' == 0x5A
# define HOST_CHARSET HOST_CHARSET_EBCDIC
# else
# define HOST_CHARSET HOST_CHARSET_UNKNOWN
# endif
#endif
/* Categories. */
enum {
/* In C99 */
_sch_isblank = 0x0001, /* space \t */
_sch_iscntrl = 0x0002, /* nonprinting characters */
_sch_isdigit = 0x0004, /* 0-9 */
_sch_islower = 0x0008, /* a-z */
_sch_isprint = 0x0010, /* any printing character including ' ' */
_sch_ispunct = 0x0020, /* all punctuation */
_sch_isspace = 0x0040, /* space \t \n \r \f \v */
_sch_isupper = 0x0080, /* A-Z */
_sch_isxdigit = 0x0100, /* 0-9A-Fa-f */
/* Extra categories useful to cpplib. */
_sch_isidst = 0x0200, /* A-Za-z_ */
_sch_isvsp = 0x0400, /* \n \r */
_sch_isnvsp = 0x0800, /* space \t \f \v \0 */
/* Combinations of the above. */
_sch_isalpha = _sch_isupper|_sch_islower, /* A-Za-z */
_sch_isalnum = _sch_isalpha|_sch_isdigit, /* A-Za-z0-9 */
_sch_isidnum = _sch_isidst|_sch_isdigit, /* A-Za-z0-9_ */
_sch_isgraph = _sch_isalnum|_sch_ispunct, /* isprint and not space */
_sch_iscppsp = _sch_isvsp|_sch_isnvsp, /* isspace + \0 */
_sch_isbasic = _sch_isprint|_sch_iscppsp /* basic charset of ISO C
(plus ` and @) */
};
/* Character classification. */
extern const unsigned short _sch_istable[256];
#define _sch_test(c, bit) (_sch_istable[(c) & 0xff] & (unsigned short)(bit))
#define ISALPHA(c) _sch_test(c, _sch_isalpha)
#define ISALNUM(c) _sch_test(c, _sch_isalnum)
#define ISBLANK(c) _sch_test(c, _sch_isblank)
#define ISCNTRL(c) _sch_test(c, _sch_iscntrl)
#define ISDIGIT(c) _sch_test(c, _sch_isdigit)
#define ISGRAPH(c) _sch_test(c, _sch_isgraph)
#define ISLOWER(c) _sch_test(c, _sch_islower)
#define ISPRINT(c) _sch_test(c, _sch_isprint)
#define ISPUNCT(c) _sch_test(c, _sch_ispunct)
#define ISSPACE(c) _sch_test(c, _sch_isspace)
#define ISUPPER(c) _sch_test(c, _sch_isupper)
#define ISXDIGIT(c) _sch_test(c, _sch_isxdigit)
#define ISIDNUM(c) _sch_test(c, _sch_isidnum)
#define ISIDST(c) _sch_test(c, _sch_isidst)
#define IS_ISOBASIC(c) _sch_test(c, _sch_isbasic)
#define IS_VSPACE(c) _sch_test(c, _sch_isvsp)
#define IS_NVSPACE(c) _sch_test(c, _sch_isnvsp)
#define IS_SPACE_OR_NUL(c) _sch_test(c, _sch_iscppsp)
/* Character transformation. */
extern const unsigned char _sch_toupper[256];
extern const unsigned char _sch_tolower[256];
#define TOUPPER(c) _sch_toupper[(c) & 0xff]
#define TOLOWER(c) _sch_tolower[(c) & 0xff]
/* Prevent the users of safe-ctype.h from accidently using the routines
from ctype.h. Initially, the approach was to produce an error when
detecting that ctype.h has been included. But this was causing
trouble as ctype.h might get indirectly included as a result of
including another system header (for instance gnulib's stdint.h).
So we include ctype.h here and then immediately redefine its macros. */
#include <ctype.h>
#undef isalpha
#define isalpha(c) do_not_use_isalpha_with_safe_ctype
#undef isalnum
#define isalnum(c) do_not_use_isalnum_with_safe_ctype
#undef iscntrl
#define iscntrl(c) do_not_use_iscntrl_with_safe_ctype
#undef isdigit
#define isdigit(c) do_not_use_isdigit_with_safe_ctype
#undef isgraph
#define isgraph(c) do_not_use_isgraph_with_safe_ctype
#undef islower
#define islower(c) do_not_use_islower_with_safe_ctype
#undef isprint
#define isprint(c) do_not_use_isprint_with_safe_ctype
#undef ispunct
#define ispunct(c) do_not_use_ispunct_with_safe_ctype
#undef isspace
#define isspace(c) do_not_use_isspace_with_safe_ctype
#undef isupper
#define isupper(c) do_not_use_isupper_with_safe_ctype
#undef isxdigit
#define isxdigit(c) do_not_use_isxdigit_with_safe_ctype
#undef toupper
#define toupper(c) do_not_use_toupper_with_safe_ctype
#undef tolower
#define tolower(c) do_not_use_tolower_with_safe_ctype
#endif /* SAFE_CTYPE_H */
+29
View File
@@ -0,0 +1,29 @@
/* This file redefines all regex external names before including
a renamed copy of glibc's regex.h. */
#ifndef _XREGEX_H
#define _XREGEX_H 1
# define regfree xregfree
# define regexec xregexec
# define regcomp xregcomp
# define regerror xregerror
# define regoff_t xregoff_t
# define re_set_registers xre_set_registers
# define re_match_2 xre_match_2
# define re_match xre_match
# define re_search xre_search
# define re_compile_pattern xre_compile_pattern
# define re_set_syntax xre_set_syntax
# define re_search_2 xre_search_2
# define re_compile_fastmap xre_compile_fastmap
# define re_syntax_options xre_syntax_options
# define re_max_failures xre_max_failures
# define _REGEX_RE_COMP
# define re_comp xre_comp
# define re_exec xre_exec
#include "xregex2.h"
#endif /* xregex.h */
+564
View File
@@ -0,0 +1,564 @@
/* Definitions for data structures and routines for the regular
expression library, version 0.12.
Copyright (C) 1985-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library. Its master source is NOT part of
the C library, however. The master source lives in /gd/gnu/lib.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA. */
#ifndef _REGEX_H
#define _REGEX_H 1
/* Allow the use in C++ code. */
#ifdef __cplusplus
extern "C" {
#endif
/* POSIX says that <sys/types.h> must be included (by the caller) before
<regex.h>. */
#if !defined _POSIX_C_SOURCE && !defined _POSIX_SOURCE && defined VMS
/* VMS doesn't have `size_t' in <sys/types.h>, even though POSIX says it
should be there. */
# include <stddef.h>
#endif
/* The following two types have to be signed and unsigned integer type
wide enough to hold a value of a pointer. For most ANSI compilers
ptrdiff_t and size_t should be likely OK. Still size of these two
types is 2 for Microsoft C. Ugh... */
typedef long int s_reg_t;
typedef unsigned long int active_reg_t;
/* The following bits are used to determine the regexp syntax we
recognize. The set/not-set meanings are chosen so that Emacs syntax
remains the value 0. The bits are given in alphabetical order, and
the definitions shifted by one from the previous bit; thus, when we
add or remove a bit, only one other definition need change. */
typedef unsigned long int reg_syntax_t;
/* If this bit is not set, then \ inside a bracket expression is literal.
If set, then such a \ quotes the following character. */
#define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1)
/* If this bit is not set, then + and ? are operators, and \+ and \? are
literals.
If set, then \+ and \? are operators and + and ? are literals. */
#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
/* If this bit is set, then character classes are supported. They are:
[:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:],
[:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
If not set, then character classes are not supported. */
#define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
/* If this bit is set, then ^ and $ are always anchors (outside bracket
expressions, of course).
If this bit is not set, then it depends:
^ is an anchor if it is at the beginning of a regular
expression or after an open-group or an alternation operator;
$ is an anchor if it is at the end of a regular expression, or
before a close-group or an alternation operator.
This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
POSIX draft 11.2 says that * etc. in leading positions is undefined.
We already implemented a previous draft which made those constructs
invalid, though, so we haven't changed the code back. */
#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
/* If this bit is set, then special characters are always special
regardless of where they are in the pattern.
If this bit is not set, then special characters are special only in
some contexts; otherwise they are ordinary. Specifically,
* + ? and intervals are only special when not after the beginning,
open-group, or alternation operator. */
#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
/* If this bit is set, then *, +, ?, and { cannot be first in an re or
immediately after an alternation or begin-group operator. */
#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
/* If this bit is set, then . matches newline.
If not set, then it doesn't. */
#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
/* If this bit is set, then . doesn't match NUL.
If not set, then it does. */
#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
/* If this bit is set, nonmatching lists [^...] do not match newline.
If not set, they do. */
#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
/* If this bit is set, either \{...\} or {...} defines an
interval, depending on RE_NO_BK_BRACES.
If not set, \{, \}, {, and } are literals. */
#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
/* If this bit is set, +, ? and | aren't recognized as operators.
If not set, they are. */
#define RE_LIMITED_OPS (RE_INTERVALS << 1)
/* If this bit is set, newline is an alternation operator.
If not set, newline is literal. */
#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
/* If this bit is set, then `{...}' defines an interval, and \{ and \}
are literals.
If not set, then `\{...\}' defines an interval. */
#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
/* If this bit is set, (...) defines a group, and \( and \) are literals.
If not set, \(...\) defines a group, and ( and ) are literals. */
#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
/* If this bit is set, then \<digit> matches <digit>.
If not set, then \<digit> is a back-reference. */
#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
/* If this bit is set, then | is an alternation operator, and \| is literal.
If not set, then \| is an alternation operator, and | is literal. */
#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
/* If this bit is set, then an ending range point collating higher
than the starting range point, as in [z-a], is invalid.
If not set, then when ending range point collates higher than the
starting range point, the range is ignored. */
#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
/* If this bit is set, then an unmatched ) is ordinary.
If not set, then an unmatched ) is invalid. */
#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
/* If this bit is set, succeed as soon as we match the whole pattern,
without further backtracking. */
#define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
/* If this bit is set, do not process the GNU regex operators.
If not set, then the GNU regex operators are recognized. */
#define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1)
/* If this bit is set, turn on internal regex debugging.
If not set, and debugging was on, turn it off.
This only works if regex.c is compiled -DDEBUG.
We define this bit always, so that all that's needed to turn on
debugging is to recompile regex.c; the calling code can always have
this bit set, and it won't affect anything in the normal case. */
#define RE_DEBUG (RE_NO_GNU_OPS << 1)
/* If this bit is set, a syntactically invalid interval is treated as
a string of ordinary characters. For example, the ERE 'a{1' is
treated as 'a\{1'. */
#define RE_INVALID_INTERVAL_ORD (RE_DEBUG << 1)
/* This global variable defines the particular regexp syntax to use (for
some interfaces). When a regexp is compiled, the syntax used is
stored in the pattern buffer, so changing this does not affect
already-compiled regexps. */
extern reg_syntax_t re_syntax_options;
/* Define combinations of the above bits for the standard possibilities.
(The [[[ comments delimit what gets put into the Texinfo file, so
don't delete them!) */
/* [[[begin syntaxes]]] */
#define RE_SYNTAX_EMACS 0
#define RE_SYNTAX_AWK \
(RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \
| RE_NO_BK_PARENS | RE_NO_BK_REFS \
| RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \
| RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \
| RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS)
#define RE_SYNTAX_GNU_AWK \
((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DEBUG) \
& ~(RE_DOT_NOT_NULL | RE_INTERVALS | RE_CONTEXT_INDEP_OPS))
#define RE_SYNTAX_POSIX_AWK \
(RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \
| RE_INTERVALS | RE_NO_GNU_OPS)
#define RE_SYNTAX_GREP \
(RE_BK_PLUS_QM | RE_CHAR_CLASSES \
| RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \
| RE_NEWLINE_ALT)
#define RE_SYNTAX_EGREP \
(RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \
| RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \
| RE_NEWLINE_ALT | RE_NO_BK_PARENS \
| RE_NO_BK_VBAR)
#define RE_SYNTAX_POSIX_EGREP \
(RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES \
| RE_INVALID_INTERVAL_ORD)
/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */
#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC
/* Syntax bits common to both basic and extended POSIX regex syntax. */
#define _RE_SYNTAX_POSIX_COMMON \
(RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \
| RE_INTERVALS | RE_NO_EMPTY_RANGES)
#define RE_SYNTAX_POSIX_BASIC \
(_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM)
/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes
RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this
isn't minimal, since other operators, such as \`, aren't disabled. */
#define RE_SYNTAX_POSIX_MINIMAL_BASIC \
(_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)
#define RE_SYNTAX_POSIX_EXTENDED \
(_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
| RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \
| RE_NO_BK_PARENS | RE_NO_BK_VBAR \
| RE_CONTEXT_INVALID_OPS | RE_UNMATCHED_RIGHT_PAREN_ORD)
/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INDEP_OPS is
removed and RE_NO_BK_REFS is added. */
#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \
(_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \
| RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \
| RE_NO_BK_PARENS | RE_NO_BK_REFS \
| RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD)
/* [[[end syntaxes]]] */
/* Maximum number of duplicates an interval can allow. Some systems
(erroneously) define this in other header files, but we want our
value, so remove any previous define. */
#ifdef RE_DUP_MAX
# undef RE_DUP_MAX
#endif
/* If sizeof(int) == 2, then ((1 << 15) - 1) overflows. */
#define RE_DUP_MAX (0x7fff)
/* POSIX `cflags' bits (i.e., information for `regcomp'). */
/* If this bit is set, then use extended regular expression syntax.
If not set, then use basic regular expression syntax. */
#define REG_EXTENDED 1
/* If this bit is set, then ignore case when matching.
If not set, then case is significant. */
#define REG_ICASE (REG_EXTENDED << 1)
/* If this bit is set, then anchors do not match at newline
characters in the string.
If not set, then anchors do match at newlines. */
#define REG_NEWLINE (REG_ICASE << 1)
/* If this bit is set, then report only success or fail in regexec.
If not set, then returns differ between not matching and errors. */
#define REG_NOSUB (REG_NEWLINE << 1)
/* POSIX `eflags' bits (i.e., information for regexec). */
/* If this bit is set, then the beginning-of-line operator doesn't match
the beginning of the string (presumably because it's not the
beginning of a line).
If not set, then the beginning-of-line operator does match the
beginning of the string. */
#define REG_NOTBOL 1
/* Like REG_NOTBOL, except for the end-of-line. */
#define REG_NOTEOL (1 << 1)
/* If any error codes are removed, changed, or added, update the
`re_error_msg' table in regex.c. */
typedef enum
{
#ifdef _XOPEN_SOURCE
REG_ENOSYS = -1, /* This will never happen for this implementation. */
#endif
REG_NOERROR = 0, /* Success. */
REG_NOMATCH, /* Didn't find a match (for regexec). */
/* POSIX regcomp return error codes. (In the order listed in the
standard.) */
REG_BADPAT, /* Invalid pattern. */
REG_ECOLLATE, /* Not implemented. */
REG_ECTYPE, /* Invalid character class name. */
REG_EESCAPE, /* Trailing backslash. */
REG_ESUBREG, /* Invalid back reference. */
REG_EBRACK, /* Unmatched left bracket. */
REG_EPAREN, /* Parenthesis imbalance. */
REG_EBRACE, /* Unmatched \{. */
REG_BADBR, /* Invalid contents of \{\}. */
REG_ERANGE, /* Invalid range end. */
REG_ESPACE, /* Ran out of memory. */
REG_BADRPT, /* No preceding re for repetition op. */
/* Error codes we've added. */
REG_EEND, /* Premature end. */
REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */
REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */
} reg_errcode_t;
/* This data structure represents a compiled pattern. Before calling
the pattern compiler, the fields `buffer', `allocated', `fastmap',
`translate', and `no_sub' can be set. After the pattern has been
compiled, the `re_nsub' field is available. All other fields are
private to the regex routines. */
#ifndef RE_TRANSLATE_TYPE
# define RE_TRANSLATE_TYPE char *
#endif
struct re_pattern_buffer
{
/* [[[begin pattern_buffer]]] */
/* Space that holds the compiled pattern. It is declared as
`unsigned char *' because its elements are
sometimes used as array indexes. */
unsigned char *buffer;
/* Number of bytes to which `buffer' points. */
unsigned long int allocated;
/* Number of bytes actually used in `buffer'. */
unsigned long int used;
/* Syntax setting with which the pattern was compiled. */
reg_syntax_t syntax;
/* Pointer to a fastmap, if any, otherwise zero. re_search uses
the fastmap, if there is one, to skip over impossible
starting points for matches. */
char *fastmap;
/* Either a translate table to apply to all characters before
comparing them, or zero for no translation. The translation
is applied to a pattern when it is compiled and to a string
when it is matched. */
RE_TRANSLATE_TYPE translate;
/* Number of subexpressions found by the compiler. */
size_t re_nsub;
/* Zero if this pattern cannot match the empty string, one else.
Well, in truth it's used only in `re_search_2', to see
whether or not we should use the fastmap, so we don't set
this absolutely perfectly; see `re_compile_fastmap' (the
`duplicate' case). */
unsigned can_be_null : 1;
/* If REGS_UNALLOCATED, allocate space in the `regs' structure
for `max (RE_NREGS, re_nsub + 1)' groups.
If REGS_REALLOCATE, reallocate space if necessary.
If REGS_FIXED, use what's there. */
#define REGS_UNALLOCATED 0
#define REGS_REALLOCATE 1
#define REGS_FIXED 2
unsigned regs_allocated : 2;
/* Set to zero when `regex_compile' compiles a pattern; set to one
by `re_compile_fastmap' if it updates the fastmap. */
unsigned fastmap_accurate : 1;
/* If set, `re_match_2' does not return information about
subexpressions. */
unsigned no_sub : 1;
/* If set, a beginning-of-line anchor doesn't match at the
beginning of the string. */
unsigned not_bol : 1;
/* Similarly for an end-of-line anchor. */
unsigned not_eol : 1;
/* If true, an anchor at a newline matches. */
unsigned newline_anchor : 1;
/* [[[end pattern_buffer]]] */
};
typedef struct re_pattern_buffer regex_t;
/* Type for byte offsets within the string. POSIX mandates this. */
typedef int regoff_t;
/* This is the structure we store register match data in. See
regex.texinfo for a full description of what registers match. */
struct re_registers
{
unsigned num_regs;
regoff_t *start;
regoff_t *end;
};
/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
`re_match_2' returns information about at least this many registers
the first time a `regs' structure is passed. */
#ifndef RE_NREGS
# define RE_NREGS 30
#endif
/* POSIX specification for registers. Aside from the different names than
`re_registers', POSIX uses an array of structures, instead of a
structure of arrays. */
typedef struct
{
regoff_t rm_so; /* Byte offset from string's start to substring's start. */
regoff_t rm_eo; /* Byte offset from string's start to substring's end. */
} regmatch_t;
/* Declarations for routines. */
/* To avoid duplicating every routine declaration -- once with a
prototype (if we are ANSI), and once without (if we aren't) -- we
use the following macro to declare argument types. This
unfortunately clutters up the declarations a bit, but I think it's
worth it. */
/* Sets the current default syntax to SYNTAX, and return the old syntax.
You can also simply assign to the `re_syntax_options' variable. */
extern reg_syntax_t re_set_syntax (reg_syntax_t syntax);
/* Compile the regular expression PATTERN, with length LENGTH
and syntax given by the global `re_syntax_options', into the buffer
BUFFER. Return NULL if successful, and an error string if not. */
extern const char *re_compile_pattern (const char *pattern, size_t length,
struct re_pattern_buffer *buffer);
/* Compile a fastmap for the compiled pattern in BUFFER; used to
accelerate searches. Return 0 if successful and -2 if was an
internal error. */
extern int re_compile_fastmap (struct re_pattern_buffer *buffer);
/* Search in the string STRING (with length LENGTH) for the pattern
compiled into BUFFER. Start searching at position START, for RANGE
characters. Return the starting position of the match, -1 for no
match, or -2 for an internal error. Also return register
information in REGS (if REGS and BUFFER->no_sub are nonzero). */
extern int re_search (struct re_pattern_buffer *buffer, const char *string,
int length, int start, int range,
struct re_registers *regs);
/* Like `re_search', but search in the concatenation of STRING1 and
STRING2. Also, stop searching at index START + STOP. */
extern int re_search_2 (struct re_pattern_buffer *buffer, const char *string1,
int length1, const char *string2, int length2,
int start, int range, struct re_registers *regs,
int stop);
/* Like `re_search', but return how many characters in STRING the regexp
in BUFFER matched, starting at position START. */
extern int re_match (struct re_pattern_buffer *buffer, const char *string,
int length, int start, struct re_registers *regs);
/* Relates to `re_match' as `re_search_2' relates to `re_search'. */
extern int re_match_2 (struct re_pattern_buffer *buffer, const char *string1,
int length1, const char *string2, int length2,
int start, struct re_registers *regs, int stop);
/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
ENDS. Subsequent matches using BUFFER and REGS will use this memory
for recording register information. STARTS and ENDS must be
allocated with malloc, and must each be at least `NUM_REGS * sizeof
(regoff_t)' bytes long.
If NUM_REGS == 0, then subsequent matches should allocate their own
register data.
Unless this function is called, the first search or match using
PATTERN_BUFFER will allocate its own register data, without
freeing the old data. */
extern void re_set_registers (struct re_pattern_buffer *buffer,
struct re_registers *regs,
unsigned num_regs, regoff_t *starts,
regoff_t *ends);
#if defined _REGEX_RE_COMP || defined _LIBC
# ifndef _CRAY
/* 4.2 bsd compatibility. */
extern char *re_comp (const char *);
extern int re_exec (const char *);
# endif
#endif
/* GCC 2.95 and later have "__restrict"; C99 compilers have
"restrict", and "configure" may have defined "restrict". */
#ifndef __restrict
# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))
# if defined restrict || 199901L <= __STDC_VERSION__
# define __restrict restrict
# else
# define __restrict
# endif
# endif
#endif
/* GCC 3.1 and later support declaring arrays as non-overlapping
using the syntax array_name[restrict] */
#ifndef __restrict_arr
# if ! (3 < __GNUC__ || (3 == __GNUC__ && 1 <= __GNUC_MINOR__)) || defined (__GNUG__)
# define __restrict_arr
# else
# define __restrict_arr __restrict
# endif
#endif
/* POSIX compatibility. */
extern int regcomp (regex_t *__restrict __preg,
const char *__restrict __pattern,
int __cflags);
#if (__GNUC__)
__extension__
#endif
extern int regexec (const regex_t *__restrict __preg,
const char *__restrict __string, size_t __nmatch,
regmatch_t __pmatch[__restrict_arr],
int __eflags);
extern size_t regerror (int __errcode, const regex_t *__preg,
char *__errbuf, size_t __errbuf_size);
extern void regfree (regex_t *__preg);
#ifdef __cplusplus
}
#endif /* C++ */
#endif /* regex.h */
/*
Local variables:
make-backup-files: t
version-control: t
trim-versions-without-asking: nil
End:
*/
+382
View File
@@ -0,0 +1,382 @@
/* CGEN generic assembler support code.
Copyright (C) 1996-2018 Free Software Foundation, Inc.
This file is part of libopcodes.
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
It is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "sysdep.h"
#include <stdio.h>
#include <string.h>
#include "ansidecl.h"
#include "libiberty.h"
#include "safe-ctype.h"
#include "ctype.h"
//#include "bfd.h"
#include "mybfd.h"
#include "symcat.h"
#include "opcode/cgen.h"
#include "opintl.h"
static CGEN_INSN_LIST * hash_insn_array (CGEN_CPU_DESC, const CGEN_INSN *, int, int, CGEN_INSN_LIST **, CGEN_INSN_LIST *);
static CGEN_INSN_LIST * hash_insn_list (CGEN_CPU_DESC, const CGEN_INSN_LIST *, CGEN_INSN_LIST **, CGEN_INSN_LIST *);
static void build_asm_hash_table (CGEN_CPU_DESC);
/* Set the cgen_parse_operand_fn callback. */
void
cgen_set_parse_operand_fn (CGEN_CPU_DESC cd, cgen_parse_operand_fn fn)
{
cd->parse_operand_fn = fn;
}
/* Called whenever starting to parse an insn. */
void
cgen_init_parse_operand (CGEN_CPU_DESC cd)
{
/* This tells the callback to re-initialize. */
(void) (* cd->parse_operand_fn)
(cd, CGEN_PARSE_OPERAND_INIT, NULL, 0, 0, NULL, NULL);
}
/* Subroutine of build_asm_hash_table to add INSNS to the hash table.
COUNT is the number of elements in INSNS.
ENTSIZE is sizeof (CGEN_IBASE) for the target.
??? No longer used but leave in for now.
HTABLE points to the hash table.
HENTBUF is a pointer to sufficiently large buffer of hash entries.
The result is a pointer to the next entry to use.
The table is scanned backwards as additions are made to the front of the
list and we want earlier ones to be prefered. */
static CGEN_INSN_LIST *
hash_insn_array (CGEN_CPU_DESC cd,
const CGEN_INSN *insns,
int count,
int entsize ATTRIBUTE_UNUSED,
CGEN_INSN_LIST **htable,
CGEN_INSN_LIST *hentbuf)
{
int i;
for (i = count - 1; i >= 0; --i, ++hentbuf)
{
unsigned int hash;
const CGEN_INSN *insn = &insns[i];
if (! (* cd->asm_hash_p) (insn))
continue;
hash = (* cd->asm_hash) (CGEN_INSN_MNEMONIC (insn));
hentbuf->next = htable[hash];
hentbuf->insn = insn;
htable[hash] = hentbuf;
}
return hentbuf;
}
/* Subroutine of build_asm_hash_table to add INSNS to the hash table.
This function is identical to hash_insn_array except the insns are
in a list. */
static CGEN_INSN_LIST *
hash_insn_list (CGEN_CPU_DESC cd,
const CGEN_INSN_LIST *insns,
CGEN_INSN_LIST **htable,
CGEN_INSN_LIST *hentbuf)
{
const CGEN_INSN_LIST *ilist;
for (ilist = insns; ilist != NULL; ilist = ilist->next, ++ hentbuf)
{
unsigned int hash;
if (! (* cd->asm_hash_p) (ilist->insn))
continue;
hash = (* cd->asm_hash) (CGEN_INSN_MNEMONIC (ilist->insn));
hentbuf->next = htable[hash];
hentbuf->insn = ilist->insn;
htable[hash] = hentbuf;
}
return hentbuf;
}
/* Build the assembler instruction hash table. */
static void
build_asm_hash_table (CGEN_CPU_DESC cd)
{
int count = cgen_insn_count (cd) + cgen_macro_insn_count (cd);
CGEN_INSN_TABLE *insn_table = &cd->insn_table;
CGEN_INSN_TABLE *macro_insn_table = &cd->macro_insn_table;
unsigned int hash_size = cd->asm_hash_size;
CGEN_INSN_LIST *hash_entry_buf;
CGEN_INSN_LIST **asm_hash_table;
CGEN_INSN_LIST *asm_hash_table_entries;
/* The space allocated for the hash table consists of two parts:
the hash table and the hash lists. */
asm_hash_table = (CGEN_INSN_LIST **)
xmalloc (hash_size * sizeof (CGEN_INSN_LIST *));
memset (asm_hash_table, 0, hash_size * sizeof (CGEN_INSN_LIST *));
asm_hash_table_entries = hash_entry_buf = (CGEN_INSN_LIST *)
xmalloc (count * sizeof (CGEN_INSN_LIST));
/* Add compiled in insns.
Don't include the first one as it is a reserved entry. */
/* ??? It was the end of all hash chains, and also the special
"invalid insn" marker. May be able to do it differently now. */
hash_entry_buf = hash_insn_array (cd,
insn_table->init_entries + 1,
insn_table->num_init_entries - 1,
insn_table->entry_size,
asm_hash_table, hash_entry_buf);
/* Add compiled in macro-insns. */
hash_entry_buf = hash_insn_array (cd, macro_insn_table->init_entries,
macro_insn_table->num_init_entries,
macro_insn_table->entry_size,
asm_hash_table, hash_entry_buf);
/* Add runtime added insns.
Later added insns will be prefered over earlier ones. */
hash_entry_buf = hash_insn_list (cd, insn_table->new_entries,
asm_hash_table, hash_entry_buf);
/* Add runtime added macro-insns. */
hash_insn_list (cd, macro_insn_table->new_entries,
asm_hash_table, hash_entry_buf);
cd->asm_hash_table = asm_hash_table;
cd->asm_hash_table_entries = asm_hash_table_entries;
}
/* Return the first entry in the hash list for INSN. */
CGEN_INSN_LIST *
cgen_asm_lookup_insn (CGEN_CPU_DESC cd, const char *insn)
{
unsigned int hash;
if (cd->asm_hash_table == NULL)
build_asm_hash_table (cd);
hash = (* cd->asm_hash) (insn);
return cd->asm_hash_table[hash];
}
/* Keyword parser.
The result is NULL upon success or an error message.
If successful, *STRP is updated to point passed the keyword.
??? At present we have a static notion of how to pick out a keyword.
Later we can allow a target to customize this if necessary [say by
recording something in the keyword table]. */
const char *
cgen_parse_keyword (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
const char **strp,
CGEN_KEYWORD *keyword_table,
long *valuep)
{
const CGEN_KEYWORD_ENTRY *ke;
char buf[256];
const char *p,*start;
if (keyword_table->name_hash_table == NULL)
(void) cgen_keyword_search_init (keyword_table, NULL);
p = start = *strp;
/* Allow any first character. This is to make life easier for
the fairly common case of suffixes, eg. 'ld.b.w', where the first
character of the suffix ('.') is special. */
if (*p)
++p;
/* Allow letters, digits, and any special characters. */
while (((p - start) < (int) sizeof (buf))
&& *p
&& (ISALNUM (*p)
|| *p == '_'
|| strchr (keyword_table->nonalpha_chars, *p)))
++p;
if (p - start >= (int) sizeof (buf))
{
/* All non-empty CGEN keywords can fit into BUF. The only thing
we can match here is the empty keyword. */
buf[0] = 0;
}
else
{
memcpy (buf, start, p - start);
buf[p - start] = 0;
}
ke = cgen_keyword_lookup_name (keyword_table, buf);
if (ke != NULL)
{
*valuep = ke->value;
/* Don't advance pointer if we recognized the null keyword. */
if (ke->name[0] != 0)
*strp = p;
return NULL;
}
return "unrecognized keyword/register name";
}
/* Parse a small signed integer parser.
??? VALUEP is not a bfd_vma * on purpose, though this is confusing.
Note that if the caller expects a bfd_vma result, it should call
cgen_parse_address. */
const char *
cgen_parse_signed_integer (CGEN_CPU_DESC cd,
const char **strp,
int opindex,
long *valuep)
{
bfd_vma value;
enum cgen_parse_operand_result result;
const char *errmsg;
errmsg = (* cd->parse_operand_fn)
(cd, CGEN_PARSE_OPERAND_INTEGER, strp, opindex, BFD_RELOC_NONE,
&result, &value);
/* FIXME: Examine `result'. */
if (!errmsg)
{
/* Handle the case where a hex value is parsed on a 64-bit host.
A value like 0xffffe000 is clearly intended to be a negative
16-bit value, but on a 64-bit host it will be parsed by gas
as 0x00000000ffffe000.
The shifts below are designed not to produce compile time
warnings on a 32-bit host. */
if (sizeof (value) > 4
&& result == CGEN_PARSE_OPERAND_RESULT_NUMBER
&& value > 0
&& (value & 0x80000000)
&& ((value >> 31) == 1))
value |= ((bfd_vma) -1) << 31;
*valuep = value;
}
return errmsg;
}
/* Parse a small unsigned integer parser.
??? VALUEP is not a bfd_vma * on purpose, though this is confusing.
Note that if the caller expects a bfd_vma result, it should call
cgen_parse_address. */
const char *
cgen_parse_unsigned_integer (CGEN_CPU_DESC cd,
const char **strp,
int opindex,
unsigned long *valuep)
{
bfd_vma value;
enum cgen_parse_operand_result result;
const char *errmsg;
errmsg = (* cd->parse_operand_fn)
(cd, CGEN_PARSE_OPERAND_INTEGER, strp, opindex, BFD_RELOC_NONE,
&result, &value);
/* FIXME: Examine `result'. */
if (!errmsg)
*valuep = value;
return errmsg;
}
/* Address parser. */
const char *
cgen_parse_address (CGEN_CPU_DESC cd,
const char **strp,
int opindex,
int opinfo,
enum cgen_parse_operand_result *resultp,
bfd_vma *valuep)
{
bfd_vma value;
enum cgen_parse_operand_result result_type;
const char *errmsg;
errmsg = (* cd->parse_operand_fn)
(cd, CGEN_PARSE_OPERAND_ADDRESS, strp, opindex, opinfo,
&result_type, &value);
/* FIXME: Examine `result'. */
if (!errmsg)
{
if (resultp != NULL)
*resultp = result_type;
*valuep = value;
}
return errmsg;
}
/* Signed integer validation routine. */
const char *
cgen_validate_signed_integer (long value, long min, long max)
{
if (value < min || value > max)
{
static char buf[100];
/* xgettext:c-format */
sprintf (buf, _("operand out of range (%ld not between %ld and %ld)"),
value, min, max);
return buf;
}
return NULL;
}
/* Unsigned integer validation routine.
Supplying `min' here may seem unnecessary, but we also want to handle
cases where min != 0 (and max > LONG_MAX). */
const char *
cgen_validate_unsigned_integer (unsigned long value,
unsigned long min,
unsigned long max)
{
if (value < min || value > max)
{
static char buf[100];
/* xgettext:c-format */
sprintf (buf, _("operand out of range (%lu not between %lu and %lu)"),
value, min, max);
return buf;
}
return NULL;
}
+172
View File
@@ -0,0 +1,172 @@
/* CGEN generic opcode support.
Copyright (C) 2002-2018 Free Software Foundation, Inc.
This file is part of libopcodes.
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
It is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
/* Functions for manipulating CGEN_BITSET. */
#include "libiberty.h"
#include "cgen/bitset.h"
#include <string.h>
/* Create a bit mask. */
CGEN_BITSET *
cgen_bitset_create (unsigned bit_count)
{
CGEN_BITSET * mask = xmalloc (sizeof (* mask));
cgen_bitset_init (mask, bit_count);
return mask;
}
/* Initialize an existing bit mask. */
void
cgen_bitset_init (CGEN_BITSET * mask, unsigned bit_count)
{
if (! mask)
return;
mask->length = (bit_count / 8) + 1;
mask->bits = xmalloc (mask->length);
cgen_bitset_clear (mask);
}
/* Clear the bits of a bit mask. */
void
cgen_bitset_clear (CGEN_BITSET * mask)
{
unsigned i;
if (! mask)
return;
for (i = 0; i < mask->length; ++i)
mask->bits[i] = 0;
}
/* Add a bit to a bit mask. */
void
cgen_bitset_add (CGEN_BITSET * mask, unsigned bit_num)
{
int byte_ix, bit_ix;
int bit_mask;
if (! mask)
return;
byte_ix = bit_num / 8;
bit_ix = bit_num % 8;
bit_mask = 1 << (7 - bit_ix);
mask->bits[byte_ix] |= bit_mask;
}
/* Set a bit mask. */
void
cgen_bitset_set (CGEN_BITSET * mask, unsigned bit_num)
{
if (! mask)
return;
cgen_bitset_clear (mask);
cgen_bitset_add (mask, bit_num);
}
/* Test for a bit in a bit mask.
Returns 1 if the bit is found */
int
cgen_bitset_contains (CGEN_BITSET * mask, unsigned bit_num)
{
int byte_ix, bit_ix;
int bit_mask;
if (! mask)
return 1; /* No bit restrictions. */
byte_ix = bit_num / 8;
bit_ix = 7 - (bit_num % 8);
bit_mask = 1 << bit_ix;
return (mask->bits[byte_ix] & bit_mask) >> bit_ix;
}
/* Compare two bit masks for equality.
Returns 0 if they are equal. */
int
cgen_bitset_compare (CGEN_BITSET * mask1, CGEN_BITSET * mask2)
{
if (mask1 == mask2)
return 0;
if (! mask1 || ! mask2)
return 1;
if (mask1->length != mask2->length)
return 1;
return memcmp (mask1->bits, mask2->bits, mask1->length);
}
/* Test two bit masks for common bits.
Returns 1 if a common bit is found. */
int
cgen_bitset_intersect_p (CGEN_BITSET * mask1, CGEN_BITSET * mask2)
{
unsigned i, limit;
if (mask1 == mask2)
return 1;
if (! mask1 || ! mask2)
return 0;
limit = mask1->length < mask2->length ? mask1->length : mask2->length;
for (i = 0; i < limit; ++i)
if ((mask1->bits[i] & mask2->bits[i]))
return 1;
return 0;
}
/* Make a copy of a bit mask. */
CGEN_BITSET *
cgen_bitset_copy (CGEN_BITSET * mask)
{
CGEN_BITSET* newmask;
if (! mask)
return NULL;
newmask = cgen_bitset_create ((mask->length * 8) - 1);
memcpy (newmask->bits, mask->bits, mask->length);
return newmask;
}
/* Combine two bit masks. */
void
cgen_bitset_union (CGEN_BITSET * mask1, CGEN_BITSET * mask2,
CGEN_BITSET * result)
{
unsigned i;
if (! mask1 || ! mask2 || ! result
|| mask1->length != mask2->length
|| mask1->length != result->length)
return;
for (i = 0; i < result->length; ++i)
result->bits[i] = mask1->bits[i] | mask2->bits[i];
}
+286
View File
@@ -0,0 +1,286 @@
/* CGEN generic disassembler support code.
Copyright (C) 1996-2018 Free Software Foundation, Inc.
This file is part of libopcodes.
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
It is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "sysdep.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ansidecl.h"
#include "libiberty.h"
//#include "bfd.h"
#include "mybfd.h"
#include "symcat.h"
#include "opcode/cgen.h"
static CGEN_INSN_LIST * hash_insn_array (CGEN_CPU_DESC, const CGEN_INSN *, int, int, CGEN_INSN_LIST **, CGEN_INSN_LIST *);
static CGEN_INSN_LIST * hash_insn_list (CGEN_CPU_DESC, const CGEN_INSN_LIST *, CGEN_INSN_LIST **, CGEN_INSN_LIST *);
static void build_dis_hash_table (CGEN_CPU_DESC);
static int count_decodable_bits (const CGEN_INSN *);
static void add_insn_to_hash_chain (CGEN_INSN_LIST *,
const CGEN_INSN *,
CGEN_INSN_LIST **,
unsigned int);
bfd_uint64_t
bfd_get_bits (const void *p, int bits, bfd_boolean big_p)
{
const bfd_byte *addr = (const bfd_byte *) p;
bfd_uint64_t data;
int i;
int bytes;
if (bits % 8 != 0)
return 0;
data = 0;
bytes = bits / 8;
for (i = 0; i < bytes; i++)
{
int addr_index = big_p ? i : bytes - i - 1;
data = (data << 8) | addr[addr_index];
}
return data;
}
void
bfd_put_bits (bfd_uint64_t data, void *p, int bits, bfd_boolean big_p)
{
bfd_byte *addr = (bfd_byte *) p;
int i;
int bytes;
if (bits % 8 != 0)
abort ();
bytes = bits / 8;
for (i = 0; i < bytes; i++)
{
int addr_index = big_p ? bytes - i - 1 : i;
addr[addr_index] = data & 0xff;
data >>= 8;
}
}
/* Return the number of decodable bits in this insn. */
static int
count_decodable_bits (const CGEN_INSN *insn)
{
unsigned mask = CGEN_INSN_BASE_MASK (insn);
int bits = 0;
unsigned m;
for (m = 1; m != 0; m <<= 1)
{
if (mask & m)
++bits;
}
return bits;
}
/* Add an instruction to the hash chain. */
static void
add_insn_to_hash_chain (CGEN_INSN_LIST *hentbuf,
const CGEN_INSN *insn,
CGEN_INSN_LIST **htable,
unsigned int hash)
{
CGEN_INSN_LIST *current_buf;
CGEN_INSN_LIST *previous_buf;
int insn_decodable_bits;
/* Add insns sorted by the number of decodable bits, in decreasing order.
This ensures that any insn which is a special case of another will be
checked first. */
insn_decodable_bits = count_decodable_bits (insn);
previous_buf = NULL;
for (current_buf = htable[hash]; current_buf != NULL;
current_buf = current_buf->next)
{
int current_decodable_bits = count_decodable_bits (current_buf->insn);
if (insn_decodable_bits >= current_decodable_bits)
break;
previous_buf = current_buf;
}
/* Now insert the new insn. */
hentbuf->insn = insn;
hentbuf->next = current_buf;
if (previous_buf == NULL)
htable[hash] = hentbuf;
else
previous_buf->next = hentbuf;
}
/* Subroutine of build_dis_hash_table to add INSNS to the hash table.
COUNT is the number of elements in INSNS.
ENTSIZE is sizeof (CGEN_IBASE) for the target.
??? No longer used but leave in for now.
HTABLE points to the hash table.
HENTBUF is a pointer to sufficiently large buffer of hash entries.
The result is a pointer to the next entry to use.
The table is scanned backwards as additions are made to the front of the
list and we want earlier ones to be prefered. */
static CGEN_INSN_LIST *
hash_insn_array (CGEN_CPU_DESC cd,
const CGEN_INSN * insns,
int count,
int entsize ATTRIBUTE_UNUSED,
CGEN_INSN_LIST ** htable,
CGEN_INSN_LIST * hentbuf)
{
int big_p = CGEN_CPU_INSN_ENDIAN (cd) == CGEN_ENDIAN_BIG;
int i;
for (i = count - 1; i >= 0; --i, ++hentbuf)
{
unsigned int hash;
char buf [4];
unsigned long value;
const CGEN_INSN *insn = &insns[i];
if (! (* cd->dis_hash_p) (insn))
continue;
/* We don't know whether the target uses the buffer or the base insn
to hash on, so set both up. */
value = CGEN_INSN_BASE_VALUE (insn);
bfd_put_bits ((bfd_vma) value,
buf,
CGEN_INSN_MASK_BITSIZE (insn),
big_p);
hash = (* cd->dis_hash) (buf, value);
add_insn_to_hash_chain (hentbuf, insn, htable, hash);
}
return hentbuf;
}
/* Subroutine of build_dis_hash_table to add INSNS to the hash table.
This function is identical to hash_insn_array except the insns are
in a list. */
static CGEN_INSN_LIST *
hash_insn_list (CGEN_CPU_DESC cd,
const CGEN_INSN_LIST *insns,
CGEN_INSN_LIST **htable,
CGEN_INSN_LIST *hentbuf)
{
int big_p = CGEN_CPU_INSN_ENDIAN (cd) == CGEN_ENDIAN_BIG;
const CGEN_INSN_LIST *ilist;
for (ilist = insns; ilist != NULL; ilist = ilist->next, ++ hentbuf)
{
unsigned int hash;
char buf[4];
unsigned long value;
if (! (* cd->dis_hash_p) (ilist->insn))
continue;
/* We don't know whether the target uses the buffer or the base insn
to hash on, so set both up. */
value = CGEN_INSN_BASE_VALUE (ilist->insn);
bfd_put_bits((bfd_vma) value,
buf,
CGEN_INSN_MASK_BITSIZE (ilist->insn),
big_p);
hash = (* cd->dis_hash) (buf, value);
add_insn_to_hash_chain (hentbuf, ilist->insn, htable, hash);
}
return hentbuf;
}
/* Build the disassembler instruction hash table. */
static void
build_dis_hash_table (CGEN_CPU_DESC cd)
{
int count = cgen_insn_count (cd) + cgen_macro_insn_count (cd);
CGEN_INSN_TABLE *insn_table = & cd->insn_table;
CGEN_INSN_TABLE *macro_insn_table = & cd->macro_insn_table;
unsigned int hash_size = cd->dis_hash_size;
CGEN_INSN_LIST *hash_entry_buf;
CGEN_INSN_LIST **dis_hash_table;
CGEN_INSN_LIST *dis_hash_table_entries;
/* The space allocated for the hash table consists of two parts:
the hash table and the hash lists. */
dis_hash_table = (CGEN_INSN_LIST **)
xmalloc (hash_size * sizeof (CGEN_INSN_LIST *));
memset (dis_hash_table, 0, hash_size * sizeof (CGEN_INSN_LIST *));
dis_hash_table_entries = hash_entry_buf = (CGEN_INSN_LIST *)
xmalloc (count * sizeof (CGEN_INSN_LIST));
/* Add compiled in insns.
Don't include the first one as it is a reserved entry. */
/* ??? It was the end of all hash chains, and also the special
"invalid insn" marker. May be able to do it differently now. */
hash_entry_buf = hash_insn_array (cd,
insn_table->init_entries + 1,
insn_table->num_init_entries - 1,
insn_table->entry_size,
dis_hash_table, hash_entry_buf);
/* Add compiled in macro-insns. */
hash_entry_buf = hash_insn_array (cd, macro_insn_table->init_entries,
macro_insn_table->num_init_entries,
macro_insn_table->entry_size,
dis_hash_table, hash_entry_buf);
/* Add runtime added insns.
Later added insns will be prefered over earlier ones. */
hash_entry_buf = hash_insn_list (cd, insn_table->new_entries,
dis_hash_table, hash_entry_buf);
/* Add runtime added macro-insns. */
hash_insn_list (cd, macro_insn_table->new_entries,
dis_hash_table, hash_entry_buf);
cd->dis_hash_table = dis_hash_table;
cd->dis_hash_table_entries = dis_hash_table_entries;
}
/* Return the first entry in the hash list for INSN. */
CGEN_INSN_LIST *
cgen_dis_lookup_insn (CGEN_CPU_DESC cd, const char * buf, CGEN_INSN_INT value)
{
unsigned int hash;
if (cd->dis_hash_table == NULL)
build_dis_hash_table (cd);
hash = (* cd->dis_hash) (buf, value);
return cd->dis_hash_table[hash];
}
+616
View File
@@ -0,0 +1,616 @@
/* CGEN generic opcode support.
Copyright (C) 1996-2018 Free Software Foundation, Inc.
This file is part of libopcodes.
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
It is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "sysdep.h"
//#include "alloca-conf.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ansidecl.h"
#include "libiberty.h"
#include "safe-ctype.h"
#include "ctype.h"
//#include "bfd.h"
#include "mybfd.h"
#include "symcat.h"
#include "opcode/cgen.h"
static unsigned int hash_keyword_name
(const CGEN_KEYWORD *, const char *, int);
static unsigned int hash_keyword_value
(const CGEN_KEYWORD *, unsigned int);
static void build_keyword_hash_tables
(CGEN_KEYWORD *);
/* Return number of hash table entries to use for N elements. */
#define KEYWORD_HASH_SIZE(n) ((n) <= 31 ? 17 : 31)
/* Look up *NAMEP in the keyword table KT.
The result is the keyword entry or NULL if not found. */
const CGEN_KEYWORD_ENTRY *
cgen_keyword_lookup_name (CGEN_KEYWORD *kt, const char *name)
{
const CGEN_KEYWORD_ENTRY *ke;
const char *p,*n;
if (kt->name_hash_table == NULL)
build_keyword_hash_tables (kt);
ke = kt->name_hash_table[hash_keyword_name (kt, name, 0)];
/* We do case insensitive comparisons.
If that ever becomes a problem, add an attribute that denotes
"do case sensitive comparisons". */
while (ke != NULL)
{
n = name;
p = ke->name;
while (*p
&& (*p == *n
|| (ISALPHA (*p) && (TOLOWER (*p) == TOLOWER (*n)))))
++n, ++p;
if (!*p && !*n)
return ke;
ke = ke->next_name;
}
if (kt->null_entry)
return kt->null_entry;
return NULL;
}
/* Look up VALUE in the keyword table KT.
The result is the keyword entry or NULL if not found. */
const CGEN_KEYWORD_ENTRY *
cgen_keyword_lookup_value (CGEN_KEYWORD *kt, int value)
{
const CGEN_KEYWORD_ENTRY *ke;
if (kt->name_hash_table == NULL)
build_keyword_hash_tables (kt);
ke = kt->value_hash_table[hash_keyword_value (kt, value)];
while (ke != NULL)
{
if (value == ke->value)
return ke;
ke = ke->next_value;
}
return NULL;
}
/* Add an entry to a keyword table. */
void
cgen_keyword_add (CGEN_KEYWORD *kt, CGEN_KEYWORD_ENTRY *ke)
{
unsigned int hash;
size_t i;
if (kt->name_hash_table == NULL)
build_keyword_hash_tables (kt);
hash = hash_keyword_name (kt, ke->name, 0);
ke->next_name = kt->name_hash_table[hash];
kt->name_hash_table[hash] = ke;
hash = hash_keyword_value (kt, ke->value);
ke->next_value = kt->value_hash_table[hash];
kt->value_hash_table[hash] = ke;
if (ke->name[0] == 0)
kt->null_entry = ke;
for (i = 1; i < strlen (ke->name); i++)
if (! ISALNUM (ke->name[i])
&& ! strchr (kt->nonalpha_chars, ke->name[i]))
{
size_t idx = strlen (kt->nonalpha_chars);
/* If you hit this limit, please don't just
increase the size of the field, instead
look for a better algorithm. */
if (idx >= sizeof (kt->nonalpha_chars) - 1)
abort ();
kt->nonalpha_chars[idx] = ke->name[i];
kt->nonalpha_chars[idx+1] = 0;
}
}
/* FIXME: Need function to return count of keywords. */
/* Initialize a keyword table search.
SPEC is a specification of what to search for.
A value of NULL means to find every keyword.
Currently NULL is the only acceptable value [further specification
deferred].
The result is an opaque data item used to record the search status.
It is passed to each call to cgen_keyword_search_next. */
CGEN_KEYWORD_SEARCH
cgen_keyword_search_init (CGEN_KEYWORD *kt, const char *spec)
{
CGEN_KEYWORD_SEARCH search;
/* FIXME: Need to specify format of params. */
if (spec != NULL)
abort ();
if (kt->name_hash_table == NULL)
build_keyword_hash_tables (kt);
search.table = kt;
search.spec = spec;
search.current_hash = 0;
search.current_entry = NULL;
return search;
}
/* Return the next keyword specified by SEARCH.
The result is the next entry or NULL if there are no more. */
const CGEN_KEYWORD_ENTRY *
cgen_keyword_search_next (CGEN_KEYWORD_SEARCH *search)
{
/* Has search finished? */
if (search->current_hash == search->table->hash_table_size)
return NULL;
/* Search in progress? */
if (search->current_entry != NULL
/* Anything left on this hash chain? */
&& search->current_entry->next_name != NULL)
{
search->current_entry = search->current_entry->next_name;
return search->current_entry;
}
/* Move to next hash chain [unless we haven't started yet]. */
if (search->current_entry != NULL)
++search->current_hash;
while (search->current_hash < search->table->hash_table_size)
{
search->current_entry = search->table->name_hash_table[search->current_hash];
if (search->current_entry != NULL)
return search->current_entry;
++search->current_hash;
}
return NULL;
}
/* Return first entry in hash chain for NAME.
If CASE_SENSITIVE_P is non-zero, return a case sensitive hash. */
static unsigned int
hash_keyword_name (const CGEN_KEYWORD *kt,
const char *name,
int case_sensitive_p)
{
unsigned int hash;
if (case_sensitive_p)
for (hash = 0; *name; ++name)
hash = (hash * 97) + (unsigned char) *name;
else
for (hash = 0; *name; ++name)
hash = (hash * 97) + (unsigned char) TOLOWER (*name);
return hash % kt->hash_table_size;
}
/* Return first entry in hash chain for VALUE. */
static unsigned int
hash_keyword_value (const CGEN_KEYWORD *kt, unsigned int value)
{
return value % kt->hash_table_size;
}
/* Build a keyword table's hash tables.
We probably needn't build the value hash table for the assembler when
we're using the disassembler, but we keep things simple. */
static void
build_keyword_hash_tables (CGEN_KEYWORD *kt)
{
int i;
/* Use the number of compiled in entries as an estimate for the
typical sized table [not too many added at runtime]. */
unsigned int size = KEYWORD_HASH_SIZE (kt->num_init_entries);
kt->hash_table_size = size;
kt->name_hash_table = (CGEN_KEYWORD_ENTRY **)
xmalloc (size * sizeof (CGEN_KEYWORD_ENTRY *));
memset (kt->name_hash_table, 0, size * sizeof (CGEN_KEYWORD_ENTRY *));
kt->value_hash_table = (CGEN_KEYWORD_ENTRY **)
xmalloc (size * sizeof (CGEN_KEYWORD_ENTRY *));
memset (kt->value_hash_table, 0, size * sizeof (CGEN_KEYWORD_ENTRY *));
/* The table is scanned backwards as we want keywords appearing earlier to
be prefered over later ones. */
for (i = kt->num_init_entries - 1; i >= 0; --i)
cgen_keyword_add (kt, &kt->init_entries[i]);
}
/* Hardware support. */
/* Lookup a hardware element by its name.
Returns NULL if NAME is not supported by the currently selected
mach/isa. */
const CGEN_HW_ENTRY *
cgen_hw_lookup_by_name (CGEN_CPU_DESC cd, const char *name)
{
unsigned int i;
const CGEN_HW_ENTRY **hw = cd->hw_table.entries;
for (i = 0; i < cd->hw_table.num_entries; ++i)
if (hw[i] && strcmp (name, hw[i]->name) == 0)
return hw[i];
return NULL;
}
/* Lookup a hardware element by its number.
Hardware elements are enumerated, however it may be possible to add some
at runtime, thus HWNUM is not an enum type but rather an int.
Returns NULL if HWNUM is not supported by the currently selected mach. */
const CGEN_HW_ENTRY *
cgen_hw_lookup_by_num (CGEN_CPU_DESC cd, unsigned int hwnum)
{
unsigned int i;
const CGEN_HW_ENTRY **hw = cd->hw_table.entries;
/* ??? This can be speeded up. */
for (i = 0; i < cd->hw_table.num_entries; ++i)
if (hw[i] && hwnum == hw[i]->type)
return hw[i];
return NULL;
}
/* Operand support. */
/* Lookup an operand by its name.
Returns NULL if NAME is not supported by the currently selected
mach/isa. */
const CGEN_OPERAND *
cgen_operand_lookup_by_name (CGEN_CPU_DESC cd, const char *name)
{
unsigned int i;
const CGEN_OPERAND **op = cd->operand_table.entries;
for (i = 0; i < cd->operand_table.num_entries; ++i)
if (op[i] && strcmp (name, op[i]->name) == 0)
return op[i];
return NULL;
}
/* Lookup an operand by its number.
Operands are enumerated, however it may be possible to add some
at runtime, thus OPNUM is not an enum type but rather an int.
Returns NULL if OPNUM is not supported by the currently selected
mach/isa. */
const CGEN_OPERAND *
cgen_operand_lookup_by_num (CGEN_CPU_DESC cd, int opnum)
{
return cd->operand_table.entries[opnum];
}
/* Instruction support. */
/* Return number of instructions. This includes any added at runtime. */
int
cgen_insn_count (CGEN_CPU_DESC cd)
{
int count = cd->insn_table.num_init_entries;
CGEN_INSN_LIST *rt_insns = cd->insn_table.new_entries;
for ( ; rt_insns != NULL; rt_insns = rt_insns->next)
++count;
return count;
}
/* Return number of macro-instructions.
This includes any added at runtime. */
int
cgen_macro_insn_count (CGEN_CPU_DESC cd)
{
int count = cd->macro_insn_table.num_init_entries;
CGEN_INSN_LIST *rt_insns = cd->macro_insn_table.new_entries;
for ( ; rt_insns != NULL; rt_insns = rt_insns->next)
++count;
return count;
}
/* Cover function to read and properly byteswap an insn value. */
CGEN_INSN_INT
cgen_get_insn_value (CGEN_CPU_DESC cd, unsigned char *buf, int length)
{
int big_p = (cd->insn_endian == CGEN_ENDIAN_BIG);
int insn_chunk_bitsize = cd->insn_chunk_bitsize;
CGEN_INSN_INT value = 0;
if (insn_chunk_bitsize != 0 && insn_chunk_bitsize < length)
{
/* We need to divide up the incoming value into insn_chunk_bitsize-length
segments, and endian-convert them, one at a time. */
int i;
/* Enforce divisibility. */
if ((length % insn_chunk_bitsize) != 0)
abort ();
for (i = 0; i < length; i += insn_chunk_bitsize) /* NB: i == bits */
{
int bit_index;
bfd_vma this_value;
bit_index = i; /* NB: not dependent on endianness; opposite of cgen_put_insn_value! */
this_value = bfd_get_bits (& buf[bit_index / 8], insn_chunk_bitsize, big_p);
value = (value << insn_chunk_bitsize) | this_value;
}
}
else
{
value = bfd_get_bits (buf, length, cd->insn_endian == CGEN_ENDIAN_BIG);
}
return value;
}
/* Cover function to store an insn value properly byteswapped. */
void
cgen_put_insn_value (CGEN_CPU_DESC cd,
unsigned char *buf,
int length,
CGEN_INSN_INT value)
{
int big_p = (cd->insn_endian == CGEN_ENDIAN_BIG);
int insn_chunk_bitsize = cd->insn_chunk_bitsize;
if (insn_chunk_bitsize != 0 && insn_chunk_bitsize < length)
{
/* We need to divide up the incoming value into insn_chunk_bitsize-length
segments, and endian-convert them, one at a time. */
int i;
/* Enforce divisibility. */
if ((length % insn_chunk_bitsize) != 0)
abort ();
for (i = 0; i < length; i += insn_chunk_bitsize) /* NB: i == bits */
{
int bit_index;
bit_index = (length - insn_chunk_bitsize - i); /* NB: not dependent on endianness! */
bfd_put_bits ((bfd_vma) value, & buf[bit_index / 8], insn_chunk_bitsize, big_p);
value >>= insn_chunk_bitsize;
}
}
else
{
bfd_put_bits ((bfd_vma) value, buf, length, big_p);
}
}
/* Look up instruction INSN_*_VALUE and extract its fields.
INSN_INT_VALUE is used if CGEN_INT_INSN_P.
Otherwise INSN_BYTES_VALUE is used.
INSN, if non-null, is the insn table entry.
Otherwise INSN_*_VALUE is examined to compute it.
LENGTH is the bit length of INSN_*_VALUE if known, otherwise 0.
0 is only valid if `insn == NULL && ! CGEN_INT_INSN_P'.
If INSN != NULL, LENGTH must be valid.
ALIAS_P is non-zero if alias insns are to be included in the search.
The result is a pointer to the insn table entry, or NULL if the instruction
wasn't recognized. */
/* ??? Will need to be revisited for VLIW architectures. */
const CGEN_INSN *
cgen_lookup_insn (CGEN_CPU_DESC cd,
const CGEN_INSN *insn,
CGEN_INSN_INT insn_int_value,
/* ??? CGEN_INSN_BYTES would be a nice type name to use here. */
unsigned char *insn_bytes_value,
int length,
CGEN_FIELDS *fields,
int alias_p)
{
CGEN_EXTRACT_INFO ex_info;
CGEN_EXTRACT_INFO *info;
if (cd->int_insn_p)
{
info = NULL;
insn_bytes_value = (unsigned char *) xmalloc (cd->max_insn_bitsize / 8);
cgen_put_insn_value (cd, insn_bytes_value, length, insn_int_value);
}
else
{
info = &ex_info;
ex_info.dis_info = NULL;
ex_info.insn_bytes = insn_bytes_value;
ex_info.valid = -1;
insn_int_value = cgen_get_insn_value (cd, insn_bytes_value, length);
}
if (!insn)
{
const CGEN_INSN_LIST *insn_list;
/* The instructions are stored in hash lists.
Pick the first one and keep trying until we find the right one. */
insn_list = cgen_dis_lookup_insn (cd, (char *) insn_bytes_value,
insn_int_value);
while (insn_list != NULL)
{
insn = insn_list->insn;
if (alias_p
/* FIXME: Ensure ALIAS attribute always has same index. */
|| ! CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_ALIAS))
{
/* Basic bit mask must be correct. */
/* ??? May wish to allow target to defer this check until the
extract handler. */
if ((insn_int_value & CGEN_INSN_BASE_MASK (insn))
== CGEN_INSN_BASE_VALUE (insn))
{
/* ??? 0 is passed for `pc' */
int elength = CGEN_EXTRACT_FN (cd, insn)
(cd, insn, info, insn_int_value, fields, (bfd_vma) 0);
if (elength > 0)
{
/* sanity check */
if (length != 0 && length != elength)
abort ();
break;
}
}
}
insn_list = insn_list->next;
}
}
else
{
/* Sanity check: can't pass an alias insn if ! alias_p. */
if (! alias_p
&& CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_ALIAS))
abort ();
/* Sanity check: length must be correct. */
if (length != CGEN_INSN_BITSIZE (insn))
abort ();
/* ??? 0 is passed for `pc' */
length = CGEN_EXTRACT_FN (cd, insn)
(cd, insn, info, insn_int_value, fields, (bfd_vma) 0);
/* Sanity check: must succeed.
Could relax this later if it ever proves useful. */
if (length == 0)
abort ();
}
if (cd->int_insn_p)
free (insn_bytes_value);
return insn;
}
/* Fill in the operand instances used by INSN whose operands are FIELDS.
INDICES is a pointer to a buffer of MAX_OPERAND_INSTANCES ints to be filled
in. */
void
cgen_get_insn_operands (CGEN_CPU_DESC cd,
const CGEN_INSN *insn,
const CGEN_FIELDS *fields,
int *indices)
{
const CGEN_OPINST *opinst;
int i;
if (insn->opinst == NULL)
abort ();
for (i = 0, opinst = insn->opinst; opinst->type != CGEN_OPINST_END; ++i, ++opinst)
{
enum cgen_operand_type op_type = opinst->op_type;
if (op_type == CGEN_OPERAND_NIL)
indices[i] = opinst->index;
else
indices[i] = (*cd->get_int_operand) (cd, op_type, fields);
}
}
/* Cover function to cgen_get_insn_operands when either INSN or FIELDS
isn't known.
The INSN, INSN_*_VALUE, and LENGTH arguments are passed to
cgen_lookup_insn unchanged.
INSN_INT_VALUE is used if CGEN_INT_INSN_P.
Otherwise INSN_BYTES_VALUE is used.
The result is the insn table entry or NULL if the instruction wasn't
recognized. */
const CGEN_INSN *
cgen_lookup_get_insn_operands (CGEN_CPU_DESC cd,
const CGEN_INSN *insn,
CGEN_INSN_INT insn_int_value,
/* ??? CGEN_INSN_BYTES would be a nice type name to use here. */
unsigned char *insn_bytes_value,
int length,
int *indices,
CGEN_FIELDS *fields)
{
/* Pass non-zero for ALIAS_P only if INSN != NULL.
If INSN == NULL, we want a real insn. */
insn = cgen_lookup_insn (cd, insn, insn_int_value, insn_bytes_value,
length, fields, insn != NULL);
if (! insn)
return NULL;
cgen_get_insn_operands (cd, insn, fields, indices);
return insn;
}
/* Allow signed overflow of instruction fields. */
void
cgen_set_signed_overflow_ok (CGEN_CPU_DESC cd)
{
cd->signed_overflow_ok_p = 1;
}
/* Generate an error message if a signed field in an instruction overflows. */
void
cgen_clear_signed_overflow_ok (CGEN_CPU_DESC cd)
{
cd->signed_overflow_ok_p = 0;
}
/* Will an error message be generated if a signed field in an instruction overflows ? */
unsigned int
cgen_signed_overflow_ok_p (CGEN_CPU_DESC cd)
{
return cd->signed_overflow_ok_p;
}
+89
View File
@@ -0,0 +1,89 @@
/* BFD support for the NIOS processor.
Copyright (C) 1998 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
//#include "bfd.h"
#include "mybfd.h"
#include "sysdep.h"
//#include "libbfd.h"
static int
bfd_default_scan (info, string)
const bfd_arch_info_type *info;
const char *string;
{
return 1;
}
static const bfd_arch_info_type *
bfd_default_compatible (a, b)
const bfd_arch_info_type *a;
const bfd_arch_info_type *b;
{
if (a->arch != b->arch)
return NULL;
if (a->bits_per_word != b->bits_per_word)
return NULL;
if (a->mach > b->mach) {
return a;
} else {
return b;
}
}
static const bfd_arch_info_type arch_info_struct[] =
{
{
32, /* bits per word */
32, /* bits per address */
8, /* bits per byte */
bfd_arch_nios, /* architecture */
bfd_mach_nios32, /* machine */
"nios", /* architecture name */
"nios32", /* printable name */
4, /* section align power */
false, /* the default ? */
bfd_default_compatible, /* architecture comparison fn */
bfd_default_scan, /* string to architecture convert fn */
NULL, /* next in list */
}
};
const bfd_arch_info_type bfd_nios_arch =
{
16, /* bits per word */
16, /* bits per address */
8, /* bits per byte */
bfd_arch_nios, /* architecture */
bfd_mach_nios16, /* machine */
"nios", /* architecture name */
"nios16", /* printable name */
4, /* section align power */
true, /* the default ? */
bfd_default_compatible, /* architecture comparison fn */
bfd_default_scan, /* string to architecture convert fn */
&arch_info_struct[0], /* next in list */
};
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+315
View File
@@ -0,0 +1,315 @@
/* CPU data header for nios.
THIS FILE IS MACHINE GENERATED WITH CGEN.
Copyright (C) 1996-2018 Free Software Foundation, Inc.
This file is part of the GNU Binutils and/or GDB, the GNU debugger.
This file is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
It is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef NIOS_CPU_H
#define NIOS_CPU_H
#ifdef __cplusplus
extern "C" {
#endif
#define CGEN_ARCH nios
/* Given symbol S, return nios_cgen_<S>. */
#define CGEN_SYM(s) nios##_cgen_##s
/* Selected cpu families. */
#define HAVE_CPU_NIOS16BF
#define HAVE_CPU_NIOS32BF
#define CGEN_INSN_LSB0_P 1
/* Minimum size of any insn (in bytes). */
#define CGEN_MIN_INSN_SIZE 2
/* Maximum size of any insn (in bytes). */
#define CGEN_MAX_INSN_SIZE 2
#define CGEN_INT_INSN_P 1
/* Maximum number of syntax elements in an instruction. */
#define CGEN_ACTUAL_MAX_SYNTAX_ELEMENTS 16
/* CGEN_MNEMONIC_OPERANDS is defined if mnemonics have operands.
e.g. In "b,a foo" the ",a" is an operand. If mnemonics have operands
we can't hash on everything up to the space. */
#define CGEN_MNEMONIC_OPERANDS
/* Maximum number of fields in an instruction. */
#define CGEN_ACTUAL_MAX_IFMT_OPERANDS 4
/* Enums. */
/* Enum declaration for insn op6 enums. */
typedef enum insn_op6 {
OP_ADD = 0, OP_ADDI = 1, OP_SUB = 2, OP_SUBI = 3
, OP_CMP = 4, OP_CMPI = 5, OP_LSL = 6, OP_LSLI = 7
, OP_LSR = 8, OP_LSRI = 9, OP_ASR = 10, OP_ASRI = 11
, OP_MOV = 12, OP_MOVI = 13, OP_AND = 14, OP_ANDN = 15
, OP_OR = 16, OP_XOR = 17, OP_BGEN = 18, OP_EXT8D = 19
, OP_SKP0 = 20, OP_SKP1 = 21, OP_LD = 22, OP_ST = 23
, OP_STS8S = 24, OP_STS16S = 25, OP_ADDC = 26, OP_EXT16D = 26
, OP_SUBC = 27, OP_MOVHI = 27, OP_USR0 = 28
} INSN_OP6;
/* Enum declaration for insn pfx enum. */
typedef enum insn_pfx_hi {
OP_PFX_HI = 19
} INSN_PFX_HI;
/* Enum declaration for insn op3 enums. */
typedef enum insn_op3 {
OP_STS = 6, OP_LDS = 7
} INSN_OP3;
/* Enum declaration for insn op4 enums. */
typedef enum insn_op4 {
OP_STP = 10, OP_LDP = 11
} INSN_OP4;
/* Enum declaration for insn op5 enums. */
typedef enum insn_op5 {
OP_BR = 16, OP_BSR = 17, OP_PFXIO = 18, OP_PFX = 19
} INSN_OP5;
/* Enum declaration for insn op8 enums. */
typedef enum insn_op8 {
OP_SAVE = 120, OP_TRAP = 121, OP_JMPC = 122, OP_CALLC = 123
} INSN_OP8;
/* Enum declaration for insn op9 enums. */
typedef enum insn_op9 {
OP_EXT8S = 232, OP_EXT16S = 233, OP_ST8S = 236, OP_ST16S = 237
} INSN_OP9;
/* Enum declaration for insn op11 enums. */
typedef enum insn_op11 {
OP_NOT = 992, OP_NEG = 993, OP_ABS = 994, OP_SEXT8 = 995
, OP_SEXT16 = 996, OP_RLC = 997, OP_RRC = 998, OP_TRET = 1006
, OP_RESTORE = 1005, OP_ST8D = 1008, OP_ST16D = 1009, OP_FILL8 = 1010
, OP_FILL16 = 1011, OP_LDM = 1012, OP_STM = 1013, OP_SKPRZ = 1014
, OP_SKPS = 1015, OP_WRCTL = 1016, OP_RDCTL = 1017, OP_SKPRNZ = 1018
, OP_JMP = 1022, OP_CALL = 1023, OP_SWAP = 1000, OP_USR1 = 1001
, OP_USR2 = 1002, OP_USR3 = 1003, OP_USR4 = 1004, OP_MSTEP = 1012
, OP_MUL = 1013
} INSN_OP11;
/* Enum declaration for . */
typedef enum ctl_names {
H_CTL__CTL0 = 0, H_CTL__CTL1 = 1, H_CTL__CTL2 = 2, H_CTL__CTL3 = 3
, H_CTL__CTL4 = 4, H_CTL__CTL5 = 5, H_CTL__STATUS = 0, H_CTL__ISTATUS = 1
, H_CTL__WVALID = 2, H_CTL__CD_BANK = 3, H_CTL__ST_BANK = 4, H_CTL__LD_BANK = 5
} CTL_NAMES;
/* Enum declaration for . */
typedef enum gr_names {
H_GR__SP = 14, H_GR__FP = 30, H_GR__G0 = 0, H_GR__G1 = 1
, H_GR__G2 = 2, H_GR__G3 = 3, H_GR__G4 = 4, H_GR__G5 = 5
, H_GR__G6 = 6, H_GR__G7 = 7, H_GR__R0 = 0, H_GR__R1 = 1
, H_GR__R2 = 2, H_GR__R3 = 3, H_GR__R4 = 4, H_GR__R5 = 5
, H_GR__R6 = 6, H_GR__R7 = 7, H_GR__O0 = 8, H_GR__O1 = 9
, H_GR__O2 = 10, H_GR__O3 = 11, H_GR__O4 = 12, H_GR__O5 = 13
, H_GR__O6 = 14, H_GR__O7 = 15, H_GR__R8 = 8, H_GR__R9 = 9
, H_GR__R10 = 10, H_GR__R11 = 11, H_GR__R12 = 12, H_GR__R13 = 13
, H_GR__R14 = 14, H_GR__R15 = 15, H_GR__L0 = 16, H_GR__L1 = 17
, H_GR__L2 = 18, H_GR__L3 = 19, H_GR__L4 = 20, H_GR__L5 = 21
, H_GR__L6 = 22, H_GR__L7 = 23, H_GR__R16 = 16, H_GR__R17 = 17
, H_GR__R18 = 18, H_GR__R19 = 19, H_GR__R20 = 20, H_GR__R21 = 21
, H_GR__R22 = 22, H_GR__R23 = 23, H_GR__I0 = 24, H_GR__I1 = 25
, H_GR__I2 = 26, H_GR__I3 = 27, H_GR__I4 = 28, H_GR__I5 = 29
, H_GR__I6 = 30, H_GR__I7 = 31, H_GR__R24 = 24, H_GR__R25 = 25
, H_GR__R26 = 26, H_GR__R27 = 27, H_GR__R28 = 28, H_GR__R29 = 29
, H_GR__R30 = 30, H_GR__R31 = 31
} GR_NAMES;
/* Enum declaration for . */
typedef enum gr0_name {
H_GR0__R0
} GR0_NAME;
/* Enum declaration for . */
typedef enum bp_names {
H_BP__L0 = 0, H_BP__L1 = 1, H_BP__L2 = 2, H_BP__L3 = 3
, H_BP__R16 = 0, H_BP__R17 = 1, H_BP__R18 = 2, H_BP__R19 = 3
} BP_NAMES;
/* Attributes. */
/* Enum declaration for machine type selection. */
typedef enum mach_attr {
MACH_BASE, MACH_NIOS16, MACH_NIOS32, MACH_MAX
} MACH_ATTR;
/* Enum declaration for instruction set selection. */
typedef enum isa_attr {
ISA_NIOS, ISA_MAX
} ISA_ATTR;
/* Number of architecture variants. */
#define MAX_ISAS 1
#define MAX_MACHS ((int) MACH_MAX)
/* Ifield support. */
/* Ifield attribute indices. */
/* Enum declaration for cgen_ifld attrs. */
typedef enum cgen_ifld_attr {
CGEN_IFLD_VIRTUAL, CGEN_IFLD_PCREL_ADDR, CGEN_IFLD_ABS_ADDR, CGEN_IFLD_RESERVED
, CGEN_IFLD_SIGN_OPT, CGEN_IFLD_SIGNED, CGEN_IFLD_END_BOOLS, CGEN_IFLD_START_NBOOLS = 31
, CGEN_IFLD_MACH, CGEN_IFLD_END_NBOOLS
} CGEN_IFLD_ATTR;
/* Number of non-boolean elements in cgen_ifld_attr. */
#define CGEN_IFLD_NBOOL_ATTRS (CGEN_IFLD_END_NBOOLS - CGEN_IFLD_START_NBOOLS - 1)
/* Enum declaration for nios ifield types. */
typedef enum ifield_type {
NIOS_F_NIL, NIOS_F_ANYOF, NIOS_F_OP6, NIOS_F_OP3
, NIOS_F_OP4, NIOS_F_OP5, NIOS_F_OP5_HI, NIOS_F_OP8
, NIOS_F_OP9, NIOS_F_OP11, NIOS_F_RA, NIOS_F_RB
, NIOS_F_RBI5, NIOS_F_RZ, NIOS_F_RP, NIOS_F_CTLC
, NIOS_F_I2, NIOS_F_I4W, NIOS_F_X1, NIOS_F_O1
, NIOS_F_O2, NIOS_F_I5, NIOS_F_I6V, NIOS_F_I8
, NIOS_F_I8V, NIOS_F_I9, NIOS_F_I10, NIOS_F_I11
, NIOS_F_I6_REL_H, NIOS_F_I6_REL_W, NIOS_F_BSRR_I6_REL, NIOS_F_I8V_REL_H
, NIOS_F_I8V_REL_W, NIOS_F_I11_REL, NIOS_F_I1, NIOS_F_MAX
} IFIELD_TYPE;
#define MAX_IFLD ((int) NIOS_F_MAX)
/* Hardware attribute indices. */
/* Enum declaration for cgen_hw attrs. */
typedef enum cgen_hw_attr {
CGEN_HW_VIRTUAL, CGEN_HW_CACHE_ADDR, CGEN_HW_PC, CGEN_HW_PROFILE
, CGEN_HW_END_BOOLS, CGEN_HW_START_NBOOLS = 31, CGEN_HW_MACH, CGEN_HW_END_NBOOLS
} CGEN_HW_ATTR;
/* Number of non-boolean elements in cgen_hw_attr. */
#define CGEN_HW_NBOOL_ATTRS (CGEN_HW_END_NBOOLS - CGEN_HW_START_NBOOLS - 1)
/* Enum declaration for nios hardware types. */
typedef enum cgen_hw_type {
HW_H_MEMORY, HW_H_SINT, HW_H_UINT, HW_H_ADDR
, HW_H_IADDR, HW_H_PC, HW_H_CWP, HW_H_OLD_CWP
, HW_H_IPRI, HW_H_ZERO, HW_H_TEBIT, HW_H_NBIT
, HW_H_ZBIT, HW_H_VBIT, HW_H_CBIT, HW_H_PBIT
, HW_H_SBIT, HW_H_WBIT, HW_H_STATUS, HW_H_K
, HW_H_M16_GR, HW_H_M16_GR0, HW_H_M16_BP, HW_H_M16_RZ
, HW_H_M16_SP, HW_H_M16_CTL, HW_H_M32_GR, HW_H_M32_GR0
, HW_H_M32_BP, HW_H_M32_RZ, HW_H_M32_SP, HW_H_M32_CTL
, HW_MAX
} CGEN_HW_TYPE;
#define MAX_HW ((int) HW_MAX)
/* Operand attribute indices. */
/* Enum declaration for cgen_operand attrs. */
typedef enum cgen_operand_attr {
CGEN_OPERAND_VIRTUAL, CGEN_OPERAND_PCREL_ADDR, CGEN_OPERAND_ABS_ADDR, CGEN_OPERAND_SIGN_OPT
, CGEN_OPERAND_SIGNED, CGEN_OPERAND_NEGATIVE, CGEN_OPERAND_RELAX, CGEN_OPERAND_SEM_ONLY
, CGEN_OPERAND_HASH_PREFIX, CGEN_OPERAND_END_BOOLS, CGEN_OPERAND_START_NBOOLS = 31, CGEN_OPERAND_MACH
, CGEN_OPERAND_END_NBOOLS
} CGEN_OPERAND_ATTR;
/* Number of non-boolean elements in cgen_operand_attr. */
#define CGEN_OPERAND_NBOOL_ATTRS (CGEN_OPERAND_END_NBOOLS - CGEN_OPERAND_START_NBOOLS - 1)
/* Enum declaration for nios operand types. */
typedef enum cgen_operand_type {
NIOS_OPERAND_PC, NIOS_OPERAND_K, NIOS_OPERAND_CTLC, NIOS_OPERAND_XRA
, NIOS_OPERAND_X1, NIOS_OPERAND_O1, NIOS_OPERAND_O2, NIOS_OPERAND_I1
, NIOS_OPERAND_I2, NIOS_OPERAND_SI5, NIOS_OPERAND_I8, NIOS_OPERAND_I8V
, NIOS_OPERAND_I6V, NIOS_OPERAND_SI11, NIOS_OPERAND_REL11, NIOS_OPERAND_BSRR_REL6
, NIOS_OPERAND_NBIT, NIOS_OPERAND_VBIT, NIOS_OPERAND_ZBIT, NIOS_OPERAND_CBIT
, NIOS_OPERAND_TEBIT, NIOS_OPERAND_PBIT, NIOS_OPERAND_SBIT, NIOS_OPERAND_WBIT
, NIOS_OPERAND_I4W, NIOS_OPERAND_I4WN, NIOS_OPERAND_I5, NIOS_OPERAND_SAVE_I8V
, NIOS_OPERAND_I11, NIOS_OPERAND_I10, NIOS_OPERAND_I9, NIOS_OPERAND_I16
, NIOS_OPERAND_I32, NIOS_OPERAND_RBI5, NIOS_OPERAND_M16_RA, NIOS_OPERAND_M16_RB
, NIOS_OPERAND_M16_R0, NIOS_OPERAND_M16_SP, NIOS_OPERAND_M16_RP, NIOS_OPERAND_M16_RZ
, NIOS_OPERAND_M16_I6, NIOS_OPERAND_M16_I8V, NIOS_OPERAND_M32_RA, NIOS_OPERAND_M32_RB
, NIOS_OPERAND_M32_R0, NIOS_OPERAND_M32_SP, NIOS_OPERAND_M32_RP, NIOS_OPERAND_M32_RZ
, NIOS_OPERAND_M32_I6, NIOS_OPERAND_M32_I8V, NIOS_OPERAND_MAX
} CGEN_OPERAND_TYPE;
/* Number of operands types. */
#define MAX_OPERANDS ((int) NIOS_OPERAND_MAX)
/* Maximum number of operands referenced by any insn. */
#define MAX_OPERAND_INSTANCES 8
/* Insn attribute indices. */
/* Enum declaration for cgen_insn attrs. */
typedef enum cgen_insn_attr {
CGEN_INSN_ALIAS, CGEN_INSN_VIRTUAL, CGEN_INSN_UNCOND_CTI, CGEN_INSN_COND_CTI
, CGEN_INSN_SKIP_CTI, CGEN_INSN_DELAY_SLOT, CGEN_INSN_RELAXABLE, CGEN_INSN_RELAXED
, CGEN_INSN_NO_DIS, CGEN_INSN_PBB, CGEN_INSN_PREFIX, CGEN_INSN_PREFIXED_INSN
, CGEN_INSN_SKIP_INSN, CGEN_INSN_DUAL_MODE, CGEN_INSN_END_BOOLS, CGEN_INSN_START_NBOOLS = 31
, CGEN_INSN_MACH, CGEN_INSN_END_NBOOLS
} CGEN_INSN_ATTR;
/* Number of non-boolean elements in cgen_insn_attr. */
#define CGEN_INSN_NBOOL_ATTRS (CGEN_INSN_END_NBOOLS - CGEN_INSN_START_NBOOLS - 1)
/* cgen.h uses things we just defined. */
#include "opcode/cgen.h"
extern const struct cgen_ifld nios_cgen_ifld_table[];
/* Attributes. */
extern const CGEN_ATTR_TABLE nios_cgen_hardware_attr_table[];
extern const CGEN_ATTR_TABLE nios_cgen_ifield_attr_table[];
extern const CGEN_ATTR_TABLE nios_cgen_operand_attr_table[];
extern const CGEN_ATTR_TABLE nios_cgen_insn_attr_table[];
/* Hardware decls. */
extern CGEN_KEYWORD nios_cgen_opval_gr_names;
extern CGEN_KEYWORD nios_cgen_opval_h_m16_gr0;
extern CGEN_KEYWORD nios_cgen_opval_bp_names;
extern CGEN_KEYWORD nios_cgen_opval_gr_names;
extern CGEN_KEYWORD nios_cgen_opval_h_m16_sp;
extern CGEN_KEYWORD nios_cgen_opval_ctl_names;
extern CGEN_KEYWORD nios_cgen_opval_gr_names;
extern CGEN_KEYWORD nios_cgen_opval_gr0_name;
extern CGEN_KEYWORD nios_cgen_opval_bp_names;
extern CGEN_KEYWORD nios_cgen_opval_gr_names;
extern CGEN_KEYWORD nios_cgen_opval_h_m32_sp;
extern CGEN_KEYWORD nios_cgen_opval_ctl_names;
extern const CGEN_HW_ENTRY nios_cgen_hw_table[];
#ifndef opcodes_error_handler
#define opcodes_error_handler(...) \
fprintf (stderr, __VA_ARGS__); fputc ('\n', stderr)
#endif
#ifdef __cplusplus
}
#endif
#endif /* NIOS_CPU_H */
+791
View File
@@ -0,0 +1,791 @@
/* Altera Nios disassemble routines
Copyright (C) 2012-2018 Free Software Foundation, Inc.
THIS FILE IS MACHINE GENERATED WITH CGEN.
- the resultant file is machine generated, cgen-dis.in isn't
Copyright (C) 1996-2018 Free Software Foundation, Inc.
This file is part of libopcodes.
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
It is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
/* ??? Eventually more and more of this stuff can go to cpu-independent files.
Keep that in mind. */
#include "sysdep.h"
#include <stdio.h>
#include <stdlib.h>
#include "ansidecl.h"
#include "dis-asm.h"
//#include "bfd.h"
#include "mybfd.h"
#include "symcat.h"
#include "libiberty.h"
#include "nios-desc.h"
#include "nios-opc.h"
#include "opintl.h"
extern const bfd_arch_info_type bfd_nios_arch;
const bfd_arch_info_type *
bfd_lookup_arch (enum bfd_architecture arch, unsigned long machine)
{
if (arch != bfd_arch_nios) {
return NULL;
}
if (machine == MACH_NIOS16) {
return &bfd_nios_arch;
} else if (machine == MACH_NIOS32) {
return bfd_nios_arch.next;
} else {
return NULL;
}
}
/* Default text to print if an instruction isn't recognized. */
#define UNKNOWN_INSN_MSG _("*unknown*")
static void print_normal
(CGEN_CPU_DESC, void *, long, unsigned int, bfd_vma, int);
static void print_address
(CGEN_CPU_DESC, void *, bfd_vma, unsigned int, bfd_vma, int) ATTRIBUTE_UNUSED;
static void print_keyword
(CGEN_CPU_DESC, void *, CGEN_KEYWORD *, long, unsigned int) ATTRIBUTE_UNUSED;
static void print_insn_normal
(CGEN_CPU_DESC, void *, const CGEN_INSN *, CGEN_FIELDS *, bfd_vma, int);
static int print_insn
(CGEN_CPU_DESC, bfd_vma, disassemble_info *, bfd_byte *, unsigned);
static int default_print_insn
(CGEN_CPU_DESC, bfd_vma, disassemble_info *) ATTRIBUTE_UNUSED;
static int read_insn
(CGEN_CPU_DESC, bfd_vma, disassemble_info *, bfd_byte *, int, CGEN_EXTRACT_INFO *,
unsigned long *);
/* -- disassembler routines inserted here. */
/* -- dis.c */
/* Include "%hi(foo) in output. */
ATTRIBUTE_UNUSED static void
print_Rbi5 (CGEN_CPU_DESC cd, void *dis_info, long value, unsigned int attrs, bfd_vma pc, int length)
{
int status;
bfd_byte buf[2];
unsigned long insn_value;
const CGEN_INSN_LIST *insn_list;
disassemble_info *info = (disassemble_info *) dis_info;
/* look at previous instruction, if possible, to see if it is PFX */
if (pc > 0)
{
status = (*info->read_memory_func) (pc - 2, buf, 2, info);
if (status != 0)
{
print_keyword (cd, info, & nios_cgen_opval_gr_names, value, 0);
return;
}
insn_value = info->endian == BFD_ENDIAN_BIG ? bfd_getb16 (buf) : bfd_getl16 (buf);
insn_list = CGEN_DIS_LOOKUP_INSN (cd, (char *) buf, insn_value);
while (insn_list != NULL)
{
const CGEN_INSN *insn = insn_list->insn;
/* Basic bit mask must be correct. */
/* ??? May wish to allow target to defer this check until the extract
handler. */
if ((insn_value & CGEN_INSN_BASE_MASK (insn))
== CGEN_INSN_BASE_VALUE (insn))
{
if (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_PREFIX))
(*info->fprintf_func) (info->stream, "0x%lx", value);
else
print_keyword (cd, info, & nios_cgen_opval_gr_names, value, 0);
return;
}
insn_list = CGEN_DIS_NEXT_INSN (insn_list);
}
}
print_keyword (cd, info, & nios_cgen_opval_gr_names, value, 0);
}
ATTRIBUTE_UNUSED static void
print_i11 (CGEN_CPU_DESC cd, void *dis_info, long value, unsigned int attrs, bfd_vma pc, int length)
{
disassemble_info *info = (disassemble_info *) dis_info;
(*info->fprintf_func) (info->stream, "hi(0x%lx)", value << 5);
}
ATTRIBUTE_UNUSED static void
print_r0 (CGEN_CPU_DESC cd, void *dis_info, long value, unsigned int attrs, bfd_vma pc, int length)
{
disassemble_info *info = (disassemble_info *) dis_info;
(*info->fprintf_func) (info->stream, "g0");
}
ATTRIBUTE_UNUSED static void
print_i16 (CGEN_CPU_DESC cd, void *dis_info, long value, unsigned int attrs, bfd_vma pc, int length)
{
disassemble_info *info = (disassemble_info *) dis_info;
(*info->fprintf_func) (info->stream, "#0x%hx)", (short)value);
}
ATTRIBUTE_UNUSED static void
print_i32 (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
void *dis_info,
long value,
unsigned int attrs,
bfd_vma pc,
int length)
{
disassemble_info *info = (disassemble_info *) dis_info;
(*info->fprintf_func) (info->stream, "#0x%lx)", value);
}
ATTRIBUTE_UNUSED static void
print_i4w (CGEN_CPU_DESC cd, void *dis_info, long value, unsigned int attrs, bfd_vma pc, int length)
{
char *str;
disassemble_info *info = (disassemble_info *) dis_info;
switch (value)
{
case CC_Z:
str = "cc_eq";
break;
case CC_NZ:
str = "cc_ne";
break;
case CC_C:
str = "cc_c";
break;
case CC_NC:
str = "cc_nc";
break;
case CC_V:
str = "cc_v";
break;
case CC_NV:
str = "cc_nv";
break;
case CC_GT:
str = "cc_gt";
break;
case CC_GE:
str = "cc_ge";
break;
case CC_LT:
str = "cc_lt";
break;
case CC_LE:
str = "cc_le";
break;
case CC_LS:
str = "cc_ls";
break;
case CC_HI:
str = "cc_hi";
break;
case CC_PL:
str = "cc_pl";
break;
case CC_MI:
str = "cc_mi";
break;
}
if (str != NULL)
(*info->fprintf_func) (info->stream, "%s", str);
else
(*info->fprintf_func) (info->stream, "0x%lx", value);
}
/* -- */
void nios_cgen_print_operand
(CGEN_CPU_DESC, int, PTR, CGEN_FIELDS *, void const *, bfd_vma, int);
/* Main entry point for printing operands.
XINFO is a `void *' and not a `disassemble_info *' to not put a requirement
of dis-asm.h on cgen.h.
This function is basically just a big switch statement. Earlier versions
used tables to look up the function to use, but
- if the table contains both assembler and disassembler functions then
the disassembler contains much of the assembler and vice-versa,
- there's a lot of inlining possibilities as things grow,
- using a switch statement avoids the function call overhead.
This function could be moved into `print_insn_normal', but keeping it
separate makes clear the interface between `print_insn_normal' and each of
the handlers. */
void
nios_cgen_print_operand (CGEN_CPU_DESC cd,
int opindex,
void * xinfo,
CGEN_FIELDS *fields,
void const *attrs ATTRIBUTE_UNUSED,
bfd_vma pc,
int length)
{
disassemble_info *info = (disassemble_info *) xinfo;
switch (opindex)
{
case NIOS_OPERAND_CTLC :
print_normal (cd, info, fields->f_CTLc, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
break;
case NIOS_OPERAND_RBI5 :
print_Rbi5 (cd, info, fields->f_Rbi5, 0, pc, length);
break;
case NIOS_OPERAND_BSRR_REL6 :
print_address (cd, info, fields->f_bsrr_i6_rel, 0|(1<<CGEN_OPERAND_RELAX)|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
break;
case NIOS_OPERAND_I1 :
print_normal (cd, info, fields->f_i1, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
break;
case NIOS_OPERAND_I10 :
print_normal (cd, info, fields->f_i10, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
break;
case NIOS_OPERAND_I11 :
print_i11 (cd, info, fields->f_i11, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
break;
case NIOS_OPERAND_I2 :
print_normal (cd, info, fields->f_i2, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
break;
case NIOS_OPERAND_I4W :
print_i4w (cd, info, fields->f_i4w, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
break;
case NIOS_OPERAND_I4WN :
print_i4w (cd, info, fields->f_i4w, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
break;
case NIOS_OPERAND_I5 :
print_normal (cd, info, fields->f_i5, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
break;
case NIOS_OPERAND_I6V :
print_normal (cd, info, fields->f_i6v, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
break;
case NIOS_OPERAND_I8 :
print_normal (cd, info, fields->f_i8, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
break;
case NIOS_OPERAND_I8V :
print_normal (cd, info, fields->f_i8v, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
break;
case NIOS_OPERAND_I9 :
print_normal (cd, info, fields->f_i9, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
break;
case NIOS_OPERAND_M16_R0 :
print_keyword (cd, info, & nios_cgen_opval_h_m16_gr0, 0, 0);
break;
case NIOS_OPERAND_M16_RA :
print_keyword (cd, info, & nios_cgen_opval_gr_names, fields->f_Ra, 0);
break;
case NIOS_OPERAND_M16_RB :
print_keyword (cd, info, & nios_cgen_opval_gr_names, fields->f_Rb, 0);
break;
case NIOS_OPERAND_M16_RP :
print_keyword (cd, info, & nios_cgen_opval_bp_names, fields->f_Rp, 0);
break;
case NIOS_OPERAND_M16_RZ :
print_keyword (cd, info, & nios_cgen_opval_gr_names, fields->f_Rz, 0);
break;
case NIOS_OPERAND_M16_I6 :
print_address (cd, info, fields->f_i6_rel_h, 0|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
break;
case NIOS_OPERAND_M16_I8V :
print_address (cd, info, fields->f_i8v_rel_h, 0|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
break;
case NIOS_OPERAND_M16_SP :
print_keyword (cd, info, & nios_cgen_opval_h_m16_sp, 0, 0);
break;
case NIOS_OPERAND_M32_R0 :
print_keyword (cd, info, & nios_cgen_opval_gr0_name, 0, 0);
break;
case NIOS_OPERAND_M32_RA :
print_keyword (cd, info, & nios_cgen_opval_gr_names, fields->f_Ra, 0);
break;
case NIOS_OPERAND_M32_RB :
print_keyword (cd, info, & nios_cgen_opval_gr_names, fields->f_Rb, 0);
break;
case NIOS_OPERAND_M32_RP :
print_keyword (cd, info, & nios_cgen_opval_bp_names, fields->f_Rp, 0);
break;
case NIOS_OPERAND_M32_RZ :
print_keyword (cd, info, & nios_cgen_opval_gr_names, fields->f_Rz, 0);
break;
case NIOS_OPERAND_M32_I6 :
print_address (cd, info, fields->f_i6_rel_w, 0|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
break;
case NIOS_OPERAND_M32_I8V :
print_address (cd, info, fields->f_i8v_rel_w, 0|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
break;
case NIOS_OPERAND_M32_SP :
print_keyword (cd, info, & nios_cgen_opval_h_m32_sp, 0, 0);
break;
case NIOS_OPERAND_O1 :
print_normal (cd, info, fields->f_o1, 0, pc, length);
break;
case NIOS_OPERAND_O2 :
print_normal (cd, info, fields->f_o2, 0, pc, length);
break;
case NIOS_OPERAND_REL11 :
print_address (cd, info, fields->f_i11_rel, 0|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length);
break;
case NIOS_OPERAND_SAVE_I8V :
print_normal (cd, info, fields->f_i8v, 0|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
break;
case NIOS_OPERAND_SI11 :
print_normal (cd, info, fields->f_i11, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
break;
case NIOS_OPERAND_SI5 :
print_normal (cd, info, fields->f_i5, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_HASH_PREFIX), pc, length);
break;
case NIOS_OPERAND_X1 :
print_normal (cd, info, fields->f_x1, 0, pc, length);
break;
case NIOS_OPERAND_XRA :
print_normal (cd, info, fields->f_Ra, 0, pc, length);
break;
default :
/* xgettext:c-format */
opcodes_error_handler
(_("internal error: unrecognized field %d while printing insn"),
opindex);
abort ();
}
}
cgen_print_fn * const nios_cgen_print_handlers[] =
{
print_insn_normal,
};
void
nios_cgen_init_dis (CGEN_CPU_DESC cd)
{
nios_cgen_init_opcode_table (cd);
nios_cgen_init_ibld_table (cd);
cd->print_handlers = & nios_cgen_print_handlers[0];
cd->print_operand = nios_cgen_print_operand;
}
/* Default print handler. */
static void
print_normal (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
void *dis_info,
long value,
unsigned int attrs,
bfd_vma pc ATTRIBUTE_UNUSED,
int length ATTRIBUTE_UNUSED)
{
disassemble_info *info = (disassemble_info *) dis_info;
/* Print the operand as directed by the attributes. */
if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SEM_ONLY))
; /* nothing to do */
else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SIGNED))
(*info->fprintf_func) (info->stream, "%ld", value);
else
(*info->fprintf_func) (info->stream, "0x%lx", value);
}
/* Default address handler. */
static void
print_address (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
void *dis_info,
bfd_vma value,
unsigned int attrs,
bfd_vma pc ATTRIBUTE_UNUSED,
int length ATTRIBUTE_UNUSED)
{
disassemble_info *info = (disassemble_info *) dis_info;
/* Print the operand as directed by the attributes. */
if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SEM_ONLY))
; /* Nothing to do. */
else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_PCREL_ADDR))
(*info->print_address_func) (value, info);
else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_ABS_ADDR))
(*info->print_address_func) (value, info);
else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SIGNED))
(*info->fprintf_func) (info->stream, "%ld", (long) value);
else
(*info->fprintf_func) (info->stream, "0x%lx", (long) value);
}
/* Keyword print handler. */
static void
print_keyword (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
void *dis_info,
CGEN_KEYWORD *keyword_table,
long value,
unsigned int attrs ATTRIBUTE_UNUSED)
{
disassemble_info *info = (disassemble_info *) dis_info;
const CGEN_KEYWORD_ENTRY *ke;
ke = cgen_keyword_lookup_value (keyword_table, value);
if (ke != NULL)
(*info->fprintf_func) (info->stream, "%s", ke->name);
else
(*info->fprintf_func) (info->stream, "???");
}
/* Default insn printer.
DIS_INFO is defined as `void *' so the disassembler needn't know anything
about disassemble_info. */
static void
print_insn_normal (CGEN_CPU_DESC cd,
void *dis_info,
const CGEN_INSN *insn,
CGEN_FIELDS *fields,
bfd_vma pc,
int length)
{
const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn);
disassemble_info *info = (disassemble_info *) dis_info;
const CGEN_SYNTAX_CHAR_TYPE *syn;
CGEN_INIT_PRINT (cd);
for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn)
{
if (CGEN_SYNTAX_MNEMONIC_P (*syn))
{
(*info->fprintf_func) (info->stream, "%s", CGEN_INSN_MNEMONIC (insn));
continue;
}
if (CGEN_SYNTAX_CHAR_P (*syn))
{
(*info->fprintf_func) (info->stream, "%c", CGEN_SYNTAX_CHAR (*syn));
continue;
}
/* We have an operand. */
nios_cgen_print_operand (cd, CGEN_SYNTAX_FIELD (*syn), info,
fields, CGEN_INSN_ATTRS (insn), pc, length);
}
}
/* Subroutine of print_insn. Reads an insn into the given buffers and updates
the extract info.
Returns 0 if all is well, non-zero otherwise. */
static int
read_insn (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
bfd_vma pc,
disassemble_info *info,
bfd_byte *buf,
int buflen,
CGEN_EXTRACT_INFO *ex_info,
unsigned long *insn_value)
{
int status = (*info->read_memory_func) (pc, buf, buflen, info);
if (status != 0)
{
(*info->memory_error_func) (status, pc, info);
return -1;
}
ex_info->dis_info = info;
ex_info->valid = (1 << buflen) - 1;
ex_info->insn_bytes = buf;
*insn_value = bfd_get_bits (buf, buflen * 8, info->endian == BFD_ENDIAN_BIG);
return 0;
}
/* Utility to print an insn.
BUF is the base part of the insn, target byte order, BUFLEN bytes long.
The result is the size of the insn in bytes or zero for an unknown insn
or -1 if an error occurs fetching data (memory_error_func will have
been called). */
static int
print_insn (CGEN_CPU_DESC cd,
bfd_vma pc,
disassemble_info *info,
bfd_byte *buf,
unsigned int buflen)
{
CGEN_INSN_INT insn_value;
const CGEN_INSN_LIST *insn_list;
CGEN_EXTRACT_INFO ex_info;
int basesize;
/* Extract base part of instruction, just in case CGEN_DIS_* uses it. */
basesize = cd->base_insn_bitsize < buflen * 8 ?
cd->base_insn_bitsize : buflen * 8;
insn_value = cgen_get_insn_value (cd, buf, basesize);
/* Fill in ex_info fields like read_insn would. Don't actually call
read_insn, since the incoming buffer is already read (and possibly
modified a la m32r). */
ex_info.valid = (1 << buflen) - 1;
ex_info.dis_info = info;
ex_info.insn_bytes = buf;
/* The instructions are stored in hash lists.
Pick the first one and keep trying until we find the right one. */
insn_list = CGEN_DIS_LOOKUP_INSN (cd, (char *) buf, insn_value);
while (insn_list != NULL)
{
const CGEN_INSN *insn = insn_list->insn;
CGEN_FIELDS fields;
int length;
unsigned long insn_value_cropped;
#ifdef CGEN_VALIDATE_INSN_SUPPORTED
/* Not needed as insn shouldn't be in hash lists if not supported. */
/* Supported by this cpu? */
if (! nios_cgen_insn_supported (cd, insn))
{
insn_list = CGEN_DIS_NEXT_INSN (insn_list);
continue;
}
#endif
/* Basic bit mask must be correct. */
/* ??? May wish to allow target to defer this check until the extract
handler. */
/* Base size may exceed this instruction's size. Extract the
relevant part from the buffer. */
if ((unsigned) (CGEN_INSN_BITSIZE (insn) / 8) < buflen &&
(unsigned) (CGEN_INSN_BITSIZE (insn) / 8) <= sizeof (unsigned long))
insn_value_cropped = bfd_get_bits (buf, CGEN_INSN_BITSIZE (insn),
info->endian == BFD_ENDIAN_BIG);
else
insn_value_cropped = insn_value;
if ((insn_value_cropped & CGEN_INSN_BASE_MASK (insn))
== CGEN_INSN_BASE_VALUE (insn))
{
/* Printing is handled in two passes. The first pass parses the
machine insn and extracts the fields. The second pass prints
them. */
/* Make sure the entire insn is loaded into insn_value, if it
can fit. */
if (((unsigned) CGEN_INSN_BITSIZE (insn) > cd->base_insn_bitsize) &&
(unsigned) (CGEN_INSN_BITSIZE (insn) / 8) <= sizeof (unsigned long))
{
unsigned long full_insn_value;
int rc = read_insn (cd, pc, info, buf,
CGEN_INSN_BITSIZE (insn) / 8,
& ex_info, & full_insn_value);
if (rc != 0)
return rc;
length = CGEN_EXTRACT_FN (cd, insn)
(cd, insn, &ex_info, full_insn_value, &fields, pc);
}
else
length = CGEN_EXTRACT_FN (cd, insn)
(cd, insn, &ex_info, insn_value_cropped, &fields, pc);
/* Length < 0 -> error. */
if (length < 0)
return length;
if (length > 0)
{
CGEN_PRINT_FN (cd, insn) (cd, info, insn, &fields, pc, length);
/* Length is in bits, result is in bytes. */
return length / 8;
}
}
insn_list = CGEN_DIS_NEXT_INSN (insn_list);
}
return 0;
}
/* Default value for CGEN_PRINT_INSN.
The result is the size of the insn in bytes or zero for an unknown insn
or -1 if an error occured fetching bytes. */
#ifndef CGEN_PRINT_INSN
#define CGEN_PRINT_INSN default_print_insn
#endif
static int
default_print_insn (CGEN_CPU_DESC cd, bfd_vma pc, disassemble_info *info)
{
bfd_byte buf[CGEN_MAX_INSN_SIZE];
int buflen;
int status;
/* Attempt to read the base part of the insn. */
buflen = cd->base_insn_bitsize / 8;
status = (*info->read_memory_func) (pc, buf, buflen, info);
/* Try again with the minimum part, if min < base. */
if (status != 0 && (cd->min_insn_bitsize < cd->base_insn_bitsize))
{
buflen = cd->min_insn_bitsize / 8;
status = (*info->read_memory_func) (pc, buf, buflen, info);
}
if (status != 0)
{
(*info->memory_error_func) (status, pc, info);
return -1;
}
return print_insn (cd, pc, info, buf, buflen);
}
/* Main entry point.
Print one instruction from PC on INFO->STREAM.
Return the size of the instruction (in bytes). */
typedef struct cpu_desc_list
{
struct cpu_desc_list *next;
CGEN_BITSET *isa;
int mach;
int endian;
CGEN_CPU_DESC cd;
} cpu_desc_list;
int
print_insn_nios (bfd_vma pc, disassemble_info *info)
{
static cpu_desc_list *cd_list = 0;
cpu_desc_list *cl = 0;
static CGEN_CPU_DESC cd = 0;
static CGEN_BITSET *prev_isa;
static int prev_mach;
static int prev_endian;
int length;
CGEN_BITSET *isa;
int mach;
int endian = (info->endian == BFD_ENDIAN_BIG
? CGEN_ENDIAN_BIG
: CGEN_ENDIAN_LITTLE);
enum bfd_architecture arch;
/* ??? gdb will set mach but leave the architecture as "unknown" */
#ifndef CGEN_BFD_ARCH
#define CGEN_BFD_ARCH bfd_arch_nios
#endif
arch = info->arch;
if (arch == bfd_arch_unknown)
arch = CGEN_BFD_ARCH;
/* There's no standard way to compute the machine or isa number
so we leave it to the target. */
#ifdef CGEN_COMPUTE_MACH
mach = CGEN_COMPUTE_MACH (info);
#else
mach = info->mach;
#endif
#ifdef CGEN_COMPUTE_ISA
{
static CGEN_BITSET *permanent_isa;
if (!permanent_isa)
permanent_isa = cgen_bitset_create (MAX_ISAS);
isa = permanent_isa;
cgen_bitset_clear (isa);
cgen_bitset_add (isa, CGEN_COMPUTE_ISA (info));
}
#else
isa = info->insn_sets;
#endif
/* If we've switched cpu's, try to find a handle we've used before */
if (cd
&& (cgen_bitset_compare (isa, prev_isa) != 0
|| mach != prev_mach
|| endian != prev_endian))
{
cd = 0;
for (cl = cd_list; cl; cl = cl->next)
{
if (cgen_bitset_compare (cl->isa, isa) == 0 &&
cl->mach == mach &&
cl->endian == endian)
{
cd = cl->cd;
prev_isa = cd->isas;
break;
}
}
}
/* If we haven't initialized yet, initialize the opcode table. */
if (! cd)
{
const bfd_arch_info_type *arch_type = bfd_lookup_arch (arch, mach);
//const bfd_arch_info_type *arch_type = &bfd_nios_arch;
const char *mach_name;
if (!arch_type)
abort ();
mach_name = arch_type->printable_name;
prev_isa = cgen_bitset_copy (isa);
prev_mach = mach;
prev_endian = endian;
cd = nios_cgen_cpu_open (CGEN_CPU_OPEN_ISAS, prev_isa,
CGEN_CPU_OPEN_BFDMACH, mach_name,
CGEN_CPU_OPEN_ENDIAN, prev_endian,
CGEN_CPU_OPEN_END);
if (!cd)
abort ();
/* Save this away for future reference. */
cl = xmalloc (sizeof (struct cpu_desc_list));
cl->cd = cd;
cl->isa = prev_isa;
cl->mach = mach;
cl->endian = endian;
cl->next = cd_list;
cd_list = cl;
nios_cgen_init_dis (cd);
}
/* We try to have as much common code as possible.
But at this point some targets need to take over. */
/* ??? Some targets may need a hook elsewhere. Try to avoid this,
but if not possible try to move this hook elsewhere rather than
have two hooks. */
length = CGEN_PRINT_INSN (cd, pc, info);
if (length > 0)
return length;
if (length < 0)
return -1;
(*info->fprintf_func) (info->stream, UNKNOWN_INSN_MSG);
return cd->default_insn_bitsize / 8;
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+186
View File
@@ -0,0 +1,186 @@
/* Instruction opcode header for nios.
THIS FILE IS MACHINE GENERATED WITH CGEN.
Copyright (C) 1996-2018 Free Software Foundation, Inc.
This file is part of the GNU Binutils and/or GDB, the GNU debugger.
This file is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
It is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef NIOS_OPC_H
#define NIOS_OPC_H
#ifdef __cplusplus
extern "C" {
#endif
/* -- opc.h */
#undef CGEN_DIS_HASH_SIZE
#define CGEN_DIS_HASH_SIZE 65
#undef CGEN_DIS_HASH
#define CGEN_DIS_HASH(buffer, value) (((unsigned char *) (buffer))[1] >> 5)
/* condition code masks for SKPS instruction */
#define CC_C 0x0
#define CC_NC 0x1
#define CC_Z 0x2
#define CC_NZ 0x3
#define CC_MI 0x4
#define CC_PL 0x5
#define CC_GE 0x6
#define CC_LT 0x7
#define CC_LE 0x8
#define CC_GT 0x9
#define CC_V 0xa
#define CC_NV 0xb
#define CC_LS 0xc
#define CC_HI 0xd
#define CC_MAX CC_HI
/* following activates check beyond hashing since m16 and m32 instructions
* hash identically, but have different descriptions */
#define CGEN_VALIDATE_INSN_SUPPORTED
/* following allows reason codes to be output when assembler errors occur */
#define CGEN_VERBOSE_ASSEMBLER_ERRORS
/* Special check to ensure that instruction exists for given machine */
ATTRIBUTE_UNUSED static int
nios_cgen_insn_supported (CGEN_CPU_DESC cd, const CGEN_INSN *insn)
{
int machs = cd->machs;
return ((CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_MACH) & machs) != 0);
}
/* values to signal between parse routines and md_assemble */
extern int nios_parsed_i11;
extern int nios_Rbi5;
/* values of nios_Rbi5 to help catch Rbi5 syntax errors */
#define NIOS_RBI5_REGISTER 1
#define NIOS_RBI5_IMMEDIATE 2
/* -- */
/* Enum declaration for nios instruction types. */
typedef enum cgen_insn_type {
NIOS_INSN_INVALID, NIOS_INSN_EXT8S16, NIOS_INSN_ST8S16, NIOS_INSN_STS8S16
, NIOS_INSN_ST8D16, NIOS_INSN_WRCTL16, NIOS_INSN_ADDC16, NIOS_INSN_SUBC16
, NIOS_INSN_ADD16, NIOS_INSN_SUB16, NIOS_INSN_ADDI16, NIOS_INSN_SUBI16
, NIOS_INSN_OR16, NIOS_INSN_XOR16, NIOS_INSN_AND16, NIOS_INSN_ANDN16
, NIOS_INSN_LSL16, NIOS_INSN_LSR16, NIOS_INSN_ASR16, NIOS_INSN_LSLI16
, NIOS_INSN_LSRI16, NIOS_INSN_ASRI16, NIOS_INSN_NOT16, NIOS_INSN_NEG16
, NIOS_INSN_ABS16, NIOS_INSN_MOV16, NIOS_INSN_MOVI16, NIOS_INSN_BGEN16
, NIOS_INSN_CMP16, NIOS_INSN_CMPI16, NIOS_INSN_EXT8D16
, NIOS_INSN_SEXT816, NIOS_INSN_FILL816, NIOS_INSN_LDS16, NIOS_INSN_STS16
, NIOS_INSN_LDP16, NIOS_INSN_STP16, NIOS_INSN_LD16, NIOS_INSN_ST16
, NIOS_INSN_TRAP16, NIOS_INSN_TRET16, NIOS_INSN_SAVE16, NIOS_INSN_RESTORE16
, NIOS_INSN_BSR16, NIOS_INSN_BSRR16, NIOS_INSN_JMP16, NIOS_INSN_CALL16
, NIOS_INSN_JMPC16, NIOS_INSN_CALLC16, NIOS_INSN_SKP016, NIOS_INSN_SKP116
, NIOS_INSN_SKPRZ16, NIOS_INSN_SKPRNZ16, NIOS_INSN_SKPS16, NIOS_INSN_RRC16
, NIOS_INSN_RLC16, NIOS_INSN_RDCTL16, NIOS_INSN_USR016, NIOS_INSN_USR116
, NIOS_INSN_USR216, NIOS_INSN_USR316, NIOS_INSN_USR416, NIOS_INSN_STS8S32
, NIOS_INSN_STS16S, NIOS_INSN_MOVHI, NIOS_INSN_EXT16D, NIOS_INSN_SEXT16
, NIOS_INSN_ST16D, NIOS_INSN_FILL16, NIOS_INSN_EXT8S32, NIOS_INSN_ST8S32
, NIOS_INSN_EXT16S, NIOS_INSN_ST16S, NIOS_INSN_ST8D32, NIOS_INSN_WRCTL32
, NIOS_INSN_ADD32, NIOS_INSN_SUB32, NIOS_INSN_ADDI32, NIOS_INSN_SUBI32
, NIOS_INSN_OR32, NIOS_INSN_XOR32, NIOS_INSN_AND32, NIOS_INSN_ANDN32
, NIOS_INSN_LSL32, NIOS_INSN_LSR32, NIOS_INSN_ASR32, NIOS_INSN_LSLI32
, NIOS_INSN_LSRI32, NIOS_INSN_ASRI32, NIOS_INSN_NOT32, NIOS_INSN_NEG32
, NIOS_INSN_ABS32, NIOS_INSN_MOV32, NIOS_INSN_MOVI32, NIOS_INSN_BGEN32
, NIOS_INSN_CMP32, NIOS_INSN_CMPI32, NIOS_INSN_EXT8D32
, NIOS_INSN_SEXT832, NIOS_INSN_FILL832, NIOS_INSN_LDS32, NIOS_INSN_STS32
, NIOS_INSN_LDP32, NIOS_INSN_STP32, NIOS_INSN_LD32, NIOS_INSN_ST32
, NIOS_INSN_TRAP32, NIOS_INSN_TRET32, NIOS_INSN_SAVE32, NIOS_INSN_RESTORE32
, NIOS_INSN_BSR32, NIOS_INSN_BSRR32, NIOS_INSN_JMP32, NIOS_INSN_CALL32
, NIOS_INSN_JMPC32, NIOS_INSN_CALLC32, NIOS_INSN_SKP032, NIOS_INSN_SKP132
, NIOS_INSN_SKPRZ32, NIOS_INSN_SKPRNZ32, NIOS_INSN_SKPS32, NIOS_INSN_RRC32
, NIOS_INSN_RLC32, NIOS_INSN_RDCTL32, NIOS_INSN_PFX, NIOS_INSN_BR
, NIOS_INSN_SWAP32, NIOS_INSN_MSTEP32, NIOS_INSN_MUL32, NIOS_INSN_USR032
, NIOS_INSN_USR132, NIOS_INSN_USR232, NIOS_INSN_USR332, NIOS_INSN_USR432
, NIOS_INSN_PFXIO, NIOS_INSN_MAX
} CGEN_INSN_TYPE;
/* Index of `invalid' insn place holder. */
#define CGEN_INSN_INVALID NIOS_INSN_INVALID
/* Total number of insns in table. */
#define MAX_INSNS ((int) NIOS_INSN_MAX)
/* This struct records data prior to insertion or after extraction. */
struct cgen_fields
{
int length;
long f_nil;
long f_anyof;
long f_op6;
long f_op3;
long f_op4;
long f_op5;
long f_op5_hi;
long f_op8;
long f_op9;
long f_op11;
long f_Ra;
long f_Rb;
long f_Rbi5;
long f_Rz;
long f_Rp;
long f_CTLc;
long f_i2;
long f_i4w;
long f_x1;
long f_o1;
long f_o2;
long f_i5;
long f_i6v;
long f_i8;
long f_i8v;
long f_i9;
long f_i10;
long f_i11;
long f_i6_rel_h;
long f_i6_rel_w;
long f_bsrr_i6_rel;
long f_i8v_rel_h;
long f_i8v_rel_w;
long f_i11_rel;
long f_i1;
};
#define CGEN_INIT_PARSE(od) \
{\
}
#define CGEN_INIT_INSERT(od) \
{\
}
#define CGEN_INIT_EXTRACT(od) \
{\
}
#define CGEN_INIT_PRINT(od) \
{\
}
#ifdef __cplusplus
}
#endif
#endif /* NIOS_OPC_H */
+254
View File
@@ -0,0 +1,254 @@
/* <ctype.h> replacement macros.
Copyright (C) 2000-2018 Free Software Foundation, Inc.
Contributed by Zack Weinberg <zackw@stanford.edu>.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
Libiberty is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with libiberty; see the file COPYING.LIB. If
not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
Boston, MA 02110-1301, USA. */
/*
@defvr Extension HOST_CHARSET
This macro indicates the basic character set and encoding used by the
host: more precisely, the encoding used for character constants in
preprocessor @samp{#if} statements (the C "execution character set").
It is defined by @file{safe-ctype.h}, and will be an integer constant
with one of the following values:
@ftable @code
@item HOST_CHARSET_UNKNOWN
The host character set is unknown - that is, not one of the next two
possibilities.
@item HOST_CHARSET_ASCII
The host character set is ASCII.
@item HOST_CHARSET_EBCDIC
The host character set is some variant of EBCDIC. (Only one of the
nineteen EBCDIC varying characters is tested; exercise caution.)
@end ftable
@end defvr
@deffn Extension ISALPHA (@var{c})
@deffnx Extension ISALNUM (@var{c})
@deffnx Extension ISBLANK (@var{c})
@deffnx Extension ISCNTRL (@var{c})
@deffnx Extension ISDIGIT (@var{c})
@deffnx Extension ISGRAPH (@var{c})
@deffnx Extension ISLOWER (@var{c})
@deffnx Extension ISPRINT (@var{c})
@deffnx Extension ISPUNCT (@var{c})
@deffnx Extension ISSPACE (@var{c})
@deffnx Extension ISUPPER (@var{c})
@deffnx Extension ISXDIGIT (@var{c})
These twelve macros are defined by @file{safe-ctype.h}. Each has the
same meaning as the corresponding macro (with name in lowercase)
defined by the standard header @file{ctype.h}. For example,
@code{ISALPHA} returns true for alphabetic characters and false for
others. However, there are two differences between these macros and
those provided by @file{ctype.h}:
@itemize @bullet
@item These macros are guaranteed to have well-defined behavior for all
values representable by @code{signed char} and @code{unsigned char}, and
for @code{EOF}.
@item These macros ignore the current locale; they are true for these
fixed sets of characters:
@multitable {@code{XDIGIT}} {yada yada yada yada yada yada yada yada}
@item @code{ALPHA} @tab @kbd{A-Za-z}
@item @code{ALNUM} @tab @kbd{A-Za-z0-9}
@item @code{BLANK} @tab @kbd{space tab}
@item @code{CNTRL} @tab @code{!PRINT}
@item @code{DIGIT} @tab @kbd{0-9}
@item @code{GRAPH} @tab @code{ALNUM || PUNCT}
@item @code{LOWER} @tab @kbd{a-z}
@item @code{PRINT} @tab @code{GRAPH ||} @kbd{space}
@item @code{PUNCT} @tab @kbd{`~!@@#$%^&*()_-=+[@{]@}\|;:'",<.>/?}
@item @code{SPACE} @tab @kbd{space tab \n \r \f \v}
@item @code{UPPER} @tab @kbd{A-Z}
@item @code{XDIGIT} @tab @kbd{0-9A-Fa-f}
@end multitable
Note that, if the host character set is ASCII or a superset thereof,
all these macros will return false for all values of @code{char} outside
the range of 7-bit ASCII. In particular, both ISPRINT and ISCNTRL return
false for characters with numeric values from 128 to 255.
@end itemize
@end deffn
@deffn Extension ISIDNUM (@var{c})
@deffnx Extension ISIDST (@var{c})
@deffnx Extension IS_VSPACE (@var{c})
@deffnx Extension IS_NVSPACE (@var{c})
@deffnx Extension IS_SPACE_OR_NUL (@var{c})
@deffnx Extension IS_ISOBASIC (@var{c})
These six macros are defined by @file{safe-ctype.h} and provide
additional character classes which are useful when doing lexical
analysis of C or similar languages. They are true for the following
sets of characters:
@multitable {@code{SPACE_OR_NUL}} {yada yada yada yada yada yada yada yada}
@item @code{IDNUM} @tab @kbd{A-Za-z0-9_}
@item @code{IDST} @tab @kbd{A-Za-z_}
@item @code{VSPACE} @tab @kbd{\r \n}
@item @code{NVSPACE} @tab @kbd{space tab \f \v \0}
@item @code{SPACE_OR_NUL} @tab @code{VSPACE || NVSPACE}
@item @code{ISOBASIC} @tab @code{VSPACE || NVSPACE || PRINT}
@end multitable
@end deffn
*/
#include "ansidecl.h"
#include <safe-ctype.h>
#include <stdio.h> /* for EOF */
#if EOF != -1
#error "<safe-ctype.h> requires EOF == -1"
#endif
/* Shorthand */
#define bl _sch_isblank
#define cn _sch_iscntrl
#define di _sch_isdigit
#define is _sch_isidst
#define lo _sch_islower
#define nv _sch_isnvsp
#define pn _sch_ispunct
#define pr _sch_isprint
#define sp _sch_isspace
#define up _sch_isupper
#define vs _sch_isvsp
#define xd _sch_isxdigit
/* Masks. */
#define L (const unsigned short) (lo|is |pr) /* lower case letter */
#define XL (const unsigned short) (lo|is|xd|pr) /* lowercase hex digit */
#define U (const unsigned short) (up|is |pr) /* upper case letter */
#define XU (const unsigned short) (up|is|xd|pr) /* uppercase hex digit */
#define D (const unsigned short) (di |xd|pr) /* decimal digit */
#define P (const unsigned short) (pn |pr) /* punctuation */
#define _ (const unsigned short) (pn|is |pr) /* underscore */
#define C (const unsigned short) ( cn) /* control character */
#define Z (const unsigned short) (nv |cn) /* NUL */
#define M (const unsigned short) (nv|sp |cn) /* cursor movement: \f \v */
#define V (const unsigned short) (vs|sp |cn) /* vertical space: \r \n */
#define T (const unsigned short) (nv|sp|bl|cn) /* tab */
#define S (const unsigned short) (nv|sp|bl|pr) /* space */
/* Are we ASCII? */
#if HOST_CHARSET == HOST_CHARSET_ASCII
const unsigned short _sch_istable[256] =
{
Z, C, C, C, C, C, C, C, /* NUL SOH STX ETX EOT ENQ ACK BEL */
C, T, V, M, M, V, C, C, /* BS HT LF VT FF CR SO SI */
C, C, C, C, C, C, C, C, /* DLE DC1 DC2 DC3 DC4 NAK SYN ETB */
C, C, C, C, C, C, C, C, /* CAN EM SUB ESC FS GS RS US */
S, P, P, P, P, P, P, P, /* SP ! " # $ % & ' */
P, P, P, P, P, P, P, P, /* ( ) * + , - . / */
D, D, D, D, D, D, D, D, /* 0 1 2 3 4 5 6 7 */
D, D, P, P, P, P, P, P, /* 8 9 : ; < = > ? */
P, XU, XU, XU, XU, XU, XU, U, /* @ A B C D E F G */
U, U, U, U, U, U, U, U, /* H I J K L M N O */
U, U, U, U, U, U, U, U, /* P Q R S T U V W */
U, U, U, P, P, P, P, _, /* X Y Z [ \ ] ^ _ */
P, XL, XL, XL, XL, XL, XL, L, /* ` a b c d e f g */
L, L, L, L, L, L, L, L, /* h i j k l m n o */
L, L, L, L, L, L, L, L, /* p q r s t u v w */
L, L, L, P, P, P, P, C, /* x y z { | } ~ DEL */
/* high half of unsigned char is locale-specific, so all tests are
false in "C" locale */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
const unsigned char _sch_tolower[256] =
{
0, 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,
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
91, 92, 93, 94, 95, 96,
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
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,
};
const unsigned char _sch_toupper[256] =
{
0, 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,
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
91, 92, 93, 94, 95, 96,
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
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,
};
#else
# if HOST_CHARSET == HOST_CHARSET_EBCDIC
#error "FIXME: write tables for EBCDIC"
# else
#error "Unrecognized host character set"
# endif
#endif
+154
View File
@@ -0,0 +1,154 @@
#define STOP_CODE 0
#define POP_TOP 1
#define ROT_TWO 2
#define ROT_THREE 3
#define DUP_TOP 4
#define ROT_FOUR 5
#define NOP 9
#define UNARY_POSITIVE 10
#define UNARY_NEGATIVE 11
#define UNARY_NOT 12
#define UNARY_CONVERT 13
#define UNARY_INVERT 15
#define BINARY_POWER 19
#define BINARY_MULTIPLY 20
#define BINARY_DIVIDE 21
#define BINARY_MODULO 22
#define BINARY_ADD 23
#define BINARY_SUBTRACT 24
#define BINARY_SUBSCR 25
#define BINARY_FLOOR_DIVIDE 26
#define BINARY_TRUE_DIVIDE 27
#define INPLACE_FLOOR_DIVIDE 28
#define INPLACE_TRUE_DIVIDE 29
#define SLICE 30
/* Also uses 31-33 */
#define SLICE_1 31
#define SLICE_2 32
#define SLICE_3 33
#define STORE_SLICE 40
/* Also uses 41-43 */
#define STORE_SLICE_1 41
#define STORE_SLICE_2 42
#define STORE_SLICE_3 43
#define DELETE_SLICE 50
/* Also uses 51-53 */
#define DELETE_SLICE_1 51
#define DELETE_SLICE_2 52
#define DELETE_SLICE_3 53
#define STORE_MAP 54
#define INPLACE_ADD 55
#define INPLACE_SUBTRACT 56
#define INPLACE_MULTIPLY 57
#define INPLACE_DIVIDE 58
#define INPLACE_MODULO 59
#define STORE_SUBSCR 60
#define DELETE_SUBSCR 61
#define BINARY_LSHIFT 62
#define BINARY_RSHIFT 63
#define BINARY_AND 64
#define BINARY_XOR 65
#define BINARY_OR 66
#define INPLACE_POWER 67
#define GET_ITER 68
#define PRINT_EXPR 70
#define PRINT_ITEM 71
#define PRINT_NEWLINE 72
#define PRINT_ITEM_TO 73
#define PRINT_NEWLINE_TO 74
#define INPLACE_LSHIFT 75
#define INPLACE_RSHIFT 76
#define INPLACE_AND 77
#define INPLACE_XOR 78
#define INPLACE_OR 79
#define BREAK_LOOP 80
#define WITH_CLEANUP 81
#define LOAD_LOCALS 82
#define RETURN_VALUE 83
#define IMPORT_STAR 84
#define EXEC_STMT 85
#define YIELD_VALUE 86
#define POP_BLOCK 87
#define END_FINALLY 88
#define BUILD_CLASS 89
#define HAVE_ARGUMENT 90 /* Opcodes from here have an argument: */
#define STORE_NAME 90 /* Index in name list */
#define DELETE_NAME 91 /* "" */
#define UNPACK_SEQUENCE 92 /* Number of sequence items */
#define FOR_ITER 93
#define LIST_APPEND 94
#define STORE_ATTR 95 /* Index in name list */
#define DELETE_ATTR 96 /* "" */
#define STORE_GLOBAL 97 /* "" */
#define DELETE_GLOBAL 98 /* "" */
#define DUP_TOPX 99 /* number of items to duplicate */
#define LOAD_CONST 100 /* Index in const list */
#define LOAD_NAME 101 /* Index in name list */
#define BUILD_TUPLE 102 /* Number of tuple items */
#define BUILD_LIST 103 /* Number of list items */
#define BUILD_SET 104 /* Number of set items */
#define BUILD_MAP 105 /* Always zero for now */
#define LOAD_ATTR 106 /* Index in name list */
#define COMPARE_OP 107 /* Comparison operator */
#define IMPORT_NAME 108 /* Index in name list */
#define IMPORT_FROM 109 /* Index in name list */
#define JUMP_FORWARD 110 /* Number of bytes to skip */
#define JUMP_IF_FALSE_OR_POP 111 /* Target byte offset from beginning
of code */
#define JUMP_IF_TRUE_OR_POP 112 /* "" */
#define JUMP_ABSOLUTE 113 /* "" */
#define POP_JUMP_IF_FALSE 114 /* "" */
#define POP_JUMP_IF_TRUE 115 /* "" */
#define LOAD_GLOBAL 116 /* Index in name list */
#define CONTINUE_LOOP 119 /* Start of loop (absolute) */
#define SETUP_LOOP 120 /* Target address (relative) */
#define SETUP_EXCEPT 121 /* "" */
#define SETUP_FINALLY 122 /* "" */
#define LOAD_FAST 124 /* Local variable number */
#define STORE_FAST 125 /* Local variable number */
#define DELETE_FAST 126 /* Local variable number */
#define RAISE_VARARGS 130 /* Number of raise arguments (1, 2 or 3) */
/* CALL_FUNCTION_XXX opcodes defined below depend on this definition */
#define CALL_FUNCTION 131 /* #args + (#kwargs<<8) */
#define MAKE_FUNCTION 132 /* #defaults */
#define BUILD_SLICE 133 /* Number of items */
#define MAKE_CLOSURE 134 /* #free vars */
#define LOAD_CLOSURE 135 /* Load free variable from closure */
#define LOAD_DEREF 136 /* Load and dereference from closure cell */
#define STORE_DEREF 137 /* Store into cell */
/* The next 3 opcodes must be contiguous and satisfy
(CALL_FUNCTION_VAR - CALL_FUNCTION) & 3 == 1 */
#define CALL_FUNCTION_VAR 140 /* #args + (#kwargs<<8) */
#define CALL_FUNCTION_KW 141 /* #args + (#kwargs<<8) */
#define CALL_FUNCTION_VAR_KW 142 /* #args + (#kwargs<<8) */
#define SETUP_WITH 143
/* Support for opargs more than 16 bits long */
#define EXTENDED_ARG 145
#define SET_ADD 146
#define MAP_ADD 147
char *op_name[0xff + 1];
+76
View File
@@ -0,0 +1,76 @@
#include <r_types.h>
#include <r_lib.h>
#include <r_util.h>
#include <r_asm.h>
#include "opcode.h"
typedef enum {
TYPE_ASCII = 'a',
TYPE_ASCII_INTERNED = 'A',
TYPE_BINARY_COMPLEX = 'y',
TYPE_BINARY_FLOAT = 'g',
TYPE_CODE_v0 = 'C',
TYPE_CODE_v1 = 'c',
TYPE_COMPLEX = 'x',
TYPE_DICT = '{',
TYPE_ELLIPSIS = '.',
TYPE_FALSE = 'F',
TYPE_FLOAT = 'f',
TYPE_FROZENSET = '>',
TYPE_INT64 = 'I',
TYPE_INTERNED = 't',
TYPE_INT = 'i',
TYPE_LIST = '[',
TYPE_LONG = 'l',
TYPE_NONE = 'N',
TYPE_NULL = '0',
TYPE_REF = 'r',
TYPE_SET = '<',
TYPE_SHORT_ASCII_INTERNED = 'Z',
TYPE_SHORT_ASCII = 'z',
TYPE_SMALL_TUPLE = ')',
TYPE_STOPITER = 'S',
TYPE_STRINGREF = 'R',
TYPE_STRING = 's',
TYPE_TRUE = 'T',
TYPE_TUPLE = '(',
TYPE_UNICODE = 'u',
TYPE_UNKNOWN = '?',
} pyc_marshal_type;
typedef enum {
FLAG_REF = '\x80',
} pyc_marshal_flag;
typedef struct {
pyc_marshal_type type;
void *data;
} pyc_object;
typedef struct {
ut32 argcount;
ut32 kwonlyargcount;
ut32 nlocals;
ut32 stacksize;
ut32 flags;
pyc_object *code;
pyc_object *consts;
pyc_object *names;
pyc_object *varnames;
pyc_object *freevars;
pyc_object *cellvars;
pyc_object *filename;
pyc_object *name;
ut32 firstlineno;
pyc_object *lnotab;
st64 start_offset;
st64 end_offset;
} pyc_code_object;
char *parse_arg (ut8 op, ut32 oparg, RList *names, RList *consts, RList *varnames, RList *interned_table);
int r_pyc_disasm (RAsmOp *op, const ut8 *buf, RList *cobjs, RList *interned_table, ut64 pc);
char *generic_array_obj_to_string (RList *l);
void dump_cobj (pyc_code_object *c);
void init_opname_table ();
void dump (RList *l);
+307
View File
@@ -0,0 +1,307 @@
#include "pyc_dis.h"
void init_opname_table () {
int i;
for(i = 0; i < 0xff+1; i++)
op_name[i] = NULL;
op_name[STOP_CODE] = "STOP_CODE";
op_name[POP_TOP] = "POP_TOP";
op_name[ROT_TWO] = "ROT_TWO";
op_name[ROT_THREE] = "ROT_THREE";
op_name[DUP_TOP] = "DUP_TOP";
op_name[ROT_FOUR] = "ROT_FOUR";
op_name[NOP] = "NOP";
op_name[UNARY_POSITIVE] = "UNARY_POSITIVE";
op_name[UNARY_NEGATIVE] = "UNARY_NEGATIVE";
op_name[UNARY_NOT] = "UNARY_NOT";
op_name[UNARY_CONVERT] = "UNARY_CONVERT";
op_name[UNARY_INVERT] = "UNARY_INVERT";
op_name[BINARY_POWER] = "BINARY_POWER";
op_name[BINARY_MULTIPLY] = "BINARY_MULTIPLY";
op_name[BINARY_DIVIDE] = "BINARY_DIVIDE";
op_name[BINARY_MODULO] = "BINARY_MODULO";
op_name[BINARY_ADD] = "BINARY_ADD";
op_name[BINARY_SUBTRACT] = "BINARY_SUBTRACT";
op_name[BINARY_SUBSCR] = "BINARY_SUBSCR";
op_name[BINARY_FLOOR_DIVIDE] = "BINARY_FLOOR_DIVIDE";
op_name[BINARY_TRUE_DIVIDE] = "BINARY_TRUE_DIVIDE";
op_name[INPLACE_FLOOR_DIVIDE] = "INPLACE_FLOOR_DIVIDE";
op_name[INPLACE_TRUE_DIVIDE] = "INPLACE_TRUE_DIVIDE";
op_name[SLICE] = "SLICE";
op_name[SLICE_1] = "SLICE_1";
op_name[SLICE_2] = "SLICE_2";
op_name[SLICE_3] = "SLICE_3";
op_name[STORE_SLICE] = "STORE_SLICE";
op_name[STORE_SLICE_1] = "STORE_SLICE_1";
op_name[STORE_SLICE_2] = "STORE_SLICE_2";
op_name[STORE_SLICE_3] = "STORE_SLICE_3";
op_name[DELETE_SLICE] = "DELETE_SLICE";
op_name[DELETE_SLICE_1] = "DELETE_SLICE_1";
op_name[DELETE_SLICE_2] = "DELETE_SLICE_2";
op_name[DELETE_SLICE_3] = "DELETE_SLICE_3";
op_name[STORE_MAP] = "STORE_MAP";
op_name[INPLACE_ADD] = "INPLACE_ADD";
op_name[INPLACE_SUBTRACT] = "INPLACE_SUBTRACT";
op_name[INPLACE_MULTIPLY] = "INPLACE_MULTIPLY";
op_name[INPLACE_DIVIDE] = "INPLACE_DIVIDE";
op_name[INPLACE_MODULO] = "INPLACE_MODULO";
op_name[STORE_SUBSCR] = "STORE_SUBSCR";
op_name[DELETE_SUBSCR] = "DELETE_SUBSCR";
op_name[BINARY_LSHIFT] = "BINARY_LSHIFT";
op_name[BINARY_RSHIFT] = "BINARY_RSHIFT";
op_name[BINARY_AND] = "BINARY_AND";
op_name[BINARY_XOR] = "BINARY_XOR";
op_name[BINARY_OR] = "BINARY_OR";
op_name[INPLACE_POWER] = "INPLACE_POWER";
op_name[GET_ITER] = "GET_ITER";
op_name[PRINT_EXPR] = "PRINT_EXPR";
op_name[PRINT_ITEM] = "PRINT_ITEM";
op_name[PRINT_NEWLINE] = "PRINT_NEWLINE";
op_name[PRINT_ITEM_TO] = "PRINT_ITEM_TO";
op_name[PRINT_NEWLINE_TO] = "PRINT_NEWLINE_TO";
op_name[INPLACE_LSHIFT] = "INPLACE_LSHIFT";
op_name[INPLACE_RSHIFT] = "INPLACE_RSHIFT";
op_name[INPLACE_AND] = "INPLACE_AND";
op_name[INPLACE_XOR] = "INPLACE_XOR";
op_name[INPLACE_OR] = "INPLACE_OR";
op_name[BREAK_LOOP] = "BREAK_LOOP";
op_name[WITH_CLEANUP] = "WITH_CLEANUP";
op_name[LOAD_LOCALS] = "LOAD_LOCALS";
op_name[RETURN_VALUE] = "RETURN_VALUE";
op_name[IMPORT_STAR] = "IMPORT_STAR";
op_name[EXEC_STMT] = "EXEC_STMT";
op_name[YIELD_VALUE] = "YIELD_VALUE";
op_name[POP_BLOCK] = "POP_BLOCK";
op_name[END_FINALLY] = "END_FINALLY";
op_name[BUILD_CLASS] = "BUILD_CLASS";
op_name[HAVE_ARGUMENT] = "HAVE_ARGUMENT";
op_name[STORE_NAME] = "STORE_NAME";
op_name[DELETE_NAME] = "DELETE_NAME";
op_name[UNPACK_SEQUENCE] = "UNPACK_SEQUENCE";
op_name[FOR_ITER] = "FOR_ITER";
op_name[LIST_APPEND] = "LIST_APPEND";
op_name[STORE_ATTR] = "STORE_ATTR";
op_name[DELETE_ATTR] = "DELETE_ATTR";
op_name[STORE_GLOBAL] = "STORE_GLOBAL";
op_name[DELETE_GLOBAL] = "DELETE_GLOBAL";
op_name[DUP_TOPX] = "DUP_TOPX";
op_name[LOAD_CONST] = "LOAD_CONST";
op_name[LOAD_NAME] = "LOAD_NAME";
op_name[BUILD_TUPLE] = "BUILD_TUPLE";
op_name[BUILD_LIST] = "BUILD_LIST";
op_name[BUILD_SET] = "BUILD_SET";
op_name[BUILD_MAP] = "BUILD_MAP";
op_name[LOAD_ATTR] = "LOAD_ATTR";
op_name[COMPARE_OP] = "COMPARE_OP";
op_name[IMPORT_NAME] = "IMPORT_NAME";
op_name[IMPORT_FROM] = "IMPORT_FROM";
op_name[JUMP_FORWARD] = "JUMP_FORWARD";
op_name[JUMP_IF_FALSE_OR_POP] = "JUMP_IF_FALSE_OR_POP";
op_name[JUMP_IF_TRUE_OR_POP] = "JUMP_IF_TRUE_OR_POP";
op_name[JUMP_ABSOLUTE] = "JUMP_ABSOLUTE";
op_name[POP_JUMP_IF_FALSE] = "POP_JUMP_IF_FALSE";
op_name[POP_JUMP_IF_TRUE] = "POP_JUMP_IF_TRUE";
op_name[LOAD_GLOBAL] = "LOAD_GLOBAL";
op_name[CONTINUE_LOOP] = "CONTINUE_LOOP";
op_name[SETUP_LOOP] = "SETUP_LOOP";
op_name[SETUP_EXCEPT] = "SETUP_EXCEPT";
op_name[SETUP_FINALLY] = "SETUP_FINALLY";
op_name[LOAD_FAST] = "LOAD_FAST";
op_name[STORE_FAST] = "STORE_FAST";
op_name[DELETE_FAST] = "DELETE_FAST";
op_name[RAISE_VARARGS] = "RAISE_VARARGS";
op_name[CALL_FUNCTION] = "CALL_FUNCTION";
op_name[MAKE_FUNCTION] = "MAKE_FUNCTION";
op_name[BUILD_SLICE] = "BUILD_SLICE";
op_name[MAKE_CLOSURE] = "MAKE_CLOSURE";
op_name[LOAD_CLOSURE] = "LOAD_CLOSURE";
op_name[LOAD_DEREF] = "LOAD_DEREF";
op_name[STORE_DEREF] = "STORE_DEREF";
op_name[CALL_FUNCTION_VAR] = "CALL_FUNCTION_VAR";
op_name[CALL_FUNCTION_KW] = "CALL_FUNCTION_KW";
op_name[CALL_FUNCTION_VAR_KW] = "CALL_FUNCTION_VAR_KW";
op_name[SETUP_WITH] = "SETUP_WITH";
op_name[EXTENDED_ARG] = "EXTENDED_ARG";
op_name[SET_ADD] = "SET_ADD";
op_name[MAP_ADD] = "MAP_ADD";
}
int r_pyc_disasm (RAsmOp *opstruct, const ut8 *code, RList *cobjs, RList *interned_table, ut64 pc) {
pyc_code_object *cobj = NULL, *t = NULL;
ut32 extended_arg = 0, i = 0, oparg;
st64 start_offset, end_offset;
RListIter *iter = NULL;
char *name = NULL;
char *arg = NULL;
RList *varnames;
RList *consts;
RList *names;
ut8 op;
r_list_foreach (cobjs, iter, t) {
start_offset = t->start_offset;
end_offset = t->end_offset;
if (pc > start_offset && pc < end_offset) {
cobj = t;
break;
}
}
if (cobj != NULL) {
/* TODO: adding line number and offset */
varnames = cobj->varnames->data;
consts = cobj->consts->data;
names = cobj->names->data;
op = code[i];
i += 1;
name = op_name[op];
r_strbuf_set (&opstruct->buf_asm, name);
if (name == NULL) {
return 0;
}
if (op >= HAVE_ARGUMENT) {
oparg = code[i] + code[i+1]*256 + extended_arg;
extended_arg = 0;
i += 2;
if (op == EXTENDED_ARG)
extended_arg = oparg*65536;
arg = parse_arg (op, oparg, names, consts, varnames, interned_table);
if (arg != NULL) {
r_strbuf_appendf (&opstruct->buf_asm, "%20s", arg);
}
}
return i;
}
return 0;
}
char *parse_arg (ut8 op, ut32 oparg, RList *names, RList *consts, RList *varnames, RList *interned_table) {
pyc_object *t = NULL;
char *arg = NULL;
switch (op) {
case DUP_TOPX:
case UNPACK_SEQUENCE:
case BUILD_TUPLE:
case BUILD_LIST: //checked
case BUILD_SET:
case JUMP_FORWARD:
case CONTINUE_LOOP:
case SETUP_LOOP:
case BUILD_SLICE:
case CALL_FUNCTION:
case POP_JUMP_IF_FALSE:
case POP_JUMP_IF_TRUE:
case JUMP_ABSOLUTE:
case JUMP_IF_TRUE_OR_POP:
case JUMP_IF_FALSE_OR_POP:
case LOAD_CLOSURE:
case LOAD_DEREF:
case CALL_FUNCTION_KW:
arg = r_str_newf ("%u", oparg);
break;
case LOAD_FAST:
case STORE_FAST:
case DELETE_FAST:
t = (pyc_object*)r_list_get_n (varnames, oparg);
if (t == NULL)
return NULL;
arg = t->data;
break;
case LOAD_CONST:
t = (pyc_object*)r_list_get_n (consts, oparg);
if (t == NULL)
return NULL;
switch (t->type) {
case TYPE_CODE_v1:
arg = strdup("CodeObject");
break;
case TYPE_TUPLE:
arg = generic_array_obj_to_string (t->data);
break;
case TYPE_STRING:
case TYPE_INTERNED:
case TYPE_STRINGREF:
arg = r_str_newf ("'%s'", t->data);
break;
default:
arg = t->data;
}
break;
case STORE_NAME:
case STORE_ATTR:
case LOAD_NAME:
case LOAD_ATTR:
case IMPORT_NAME:
case IMPORT_FROM:
case LOAD_GLOBAL:
t = (pyc_object*)r_list_get_n (names, oparg);
if (t == NULL)
return NULL;
arg = t->data;
break;
}
return arg;
}
/* for debugging purpose */
void dump (RList *l) {
RListIter *it;
pyc_object *e = NULL;
r_list_foreach (l, it, e) {
if (e->type == TYPE_TUPLE) {
eprintf ("[TYPE_TUPLE] %s\n", generic_array_obj_to_string(e->data));
return;
}
eprintf("[DATA] %s\n", (char *)e->data);
}
}
char *generic_array_obj_to_string (RList *l) {
RListIter *iter = NULL;
pyc_object *e = NULL;
ut32 size = 256, used = 0;
char *r = NULL, *buf = NULL;
buf = (char*)calloc (1024, 0);
r_list_foreach (l, iter, e) {
while ( !(strlen (e->data) < size) ) {
size *= 2;
buf = realloc (buf, used + size);
if (!buf) {
eprintf ("generic_array_obj_to_string cannot request more memory");
return NULL;
}
}
strcat (buf, e->data);
strcat (buf, ",");
size -= strlen (e->data) + 1;
used += strlen (e->data) + 1;
}
/* remove last , */
buf[ strlen(buf)-1 ] = '\0';
r = r_str_newf ("(%s)", buf);
free(buf);
return r;
}
void dump_cobj (pyc_code_object *c) {
eprintf("[DUMP]\n");
eprintf("name: %s\n", (char *)c->name->data);
eprintf("const_start\n");
dump(c->consts->data);
eprintf("consts_end\n");
eprintf("names_start\n");
dump(c->names->data);
eprintf("names_end\n");
eprintf("varnames_start\n");
dump(c->varnames->data);
eprintf("varnames_end\n");
}
+3 -4
View File
@@ -1,4 +1,4 @@
/* radare - LGPL3 - Copyright 2016 - xarkes */
/* radare - LGPL3 - Copyright 2016-2017 - xarkes */
#include "swfdis.h"
#include "swf_op.h"
@@ -25,7 +25,7 @@ swf_tag_t r_asm_swf_gettag(ut16 tagCode) {
int r_asm_swf_disass(RBinObject *obj, char* buf_asm, const ut8* buf, int len, ut64 pc) {
ut8 isTag = false;
int dlen;
int dlen = 0;
RListIter *it;
RBinSection *sect;
@@ -238,12 +238,11 @@ int r_asm_swf_disass(RBinObject *obj, char* buf_asm, const ut8* buf, int len, ut
dlen = 2;
break;
}
default: {
default:
strcpy (buf_asm, op.name);
dlen = 1;
break;
}
}
}
return dlen;
+1
View File
@@ -20,6 +20,7 @@
#include "sysdep.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "dis-asm.h"
#include "ansidecl.h"
+2
View File
@@ -22,6 +22,8 @@
#include "sysdep.h"
#include <alloca.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ansidecl.h"
#include "libiberty.h"
#include <ctype.h>
+1
View File
@@ -28,6 +28,7 @@
#include "sysdep.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ansidecl.h"
#include "dis-asm.h"
+1
View File
@@ -28,6 +28,7 @@
#include "sysdep.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "ansidecl.h"
#include "dis-asm.h"
#include "mybfd.h"
+897
View File
@@ -0,0 +1,897 @@
// Free Disassembler and Assembler -- Command data and service routines
//
// Copyright (C) 2001 Oleh Yuschuk
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// 05.03.2002: Corrected error, FSTSW AX assembled with data size prefix
#define STRICT
//#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
//#include <dir.h>
#include <math.h>
#include <float.h>
//#pragma hdrstop
#include "disasm.h"
const char *regname[3][9] = {
{ "AL", "CL", "DL", "BL", "AH", "CH", "DH", "BH", "R8" },
{ "AX", "CX", "DX", "BX", "SP", "BP", "SI", "DI", "R16" },
{ "EAX","ECX","EDX","EBX","ESP","EBP","ESI","EDI","R32" } };
const char *segname[8] = {
"ES","CS","SS","DS","FS","GS","SEG?","SEG?" };
const char *sizename[11] = {
"(0-BYTE)", "BYTE", "WORD", "(3-BYTE)",
"DWORD", "(5-BYTE)", "FWORD", "(7-BYTE)",
"QWORD", "(9-BYTE)", "TBYTE" };
const t_addrdec addr16[8] = {
{ SEG_DS,"BX+SI" }, { SEG_DS,"BX+DI" },
{ SEG_SS,"BP+SI" }, { SEG_SS,"BP+DI" },
{ SEG_DS,"SI" }, { SEG_DS,"DI" },
{ SEG_SS,"BP" }, { SEG_DS,"BX" } };
const t_addrdec addr32[8] = {
{ SEG_DS,"EAX" }, { SEG_DS,"ECX" },
{ SEG_DS,"EDX" }, { SEG_DS,"EBX" },
{ SEG_SS,"" }, { SEG_SS,"EBP" },
{ SEG_DS,"ESI" }, { SEG_DS,"EDI" } };
const char *fpuname[9] = {
"ST0","ST1","ST2","ST3","ST4","ST5","ST6","ST7","FPU" };
const char *mmxname[9] = {
"MM0","MM1","MM2","MM3","MM4","MM5","MM6","MM7","MMX" };
const char *crname[9] = {
"CR0","CR1","CR2","CR3","CR4","CR5","CR6","CR7","CRX" };
const char *drname[9] = {
"DR0","DR1","DR2","DR3","DR4","DR5","DR6","DR7","DRX" };
// List of available processor commands with decoding, types of parameters and
// other useful information. Last element has field mask=0. If mnemonic begins
// with ampersand ('&'), its mnemonic decodes differently depending on operand
// size (16 or 32 bits). If mnemonic begins with dollar ('$'), this mnemonic
// depends on address size. Semicolon (':') separates 16-bit form from 32-bit,
// asterisk ('*') will be substituted by either W (16), D (32) or none (16/32)
// character. If command is of type C_MMX or C_NOW, or if type contains C_EXPL
// (=0x01), Disassembler must specify explicit size of memory operand.
const t_cmddata cmddata[] = {
{ 0x0000FF, 0x000090, 1,00, NNN,NNN,NNN, C_CMD+0, "NOP" },
{ 0x0000FE, 0x00008A, 1,WW, REG,MRG,NNN, C_CMD+0, "MOV" },
{ 0x0000F8, 0x000050, 1,00, RCM,NNN,NNN, C_PSH+0, "PUSH" },
{ 0x0000FE, 0x000088, 1,WW, MRG,REG,NNN, C_CMD+0, "MOV" },
{ 0x0000FF, 0x0000E8, 1,00, JOW,NNN,NNN, C_CAL+0, "CALL" },
{ 0x0000FD, 0x000068, 1,SS, IMM,NNN,NNN, C_PSH+0, "PUSH" },
{ 0x0000FF, 0x00008D, 1,00, REG,MMA,NNN, C_CMD+0, "LEA" },
{ 0x0000FF, 0x000074, 1,CC, JOB,NNN,NNN, C_JMC+0, "JE,JZ" },
{ 0x0000F8, 0x000058, 1,00, RCM,NNN,NNN, C_POP+0, "POP" },
{ 0x0038FC, 0x000080, 1,WS, MRG,IMM,NNN, C_CMD+1, "ADD" },
{ 0x0000FF, 0x000075, 1,CC, JOB,NNN,NNN, C_JMC+0, "JNZ,JNE" },
{ 0x0000FF, 0x0000EB, 1,00, JOB,NNN,NNN, C_JMP+0, "JMP" },
{ 0x0000FF, 0x0000E9, 1,00, JOW,NNN,NNN, C_JMP+0, "JMP" },
{ 0x0000FE, 0x000084, 1,WW, MRG,REG,NNN, C_CMD+0, "TEST" },
{ 0x0038FE, 0x0000C6, 1,WW, MRG,IMM,NNN, C_CMD+1, "MOV" },
{ 0x0000FE, 0x000032, 1,WW, REG,MRG,NNN, C_CMD+0, "XOR" },
{ 0x0000FE, 0x00003A, 1,WW, REG,MRG,NNN, C_CMD+0, "CMP" },
{ 0x0038FC, 0x003880, 1,WS, MRG,IMM,NNN, C_CMD+1, "CMP" },
{ 0x0038FF, 0x0010FF, 1,00, MRJ,NNN,NNN, C_CAL+0, "CALL" },
{ 0x0000FF, 0x0000C3, 1,00, NNN,NNN,NNN, C_RET+0, "RETN,RET" },
{ 0x0000F0, 0x0000B0, 1,W3, RCM,IMM,NNN, C_CMD+0, "MOV" },
{ 0x0000FE, 0x0000A0, 1,WW, RAC,IMA,NNN, C_CMD+0, "MOV" },
{ 0x00FFFF, 0x00840F, 2,CC, JOW,NNN,NNN, C_JMC+0, "JE,JZ" },
{ 0x0000F8, 0x000040, 1,00, RCM,NNN,NNN, C_CMD+0, "INC" },
{ 0x0038FE, 0x0000F6, 1,WW, MRG,IMU,NNN, C_CMD+1, "TEST" },
{ 0x0000FE, 0x0000A2, 1,WW, IMA,RAC,NNN, C_CMD+0, "MOV" },
{ 0x0000FE, 0x00002A, 1,WW, REG,MRG,NNN, C_CMD+0, "SUB" },
{ 0x0000FF, 0x00007E, 1,CC, JOB,NNN,NNN, C_JMC+0, "JLE,JNG" },
{ 0x00FFFF, 0x00850F, 2,CC, JOW,NNN,NNN, C_JMC+0, "JNZ,JNE" },
{ 0x0000FF, 0x0000C2, 1,00, IM2,PRN,NNN, C_RET+0, "RETN" },
{ 0x0038FF, 0x0030FF, 1,00, MRG,NNN,NNN, C_PSH+1, "PUSH" },
{ 0x0038FC, 0x000880, 1,WS, MRG,IMU,NNN, C_CMD+1, "OR" },
{ 0x0038FC, 0x002880, 1,WS, MRG,IMM,NNN, C_CMD+1, "SUB" },
{ 0x0000F8, 0x000048, 1,00, RCM,NNN,NNN, C_CMD+0, "DEC" },
{ 0x00FFFF, 0x00BF0F, 2,00, REG,MR2,NNN, C_CMD+1, "MOVSX" },
{ 0x0000FF, 0x00007C, 1,CC, JOB,NNN,NNN, C_JMC+0, "JL,JNGE" },
{ 0x0000FE, 0x000002, 1,WW, REG,MRG,NNN, C_CMD+0, "ADD" },
{ 0x0038FC, 0x002080, 1,WS, MRG,IMU,NNN, C_CMD+1, "AND" },
{ 0x0000FE, 0x00003C, 1,WW, RAC,IMM,NNN, C_CMD+0, "CMP" },
{ 0x0038FF, 0x0020FF, 1,00, MRJ,NNN,NNN, C_JMP+0, "JMP" },
{ 0x0038FE, 0x0010F6, 1,WW, MRG,NNN,NNN, C_CMD+1, "NOT" },
{ 0x0038FE, 0x0028C0, 1,WW, MRG,IMS,NNN, C_CMD+1, "SHR" },
{ 0x0000FE, 0x000038, 1,WW, MRG,REG,NNN, C_CMD+0, "CMP" },
{ 0x0000FF, 0x00007D, 1,CC, JOB,NNN,NNN, C_JMC+0, "JGE,JNL" },
{ 0x0000FF, 0x00007F, 1,CC, JOB,NNN,NNN, C_JMC+0, "JG,JNLE" },
{ 0x0038FE, 0x0020C0, 1,WW, MRG,IMS,NNN, C_CMD+1, "SHL" },
{ 0x0000FE, 0x00001A, 1,WW, REG,MRG,NNN, C_CMD+0, "SBB" },
{ 0x0038FE, 0x0018F6, 1,WW, MRG,NNN,NNN, C_CMD+1, "NEG" },
{ 0x0000FF, 0x0000C9, 1,00, NNN,NNN,NNN, C_CMD+0, "LEAVE" },
{ 0x0000FF, 0x000060, 1,00, NNN,NNN,NNN, C_CMD+C_RARE+0, "&PUSHA*" },
{ 0x0038FF, 0x00008F, 1,00, MRG,NNN,NNN, C_POP+1, "POP" },
{ 0x0000FF, 0x000061, 1,00, NNN,NNN,NNN, C_CMD+C_RARE+0, "&POPA*" },
{ 0x0000F8, 0x000090, 1,00, RAC,RCM,NNN, C_CMD+0, "XCHG" },
{ 0x0000FE, 0x000086, 1,WW, MRG,REG,NNN, C_CMD+0, "XCHG" },
{ 0x0000FE, 0x000000, 1,WW, MRG,REG,NNN, C_CMD+0, "ADD" },
{ 0x0000FE, 0x000010, 1,WW, MRG,REG,NNN, C_CMD+C_RARE+0, "ADC" },
{ 0x0000FE, 0x000012, 1,WW, REG,MRG,NNN, C_CMD+C_RARE+0, "ADC" },
{ 0x0000FE, 0x000020, 1,WW, MRG,REG,NNN, C_CMD+0, "AND" },
{ 0x0000FE, 0x000022, 1,WW, REG,MRG,NNN, C_CMD+0, "AND" },
{ 0x0000FE, 0x000008, 1,WW, MRG,REG,NNN, C_CMD+0, "OR" },
{ 0x0000FE, 0x00000A, 1,WW, REG,MRG,NNN, C_CMD+0, "OR" },
{ 0x0000FE, 0x000028, 1,WW, MRG,REG,NNN, C_CMD+0, "SUB" },
{ 0x0000FE, 0x000018, 1,WW, MRG,REG,NNN, C_CMD+C_RARE+0, "SBB" },
{ 0x0000FE, 0x000030, 1,WW, MRG,REG,NNN, C_CMD+0, "XOR" },
{ 0x0038FC, 0x001080, 1,WS, MRG,IMM,NNN, C_CMD+C_RARE+1, "ADC" },
{ 0x0038FC, 0x001880, 1,WS, MRG,IMM,NNN, C_CMD+C_RARE+1, "SBB" },
{ 0x0038FC, 0x003080, 1,WS, MRG,IMU,NNN, C_CMD+1, "XOR" },
{ 0x0000FE, 0x000004, 1,WW, RAC,IMM,NNN, C_CMD+0, "ADD" },
{ 0x0000FE, 0x000014, 1,WW, RAC,IMM,NNN, C_CMD+C_RARE+0, "ADC" },
{ 0x0000FE, 0x000024, 1,WW, RAC,IMU,NNN, C_CMD+0, "AND" },
{ 0x0000FE, 0x00000C, 1,WW, RAC,IMU,NNN, C_CMD+0, "OR" },
{ 0x0000FE, 0x00002C, 1,WW, RAC,IMM,NNN, C_CMD+0, "SUB" },
{ 0x0000FE, 0x00001C, 1,WW, RAC,IMM,NNN, C_CMD+C_RARE+0, "SBB" },
{ 0x0000FE, 0x000034, 1,WW, RAC,IMU,NNN, C_CMD+0, "XOR" },
{ 0x0038FE, 0x0000FE, 1,WW, MRG,NNN,NNN, C_CMD+1, "INC" },
{ 0x0038FE, 0x0008FE, 1,WW, MRG,NNN,NNN, C_CMD+1, "DEC" },
{ 0x0000FE, 0x0000A8, 1,WW, RAC,IMU,NNN, C_CMD+0, "TEST" },
{ 0x0038FE, 0x0020F6, 1,WW, MRG,NNN,NNN, C_CMD+1, "MUL" },
{ 0x0038FE, 0x0028F6, 1,WW, MRG,NNN,NNN, C_CMD+1, "IMUL" },
{ 0x00FFFF, 0x00AF0F, 2,00, REG,MRG,NNN, C_CMD+0, "IMUL" },
{ 0x0000FF, 0x00006B, 1,00, REG,MRG,IMX, C_CMD+C_RARE+0, "IMUL" },
{ 0x0000FF, 0x000069, 1,00, REG,MRG,IMM, C_CMD+C_RARE+0, "IMUL" },
{ 0x0038FE, 0x0030F6, 1,WW, MRG,NNN,NNN, C_CMD+1, "DIV" },
{ 0x0038FE, 0x0038F6, 1,WW, MRG,NNN,NNN, C_CMD+1, "IDIV" },
{ 0x0000FF, 0x000098, 1,00, NNN,NNN,NNN, C_CMD+0, "&CBW:CWDE" },
{ 0x0000FF, 0x000099, 1,00, NNN,NNN,NNN, C_CMD+0, "&CWD:CDQ" },
{ 0x0038FE, 0x0000D0, 1,WW, MRG,C01,NNN, C_CMD+1, "ROL" },
{ 0x0038FE, 0x0008D0, 1,WW, MRG,C01,NNN, C_CMD+1, "ROR" },
{ 0x0038FE, 0x0010D0, 1,WW, MRG,C01,NNN, C_CMD+1, "RCL" },
{ 0x0038FE, 0x0018D0, 1,WW, MRG,C01,NNN, C_CMD+1, "RCR" },
{ 0x0038FE, 0x0020D0, 1,WW, MRG,C01,NNN, C_CMD+1, "SHL" },
{ 0x0038FE, 0x0028D0, 1,WW, MRG,C01,NNN, C_CMD+1, "SHR" },
{ 0x0038FE, 0x0038D0, 1,WW, MRG,C01,NNN, C_CMD+1, "SAR" },
{ 0x0038FE, 0x0000D2, 1,WW, MRG,RCL,NNN, C_CMD+1, "ROL" },
{ 0x0038FE, 0x0008D2, 1,WW, MRG,RCL,NNN, C_CMD+1, "ROR" },
{ 0x0038FE, 0x0010D2, 1,WW, MRG,RCL,NNN, C_CMD+1, "RCL" },
{ 0x0038FE, 0x0018D2, 1,WW, MRG,RCL,NNN, C_CMD+1, "RCR" },
{ 0x0038FE, 0x0020D2, 1,WW, MRG,RCL,NNN, C_CMD+1, "SHL" },
{ 0x0038FE, 0x0028D2, 1,WW, MRG,RCL,NNN, C_CMD+1, "SHR" },
{ 0x0038FE, 0x0038D2, 1,WW, MRG,RCL,NNN, C_CMD+1, "SAR" },
{ 0x0038FE, 0x0000C0, 1,WW, MRG,IMS,NNN, C_CMD+1, "ROL" },
{ 0x0038FE, 0x0008C0, 1,WW, MRG,IMS,NNN, C_CMD+1, "ROR" },
{ 0x0038FE, 0x0010C0, 1,WW, MRG,IMS,NNN, C_CMD+1, "RCL" },
{ 0x0038FE, 0x0018C0, 1,WW, MRG,IMS,NNN, C_CMD+1, "RCR" },
{ 0x0038FE, 0x0038C0, 1,WW, MRG,IMS,NNN, C_CMD+1, "SAR" },
{ 0x0000FF, 0x000070, 1,CC, JOB,NNN,NNN, C_JMC+0, "JO" },
{ 0x0000FF, 0x000071, 1,CC, JOB,NNN,NNN, C_JMC+0, "JNO" },
{ 0x0000FF, 0x000072, 1,CC, JOB,NNN,NNN, C_JMC+0, "JB,JC" },
{ 0x0000FF, 0x000073, 1,CC, JOB,NNN,NNN, C_JMC+0, "JNB,JNC" },
{ 0x0000FF, 0x000076, 1,CC, JOB,NNN,NNN, C_JMC+0, "JBE,JNA" },
{ 0x0000FF, 0x000077, 1,CC, JOB,NNN,NNN, C_JMC+0, "JA,JNBE" },
{ 0x0000FF, 0x000078, 1,CC, JOB,NNN,NNN, C_JMC+0, "JS" },
{ 0x0000FF, 0x000079, 1,CC, JOB,NNN,NNN, C_JMC+0, "JNS" },
{ 0x0000FF, 0x00007A, 1,CC, JOB,NNN,NNN, C_JMC+C_RARE+0, "JPE,JP" },
{ 0x0000FF, 0x00007B, 1,CC, JOB,NNN,NNN, C_JMC+C_RARE+0, "JPO,JNP" },
{ 0x0000FF, 0x0000E3, 1,00, JOB,NNN,NNN, C_JMC+C_RARE+0, "$JCXZ:JECXZ" },
{ 0x00FFFF, 0x00800F, 2,CC, JOW,NNN,NNN, C_JMC+0, "JO" },
{ 0x00FFFF, 0x00810F, 2,CC, JOW,NNN,NNN, C_JMC+0, "JNO" },
{ 0x00FFFF, 0x00820F, 2,CC, JOW,NNN,NNN, C_JMC+0, "JB,JC" },
{ 0x00FFFF, 0x00830F, 2,CC, JOW,NNN,NNN, C_JMC+0, "JNB,JNC" },
{ 0x00FFFF, 0x00860F, 2,CC, JOW,NNN,NNN, C_JMC+0, "JBE,JNA" },
{ 0x00FFFF, 0x00870F, 2,CC, JOW,NNN,NNN, C_JMC+0, "JA,JNBE" },
{ 0x00FFFF, 0x00880F, 2,CC, JOW,NNN,NNN, C_JMC+0, "JS" },
{ 0x00FFFF, 0x00890F, 2,CC, JOW,NNN,NNN, C_JMC+0, "JNS" },
{ 0x00FFFF, 0x008A0F, 2,CC, JOW,NNN,NNN, C_JMC+C_RARE+0, "JPE,JP" },
{ 0x00FFFF, 0x008B0F, 2,CC, JOW,NNN,NNN, C_JMC+C_RARE+0, "JPO,JNP" },
{ 0x00FFFF, 0x008C0F, 2,CC, JOW,NNN,NNN, C_JMC+0, "JL,JNGE" },
{ 0x00FFFF, 0x008D0F, 2,CC, JOW,NNN,NNN, C_JMC+0, "JGE,JNL" },
{ 0x00FFFF, 0x008E0F, 2,CC, JOW,NNN,NNN, C_JMC+0, "JLE,JNG" },
{ 0x00FFFF, 0x008F0F, 2,CC, JOW,NNN,NNN, C_JMC+0, "JG,JNLE" },
{ 0x0000FF, 0x0000F8, 1,00, NNN,NNN,NNN, C_CMD+0, "CLC" },
{ 0x0000FF, 0x0000F9, 1,00, NNN,NNN,NNN, C_CMD+0, "STC" },
{ 0x0000FF, 0x0000F5, 1,00, NNN,NNN,NNN, C_CMD+C_RARE+0, "CMC" },
{ 0x0000FF, 0x0000FC, 1,00, NNN,NNN,NNN, C_CMD+0, "CLD" },
{ 0x0000FF, 0x0000FD, 1,00, NNN,NNN,NNN, C_CMD+0, "STD" },
{ 0x0000FF, 0x0000FA, 1,00, NNN,NNN,NNN, C_CMD+C_RARE+0, "CLI" },
{ 0x0000FF, 0x0000FB, 1,00, NNN,NNN,NNN, C_CMD+C_RARE+0, "STI" },
{ 0x0000FF, 0x00008C, 1,FF, MRG,SGM,NNN, C_CMD+C_RARE+0, "MOV" },
{ 0x0000FF, 0x00008E, 1,FF, SGM,MRG,NNN, C_CMD+C_RARE+0, "MOV" },
{ 0x0000FE, 0x0000A6, 1,WW, MSO,MDE,NNN, C_CMD+1, "CMPS" },
{ 0x0000FE, 0x0000AC, 1,WW, MSO,NNN,NNN, C_CMD+1, "LODS" },
{ 0x0000FE, 0x0000A4, 1,WW, MDE,MSO,NNN, C_CMD+1, "MOVS" },
{ 0x0000FE, 0x0000AE, 1,WW, MDE,PAC,NNN, C_CMD+1, "SCAS" },
{ 0x0000FE, 0x0000AA, 1,WW, MDE,PAC,NNN, C_CMD+1, "STOS" },
{ 0x00FEFF, 0x00A4F3, 1,WW, MDE,MSO,PCX, C_REP+1, "REP MOVS" },
{ 0x00FEFF, 0x00ACF3, 1,WW, MSO,PAC,PCX, C_REP+C_RARE+1, "REP LODS" },
{ 0x00FEFF, 0x00AAF3, 1,WW, MDE,PAC,PCX, C_REP+1, "REP STOS" },
{ 0x00FEFF, 0x00A6F3, 1,WW, MDE,MSO,PCX, C_REP+1, "REPE CMPS" },
{ 0x00FEFF, 0x00AEF3, 1,WW, MDE,PAC,PCX, C_REP+1, "REPE SCAS" },
{ 0x00FEFF, 0x00A6F2, 1,WW, MDE,MSO,PCX, C_REP+1, "REPNE CMPS" },
{ 0x00FEFF, 0x00AEF2, 1,WW, MDE,PAC,PCX, C_REP+1, "REPNE SCAS" },
{ 0x0000FF, 0x0000EA, 1,00, JMF,NNN,NNN, C_JMP+C_RARE+0, "JMP" },
{ 0x0038FF, 0x0028FF, 1,00, MMS,NNN,NNN, C_JMP+C_RARE+1, "JMP" },
{ 0x0000FF, 0x00009A, 1,00, JMF,NNN,NNN, C_CAL+C_RARE+0, "CALL" },
{ 0x0038FF, 0x0018FF, 1,00, MMS,NNN,NNN, C_CAL+C_RARE+1, "CALL" },
{ 0x0000FF, 0x0000CB, 1,00, PRF,NNN,NNN, C_RET+C_RARE+0, "RETF" },
{ 0x0000FF, 0x0000CA, 1,00, IM2,PRF,NNN, C_RET+C_RARE+0, "RETF" },
{ 0x00FFFF, 0x00A40F, 2,00, MRG,REG,IMS, C_CMD+0, "SHLD" },
{ 0x00FFFF, 0x00AC0F, 2,00, MRG,REG,IMS, C_CMD+0, "SHRD" },
{ 0x00FFFF, 0x00A50F, 2,00, MRG,REG,RCL, C_CMD+0, "SHLD" },
{ 0x00FFFF, 0x00AD0F, 2,00, MRG,REG,RCL, C_CMD+0, "SHRD" },
{ 0x00F8FF, 0x00C80F, 2,00, RCM,NNN,NNN, C_CMD+C_RARE+0, "BSWAP" },
{ 0x00FEFF, 0x00C00F, 2,WW, MRG,REG,NNN, C_CMD+C_RARE+0, "XADD" },
{ 0x0000FF, 0x0000E2, 1,LL, JOB,PCX,NNN, C_JMC+0, "$LOOP*" },
{ 0x0000FF, 0x0000E1, 1,LL, JOB,PCX,NNN, C_JMC+0, "$LOOP*E" },
{ 0x0000FF, 0x0000E0, 1,LL, JOB,PCX,NNN, C_JMC+0, "$LOOP*NE" },
{ 0x0000FF, 0x0000C8, 1,00, IM2,IM1,NNN, C_CMD+0, "ENTER" },
{ 0x0000FE, 0x0000E4, 1,WP, RAC,IM1,NNN, C_CMD+C_RARE+0, "IN" },
{ 0x0000FE, 0x0000EC, 1,WP, RAC,RDX,NNN, C_CMD+C_RARE+0, "IN" },
{ 0x0000FE, 0x0000E6, 1,WP, IM1,RAC,NNN, C_CMD+C_RARE+0, "OUT" },
{ 0x0000FE, 0x0000EE, 1,WP, RDX,RAC,NNN, C_CMD+C_RARE+0, "OUT" },
{ 0x0000FE, 0x00006C, 1,WP, MDE,RDX,NNN, C_CMD+C_RARE+1, "INS" },
{ 0x0000FE, 0x00006E, 1,WP, RDX,MDE,NNN, C_CMD+C_RARE+1, "OUTS" },
{ 0x00FEFF, 0x006CF3, 1,WP, MDE,RDX,PCX, C_REP+C_RARE+1, "REP INS" },
{ 0x00FEFF, 0x006EF3, 1,WP, RDX,MDE,PCX, C_REP+C_RARE+1, "REP OUTS" },
{ 0x0000FF, 0x000037, 1,00, NNN,NNN,NNN, C_CMD+C_RARE+0, "AAA" },
{ 0x0000FF, 0x00003F, 1,00, NNN,NNN,NNN, C_CMD+C_RARE+0, "AAS" },
{ 0x00FFFF, 0x000AD4, 2,00, NNN,NNN,NNN, C_CMD+C_RARE+0, "AAM" },
{ 0x0000FF, 0x0000D4, 1,00, IM1,NNN,NNN, C_CMD+C_RARE+0, "AAM" },
{ 0x00FFFF, 0x000AD5, 2,00, NNN,NNN,NNN, C_CMD+C_RARE+0, "AAD" },
{ 0x0000FF, 0x0000D5, 1,00, IM1,NNN,NNN, C_CMD+C_RARE+0, "AAD" },
{ 0x0000FF, 0x000027, 1,00, NNN,NNN,NNN, C_CMD+C_RARE+0, "DAA" },
{ 0x0000FF, 0x00002F, 1,00, NNN,NNN,NNN, C_CMD+C_RARE+0, "DAS" },
{ 0x0000FF, 0x0000F4, 1,PR, NNN,NNN,NNN, C_PRI+C_RARE+0, "HLT" },
{ 0x0000FF, 0x00000E, 1,00, SCM,NNN,NNN, C_PSH+C_RARE+0, "PUSH" },
{ 0x0000FF, 0x000016, 1,00, SCM,NNN,NNN, C_PSH+C_RARE+0, "PUSH" },
{ 0x0000FF, 0x00001E, 1,00, SCM,NNN,NNN, C_PSH+C_RARE+0, "PUSH" },
{ 0x0000FF, 0x000006, 1,00, SCM,NNN,NNN, C_PSH+C_RARE+0, "PUSH" },
{ 0x00FFFF, 0x00A00F, 2,00, SCM,NNN,NNN, C_PSH+C_RARE+0, "PUSH" },
{ 0x00FFFF, 0x00A80F, 2,00, SCM,NNN,NNN, C_PSH+C_RARE+0, "PUSH" },
{ 0x0000FF, 0x00001F, 1,00, SCM,NNN,NNN, C_POP+C_RARE+0, "POP" },
{ 0x0000FF, 0x000007, 1,00, SCM,NNN,NNN, C_POP+C_RARE+0, "POP" },
{ 0x0000FF, 0x000017, 1,00, SCM,NNN,NNN, C_POP+C_RARE+0, "POP" },
{ 0x00FFFF, 0x00A10F, 2,00, SCM,NNN,NNN, C_POP+C_RARE+0, "POP" },
{ 0x00FFFF, 0x00A90F, 2,00, SCM,NNN,NNN, C_POP+C_RARE+0, "POP" },
{ 0x0000FF, 0x0000D7, 1,00, MXL,NNN,NNN, C_CMD+C_RARE+1, "XLAT" },
{ 0x00FFFF, 0x00BE0F, 2,00, REG,MR1,NNN, C_CMD+1, "MOVSX" },
{ 0x00FFFF, 0x00B60F, 2,00, REG,MR1,NNN, C_CMD+1, "MOVZX" },
{ 0x00FFFF, 0x00B70F, 2,00, REG,MR2,NNN, C_CMD+1, "MOVZX" },
{ 0x0000FF, 0x00009B, 1,00, NNN,NNN,NNN, C_CMD+0, "WAIT" },
{ 0x0000FF, 0x00009F, 1,00, PAH,PFL,NNN, C_CMD+C_RARE+0, "LAHF" },
{ 0x0000FF, 0x00009E, 1,00, PFL,PAH,NNN, C_CMD+C_RARE+0, "SAHF" },
{ 0x0000FF, 0x00009C, 1,00, NNN,NNN,NNN, C_PSH+0, "&PUSHF*" },
{ 0x0000FF, 0x00009D, 1,00, NNN,NNN,NNN, C_FLG+0, "&POPF*" },
{ 0x0000FF, 0x0000CD, 1,00, IM1,NNN,NNN, C_CAL+C_RARE+0, "INT" },
{ 0x0000FF, 0x0000CC, 1,00, NNN,NNN,NNN, C_CAL+C_RARE+0, "INT3" },
{ 0x0000FF, 0x0000CE, 1,00, NNN,NNN,NNN, C_CAL+C_RARE+0, "INTO" },
{ 0x0000FF, 0x0000CF, 1,00, NNN,NNN,NNN, C_RTF+C_RARE+0, "&IRET*" },
{ 0x00FFFF, 0x00900F, 2,CC, MR1,NNN,NNN, C_CMD+0, "SETO" },
{ 0x00FFFF, 0x00910F, 2,CC, MR1,NNN,NNN, C_CMD+0, "SETNO" },
{ 0x00FFFF, 0x00920F, 2,CC, MR1,NNN,NNN, C_CMD+0, "SETB,SETC" },
{ 0x00FFFF, 0x00930F, 2,CC, MR1,NNN,NNN, C_CMD+0, "SETNB,SETNC" },
{ 0x00FFFF, 0x00940F, 2,CC, MR1,NNN,NNN, C_CMD+0, "SETE,SETZ" },
{ 0x00FFFF, 0x00950F, 2,CC, MR1,NNN,NNN, C_CMD+0, "SETNE,SETNZ" },
{ 0x00FFFF, 0x00960F, 2,CC, MR1,NNN,NNN, C_CMD+0, "SETBE,SETNA" },
{ 0x00FFFF, 0x00970F, 2,CC, MR1,NNN,NNN, C_CMD+0, "SETA,SETNBE" },
{ 0x00FFFF, 0x00980F, 2,CC, MR1,NNN,NNN, C_CMD+0, "SETS" },
{ 0x00FFFF, 0x00990F, 2,CC, MR1,NNN,NNN, C_CMD+0, "SETNS" },
{ 0x00FFFF, 0x009A0F, 2,CC, MR1,NNN,NNN, C_CMD+C_RARE+0, "SETPE,SETP" },
{ 0x00FFFF, 0x009B0F, 2,CC, MR1,NNN,NNN, C_CMD+C_RARE+0, "SETPO,SETNP" },
{ 0x00FFFF, 0x009C0F, 2,CC, MR1,NNN,NNN, C_CMD+0, "SETL,SETNGE" },
{ 0x00FFFF, 0x009D0F, 2,CC, MR1,NNN,NNN, C_CMD+0, "SETGE,SETNL" },
{ 0x00FFFF, 0x009E0F, 2,CC, MR1,NNN,NNN, C_CMD+0, "SETLE,SETNG" },
{ 0x00FFFF, 0x009F0F, 2,CC, MR1,NNN,NNN, C_CMD+0, "SETG,SETNLE" },
{ 0x38FFFF, 0x20BA0F, 2,00, MRG,IM1,NNN, C_CMD+C_RARE+1, "BT" },
{ 0x38FFFF, 0x28BA0F, 2,00, MRG,IM1,NNN, C_CMD+C_RARE+1, "BTS" },
{ 0x38FFFF, 0x30BA0F, 2,00, MRG,IM1,NNN, C_CMD+C_RARE+1, "BTR" },
{ 0x38FFFF, 0x38BA0F, 2,00, MRG,IM1,NNN, C_CMD+C_RARE+1, "BTC" },
{ 0x00FFFF, 0x00A30F, 2,00, MRG,REG,NNN, C_CMD+C_RARE+1, "BT" },
{ 0x00FFFF, 0x00AB0F, 2,00, MRG,REG,NNN, C_CMD+C_RARE+1, "BTS" },
{ 0x00FFFF, 0x00B30F, 2,00, MRG,REG,NNN, C_CMD+C_RARE+1, "BTR" },
{ 0x00FFFF, 0x00BB0F, 2,00, MRG,REG,NNN, C_CMD+C_RARE+1, "BTC" },
{ 0x0000FF, 0x0000C5, 1,00, REG,MML,NNN, C_CMD+C_RARE+0, "LDS" },
{ 0x0000FF, 0x0000C4, 1,00, REG,MML,NNN, C_CMD+C_RARE+0, "LES" },
{ 0x00FFFF, 0x00B40F, 2,00, REG,MML,NNN, C_CMD+C_RARE+0, "LFS" },
{ 0x00FFFF, 0x00B50F, 2,00, REG,MML,NNN, C_CMD+C_RARE+0, "LGS" },
{ 0x00FFFF, 0x00B20F, 2,00, REG,MML,NNN, C_CMD+C_RARE+0, "LSS" },
{ 0x0000FF, 0x000063, 1,00, MRG,REG,NNN, C_CMD+C_RARE+0, "ARPL" },
{ 0x0000FF, 0x000062, 1,00, REG,MMB,NNN, C_CMD+C_RARE+0, "BOUND" },
{ 0x00FFFF, 0x00BC0F, 2,00, REG,MRG,NNN, C_CMD+C_RARE+0, "BSF" },
{ 0x00FFFF, 0x00BD0F, 2,00, REG,MRG,NNN, C_CMD+C_RARE+0, "BSR" },
{ 0x00FFFF, 0x00060F, 2,PR, NNN,NNN,NNN, C_CMD+C_RARE+0, "CLTS" },
{ 0x00FFFF, 0x00400F, 2,CC, REG,MRG,NNN, C_CMD+0, "CMOVO" },
{ 0x00FFFF, 0x00410F, 2,CC, REG,MRG,NNN, C_CMD+0, "CMOVNO" },
{ 0x00FFFF, 0x00420F, 2,CC, REG,MRG,NNN, C_CMD+0, "CMOVB,CMOVC" },
{ 0x00FFFF, 0x00430F, 2,CC, REG,MRG,NNN, C_CMD+0, "CMOVNB,CMOVNC" },
{ 0x00FFFF, 0x00440F, 2,CC, REG,MRG,NNN, C_CMD+0, "CMOVE,CMOVZ" },
{ 0x00FFFF, 0x00450F, 2,CC, REG,MRG,NNN, C_CMD+0, "CMOVNE,CMOVNZ" },
{ 0x00FFFF, 0x00460F, 2,CC, REG,MRG,NNN, C_CMD+0, "CMOVBE,CMOVNA" },
{ 0x00FFFF, 0x00470F, 2,CC, REG,MRG,NNN, C_CMD+0, "CMOVA,CMOVNBE" },
{ 0x00FFFF, 0x00480F, 2,CC, REG,MRG,NNN, C_CMD+0, "CMOVS" },
{ 0x00FFFF, 0x00490F, 2,CC, REG,MRG,NNN, C_CMD+0, "CMOVNS" },
{ 0x00FFFF, 0x004A0F, 2,CC, REG,MRG,NNN, C_CMD+0, "CMOVPE,CMOVP" },
{ 0x00FFFF, 0x004B0F, 2,CC, REG,MRG,NNN, C_CMD+0, "CMOVPO,CMOVNP" },
{ 0x00FFFF, 0x004C0F, 2,CC, REG,MRG,NNN, C_CMD+0, "CMOVL,CMOVNGE" },
{ 0x00FFFF, 0x004D0F, 2,CC, REG,MRG,NNN, C_CMD+0, "CMOVGE,CMOVNL" },
{ 0x00FFFF, 0x004E0F, 2,CC, REG,MRG,NNN, C_CMD+0, "CMOVLE,CMOVNG" },
{ 0x00FFFF, 0x004F0F, 2,CC, REG,MRG,NNN, C_CMD+0, "CMOVG,CMOVNLE" },
{ 0x00FEFF, 0x00B00F, 2,WW, MRG,REG,NNN, C_CMD+C_RARE+0, "CMPXCHG" },
{ 0x38FFFF, 0x08C70F, 2,00, MD8,NNN,NNN, C_CMD+C_RARE+1, "CMPXCHG8B" },
{ 0x00FFFF, 0x00A20F, 2,00, NNN,NNN,NNN, C_CMD+0, "CPUID" },
{ 0x00FFFF, 0x00080F, 2,PR, NNN,NNN,NNN, C_CMD+C_RARE+0, "INVD" },
{ 0x00FFFF, 0x00020F, 2,00, REG,MRG,NNN, C_CMD+C_RARE+0, "LAR" },
{ 0x00FFFF, 0x00030F, 2,00, REG,MRG,NNN, C_CMD+C_RARE+0, "LSL" },
{ 0x38FFFF, 0x38010F, 2,PR, MR1,NNN,NNN, C_CMD+C_RARE+0, "INVLPG" },
{ 0x00FFFF, 0x00090F, 2,PR, NNN,NNN,NNN, C_CMD+C_RARE+0, "WBINVD" },
{ 0x38FFFF, 0x10010F, 2,PR, MM6,NNN,NNN, C_CMD+C_RARE+0, "LGDT" },
{ 0x38FFFF, 0x00010F, 2,00, MM6,NNN,NNN, C_CMD+C_RARE+0, "SGDT" },
{ 0x38FFFF, 0x18010F, 2,PR, MM6,NNN,NNN, C_CMD+C_RARE+0, "LIDT" },
{ 0x38FFFF, 0x08010F, 2,00, MM6,NNN,NNN, C_CMD+C_RARE+0, "SIDT" },
{ 0x38FFFF, 0x10000F, 2,PR, MR2,NNN,NNN, C_CMD+C_RARE+0, "LLDT" },
{ 0x38FFFF, 0x00000F, 2,00, MR2,NNN,NNN, C_CMD+C_RARE+0, "SLDT" },
{ 0x38FFFF, 0x18000F, 2,PR, MR2,NNN,NNN, C_CMD+C_RARE+0, "LTR" },
{ 0x38FFFF, 0x08000F, 2,00, MR2,NNN,NNN, C_CMD+C_RARE+0, "STR" },
{ 0x38FFFF, 0x30010F, 2,PR, MR2,NNN,NNN, C_CMD+C_RARE+0, "LMSW" },
{ 0x38FFFF, 0x20010F, 2,00, MR2,NNN,NNN, C_CMD+C_RARE+0, "SMSW" },
{ 0x38FFFF, 0x20000F, 2,00, MR2,NNN,NNN, C_CMD+C_RARE+0, "VERR" },
{ 0x38FFFF, 0x28000F, 2,00, MR2,NNN,NNN, C_CMD+C_RARE+0, "VERW" },
{ 0xC0FFFF, 0xC0220F, 2,PR, CRX,RR4,NNN, C_CMD+C_RARE+0, "MOV" },
{ 0xC0FFFF, 0xC0200F, 2,00, RR4,CRX,NNN, C_CMD+C_RARE+0, "MOV" },
{ 0xC0FFFF, 0xC0230F, 2,PR, DRX,RR4,NNN, C_CMD+C_RARE+0, "MOV" },
{ 0xC0FFFF, 0xC0210F, 2,PR, RR4,DRX,NNN, C_CMD+C_RARE+0, "MOV" },
{ 0x00FFFF, 0x00310F, 2,00, NNN,NNN,NNN, C_CMD+C_RARE+0, "RDTSC" },
{ 0x00FFFF, 0x00320F, 2,PR, NNN,NNN,NNN, C_CMD+C_RARE+0, "RDMSR" },
{ 0x00FFFF, 0x00300F, 2,PR, NNN,NNN,NNN, C_CMD+C_RARE+0, "WRMSR" },
{ 0x00FFFF, 0x00330F, 2,PR, NNN,NNN,NNN, C_CMD+C_RARE+0, "RDPMC" },
{ 0x00FFFF, 0x00AA0F, 2,PR, NNN,NNN,NNN, C_RTF+C_RARE+0, "RSM" },
{ 0x00FFFF, 0x000B0F, 2,00, NNN,NNN,NNN, C_CMD+C_RARE+0, "UD2" },
{ 0x00FFFF, 0x00340F, 2,00, NNN,NNN,NNN, C_CMD+C_RARE+0, "SYSENTER" },
{ 0x00FFFF, 0x00350F, 2,PR, NNN,NNN,NNN, C_CMD+C_RARE+0, "SYSEXIT" },
{ 0x0000FF, 0x0000D6, 1,00, NNN,NNN,NNN, C_CMD+C_RARE+0, "SALC" },
// FPU instructions. Never change the order of instructions!
{ 0x00FFFF, 0x00F0D9, 2,00, PS0,NNN,NNN, C_FLT+0, "F2XM1" },
{ 0x00FFFF, 0x00E0D9, 2,00, PS0,NNN,NNN, C_FLT+0, "FCHS" },
{ 0x00FFFF, 0x00E1D9, 2,00, PS0,NNN,NNN, C_FLT+0, "FABS" },
{ 0x00FFFF, 0x00E2DB, 2,00, NNN,NNN,NNN, C_FLT+0, "FCLEX" },
{ 0x00FFFF, 0x00E3DB, 2,00, NNN,NNN,NNN, C_FLT+0, "FINIT" },
{ 0x00FFFF, 0x00F6D9, 2,00, NNN,NNN,NNN, C_FLT+0, "FDECSTP" },
{ 0x00FFFF, 0x00F7D9, 2,00, NNN,NNN,NNN, C_FLT+0, "FINCSTP" },
{ 0x00FFFF, 0x00E4D9, 2,00, PS0,NNN,NNN, C_FLT+0, "FTST" },
{ 0x00FFFF, 0x00FAD9, 2,00, PS0,NNN,NNN, C_FLT+0, "FSQRT" },
{ 0x00FFFF, 0x00FED9, 2,00, PS0,NNN,NNN, C_FLT+0, "FSIN" },
{ 0x00FFFF, 0x00FFD9, 2,00, PS0,NNN,NNN, C_FLT+0, "FCOS" },
{ 0x00FFFF, 0x00FBD9, 2,00, PS0,NNN,NNN, C_FLT+0, "FSINCOS" },
{ 0x00FFFF, 0x00F2D9, 2,00, PS0,NNN,NNN, C_FLT+0, "FPTAN" },
{ 0x00FFFF, 0x00F3D9, 2,00, PS0,PS1,NNN, C_FLT+0, "FPATAN" },
{ 0x00FFFF, 0x00F8D9, 2,00, PS1,PS0,NNN, C_FLT+0, "FPREM" },
{ 0x00FFFF, 0x00F5D9, 2,00, PS1,PS0,NNN, C_FLT+0, "FPREM1" },
{ 0x00FFFF, 0x00F1D9, 2,00, PS0,PS1,NNN, C_FLT+0, "FYL2X" },
{ 0x00FFFF, 0x00F9D9, 2,00, PS0,PS1,NNN, C_FLT+0, "FYL2XP1" },
{ 0x00FFFF, 0x00FCD9, 2,00, PS0,NNN,NNN, C_FLT+0, "FRNDINT" },
{ 0x00FFFF, 0x00E8D9, 2,00, NNN,NNN,NNN, C_FLT+0, "FLD1" },
{ 0x00FFFF, 0x00E9D9, 2,00, NNN,NNN,NNN, C_FLT+0, "FLDL2T" },
{ 0x00FFFF, 0x00EAD9, 2,00, NNN,NNN,NNN, C_FLT+0, "FLDL2E" },
{ 0x00FFFF, 0x00EBD9, 2,00, NNN,NNN,NNN, C_FLT+0, "FLDPI" },
{ 0x00FFFF, 0x00ECD9, 2,00, NNN,NNN,NNN, C_FLT+0, "FLDLG2" },
{ 0x00FFFF, 0x00EDD9, 2,00, NNN,NNN,NNN, C_FLT+0, "FLDLN2" },
{ 0x00FFFF, 0x00EED9, 2,00, NNN,NNN,NNN, C_FLT+0, "FLDZ" },
{ 0x00FFFF, 0x00FDD9, 2,00, PS0,PS1,NNN, C_FLT+0, "FSCALE" },
{ 0x00FFFF, 0x00D0D9, 2,00, NNN,NNN,NNN, C_FLT+0, "FNOP" },
{ 0x00FFFF, 0x00E0DF, 2,FF, RAX,NNN,NNN, C_FLT+0, "FSTSW" },
{ 0x00FFFF, 0x00E5D9, 2,00, PS0,NNN,NNN, C_FLT+0, "FXAM" },
{ 0x00FFFF, 0x00F4D9, 2,00, PS0,NNN,NNN, C_FLT+0, "FXTRACT" },
{ 0x00FFFF, 0x00D9DE, 2,00, PS0,PS1,NNN, C_FLT+0, "FCOMPP" },
{ 0x00FFFF, 0x00E9DA, 2,00, PS0,PS1,NNN, C_FLT+0, "FUCOMPP" },
{ 0x00F8FF, 0x00C0DD, 2,00, RST,NNN,NNN, C_FLT+0, "FFREE" },
{ 0x00F8FF, 0x00C0DA, 2,00, RS0,RST,NNN, C_FLT+0, "FCMOVB" },
{ 0x00F8FF, 0x00C8DA, 2,00, RS0,RST,NNN, C_FLT+0, "FCMOVE" },
{ 0x00F8FF, 0x00D0DA, 2,00, RS0,RST,NNN, C_FLT+0, "FCMOVBE" },
{ 0x00F8FF, 0x00D8DA, 2,00, RS0,RST,NNN, C_FLT+0, "FCMOVU" },
{ 0x00F8FF, 0x00C0DB, 2,00, RS0,RST,NNN, C_FLT+0, "FCMOVNB" },
{ 0x00F8FF, 0x00C8DB, 2,00, RS0,RST,NNN, C_FLT+0, "FCMOVNE" },
{ 0x00F8FF, 0x00D0DB, 2,00, RS0,RST,NNN, C_FLT+0, "FCMOVNBE" },
{ 0x00F8FF, 0x00D8DB, 2,00, RS0,RST,NNN, C_FLT+0, "FCMOVNU" },
{ 0x00F8FF, 0x00F0DB, 2,00, RS0,RST,NNN, C_FLT+0, "FCOMI" },
{ 0x00F8FF, 0x00F0DF, 2,00, RS0,RST,NNN, C_FLT+0, "FCOMIP" },
{ 0x00F8FF, 0x00E8DB, 2,00, RS0,RST,NNN, C_FLT+0, "FUCOMI" },
{ 0x00F8FF, 0x00E8DF, 2,00, RS0,RST,NNN, C_FLT+0, "FUCOMIP" },
{ 0x00F8FF, 0x00C0D8, 2,00, RS0,RST,NNN, C_FLT+0, "FADD" },
{ 0x00F8FF, 0x00C0DC, 2,00, RST,RS0,NNN, C_FLT+0, "FADD" },
{ 0x00F8FF, 0x00C0DE, 2,00, RST,RS0,NNN, C_FLT+0, "FADDP" },
{ 0x00F8FF, 0x00E0D8, 2,00, RS0,RST,NNN, C_FLT+0, "FSUB" },
{ 0x00F8FF, 0x00E8DC, 2,00, RST,RS0,NNN, C_FLT+0, "FSUB" },
{ 0x00F8FF, 0x00E8DE, 2,00, RST,RS0,NNN, C_FLT+0, "FSUBP" },
{ 0x00F8FF, 0x00E8D8, 2,00, RS0,RST,NNN, C_FLT+0, "FSUBR" },
{ 0x00F8FF, 0x00E0DC, 2,00, RST,RS0,NNN, C_FLT+0, "FSUBR" },
{ 0x00F8FF, 0x00E0DE, 2,00, RST,RS0,NNN, C_FLT+0, "FSUBRP" },
{ 0x00F8FF, 0x00C8D8, 2,00, RS0,RST,NNN, C_FLT+0, "FMUL" },
{ 0x00F8FF, 0x00C8DC, 2,00, RST,RS0,NNN, C_FLT+0, "FMUL" },
{ 0x00F8FF, 0x00C8DE, 2,00, RST,RS0,NNN, C_FLT+0, "FMULP" },
{ 0x00F8FF, 0x00D0D8, 2,00, RST,PS0,NNN, C_FLT+0, "FCOM" },
{ 0x00F8FF, 0x00D8D8, 2,00, RST,PS0,NNN, C_FLT+0, "FCOMP" },
{ 0x00F8FF, 0x00E0DD, 2,00, RST,PS0,NNN, C_FLT+0, "FUCOM" },
{ 0x00F8FF, 0x00E8DD, 2,00, RST,PS0,NNN, C_FLT+0, "FUCOMP" },
{ 0x00F8FF, 0x00F0D8, 2,00, RS0,RST,NNN, C_FLT+0, "FDIV" },
{ 0x00F8FF, 0x00F8DC, 2,00, RST,RS0,NNN, C_FLT+0, "FDIV" },
{ 0x00F8FF, 0x00F8DE, 2,00, RST,RS0,NNN, C_FLT+0, "FDIVP" },
{ 0x00F8FF, 0x00F8D8, 2,00, RS0,RST,NNN, C_FLT+0, "FDIVR" },
{ 0x00F8FF, 0x00F0DC, 2,00, RST,RS0,NNN, C_FLT+0, "FDIVR" },
{ 0x00F8FF, 0x00F0DE, 2,00, RST,RS0,NNN, C_FLT+0, "FDIVRP" },
{ 0x00F8FF, 0x00C0D9, 2,00, RST,NNN,NNN, C_FLT+0, "FLD" },
{ 0x00F8FF, 0x00D0DD, 2,00, RST,PS0,NNN, C_FLT+0, "FST" },
{ 0x00F8FF, 0x00D8DD, 2,00, RST,PS0,NNN, C_FLT+0, "FSTP" },
{ 0x00F8FF, 0x00C8D9, 2,00, RST,PS0,NNN, C_FLT+0, "FXCH" },
{ 0x0038FF, 0x0000D8, 1,00, MF4,PS0,NNN, C_FLT+1, "FADD" },
{ 0x0038FF, 0x0000DC, 1,00, MF8,PS0,NNN, C_FLT+1, "FADD" },
{ 0x0038FF, 0x0000DA, 1,00, MD4,PS0,NNN, C_FLT+1, "FIADD" },
{ 0x0038FF, 0x0000DE, 1,00, MD2,PS0,NNN, C_FLT+1, "FIADD" },
{ 0x0038FF, 0x0020D8, 1,00, MF4,PS0,NNN, C_FLT+1, "FSUB" },
{ 0x0038FF, 0x0020DC, 1,00, MF8,PS0,NNN, C_FLT+1, "FSUB" },
{ 0x0038FF, 0x0020DA, 1,00, MD4,PS0,NNN, C_FLT+1, "FISUB" },
{ 0x0038FF, 0x0020DE, 1,00, MD2,PS0,NNN, C_FLT+1, "FISUB" },
{ 0x0038FF, 0x0028D8, 1,00, MF4,PS0,NNN, C_FLT+1, "FSUBR" },
{ 0x0038FF, 0x0028DC, 1,00, MF8,PS0,NNN, C_FLT+1, "FSUBR" },
{ 0x0038FF, 0x0028DA, 1,00, MD4,PS0,NNN, C_FLT+1, "FISUBR" },
{ 0x0038FF, 0x0028DE, 1,00, MD2,PS0,NNN, C_FLT+1, "FISUBR" },
{ 0x0038FF, 0x0008D8, 1,00, MF4,PS0,NNN, C_FLT+1, "FMUL" },
{ 0x0038FF, 0x0008DC, 1,00, MF8,PS0,NNN, C_FLT+1, "FMUL" },
{ 0x0038FF, 0x0008DA, 1,00, MD4,PS0,NNN, C_FLT+1, "FIMUL" },
{ 0x0038FF, 0x0008DE, 1,00, MD2,PS0,NNN, C_FLT+1, "FIMUL" },
{ 0x0038FF, 0x0010D8, 1,00, MF4,PS0,NNN, C_FLT+1, "FCOM" },
{ 0x0038FF, 0x0010DC, 1,00, MF8,PS0,NNN, C_FLT+1, "FCOM" },
{ 0x0038FF, 0x0018D8, 1,00, MF4,PS0,NNN, C_FLT+1, "FCOMP" },
{ 0x0038FF, 0x0018DC, 1,00, MF8,PS0,NNN, C_FLT+1, "FCOMP" },
{ 0x0038FF, 0x0030D8, 1,00, MF4,PS0,NNN, C_FLT+1, "FDIV" },
{ 0x0038FF, 0x0030DC, 1,00, MF8,PS0,NNN, C_FLT+1, "FDIV" },
{ 0x0038FF, 0x0030DA, 1,00, MD4,PS0,NNN, C_FLT+1, "FIDIV" },
{ 0x0038FF, 0x0030DE, 1,00, MD2,PS0,NNN, C_FLT+1, "FIDIV" },
{ 0x0038FF, 0x0038D8, 1,00, MF4,PS0,NNN, C_FLT+1, "FDIVR" },
{ 0x0038FF, 0x0038DC, 1,00, MF8,PS0,NNN, C_FLT+1, "FDIVR" },
{ 0x0038FF, 0x0038DA, 1,00, MD4,PS0,NNN, C_FLT+1, "FIDIVR" },
{ 0x0038FF, 0x0038DE, 1,00, MD2,PS0,NNN, C_FLT+1, "FIDIVR" },
{ 0x0038FF, 0x0020DF, 1,00, MDA,NNN,NNN, C_FLT+C_RARE+1, "FBLD" },
{ 0x0038FF, 0x0030DF, 1,00, MDA,PS0,NNN, C_FLT+C_RARE+1, "FBSTP" },
{ 0x0038FF, 0x0010DE, 1,00, MD2,PS0,NNN, C_FLT+1, "FICOM" },
{ 0x0038FF, 0x0010DA, 1,00, MD4,PS0,NNN, C_FLT+1, "FICOM" },
{ 0x0038FF, 0x0018DE, 1,00, MD2,PS0,NNN, C_FLT+1, "FICOMP" },
{ 0x0038FF, 0x0018DA, 1,00, MD4,PS0,NNN, C_FLT+1, "FICOMP" },
{ 0x0038FF, 0x0000DF, 1,00, MD2,NNN,NNN, C_FLT+1, "FILD" },
{ 0x0038FF, 0x0000DB, 1,00, MD4,NNN,NNN, C_FLT+1, "FILD" },
{ 0x0038FF, 0x0028DF, 1,00, MD8,NNN,NNN, C_FLT+1, "FILD" },
{ 0x0038FF, 0x0010DF, 1,00, MD2,PS0,NNN, C_FLT+1, "FIST" },
{ 0x0038FF, 0x0010DB, 1,00, MD4,PS0,NNN, C_FLT+1, "FIST" },
{ 0x0038FF, 0x0018DF, 1,00, MD2,PS0,NNN, C_FLT+1, "FISTP" },
{ 0x0038FF, 0x0018DB, 1,00, MD4,PS0,NNN, C_FLT+1, "FISTP" },
{ 0x0038FF, 0x0038DF, 1,00, MD8,PS0,NNN, C_FLT+1, "FISTP" },
{ 0x0038FF, 0x0000D9, 1,00, MF4,NNN,NNN, C_FLT+1, "FLD" },
{ 0x0038FF, 0x0000DD, 1,00, MF8,NNN,NNN, C_FLT+1, "FLD" },
{ 0x0038FF, 0x0028DB, 1,00, MFA,NNN,NNN, C_FLT+1, "FLD" },
{ 0x0038FF, 0x0010D9, 1,00, MF4,PS0,NNN, C_FLT+1, "FST" },
{ 0x0038FF, 0x0010DD, 1,00, MF8,PS0,NNN, C_FLT+1, "FST" },
{ 0x0038FF, 0x0018D9, 1,00, MF4,PS0,NNN, C_FLT+1, "FSTP" },
{ 0x0038FF, 0x0018DD, 1,00, MF8,PS0,NNN, C_FLT+1, "FSTP" },
{ 0x0038FF, 0x0038DB, 1,00, MFA,PS0,NNN, C_FLT+1, "FSTP" },
{ 0x0038FF, 0x0028D9, 1,00, MB2,NNN,NNN, C_FLT+0, "FLDCW" },
{ 0x0038FF, 0x0038D9, 1,00, MB2,NNN,NNN, C_FLT+0, "FSTCW" },
{ 0x0038FF, 0x0020D9, 1,00, MFE,NNN,NNN, C_FLT+0, "FLDENV" },
{ 0x0038FF, 0x0030D9, 1,00, MFE,NNN,NNN, C_FLT+0, "FSTENV" },
{ 0x0038FF, 0x0020DD, 1,00, MFS,NNN,NNN, C_FLT+0, "FRSTOR" },
{ 0x0038FF, 0x0030DD, 1,00, MFS,NNN,NNN, C_FLT+0, "FSAVE" },
{ 0x0038FF, 0x0038DD, 1,00, MB2,NNN,NNN, C_FLT+0, "FSTSW" },
{ 0x38FFFF, 0x08AE0F, 2,00, MFX,NNN,NNN, C_FLT+0, "FXRSTOR" },
{ 0x38FFFF, 0x00AE0F, 2,00, MFX,NNN,NNN, C_FLT+0, "FXSAVE" },
{ 0x00FFFF, 0x00E0DB, 2,00, NNN,NNN,NNN, C_FLT+0, "FENI" },
{ 0x00FFFF, 0x00E1DB, 2,00, NNN,NNN,NNN, C_FLT+0, "FDISI" },
// MMX instructions. Length of MMX operand fields (in bytes) is added to the
// type, length of 0 means 8-byte MMX operand.
{ 0x00FFFF, 0x00770F, 2,00, NNN,NNN,NNN, C_MMX+0, "EMMS" },
{ 0x00FFFF, 0x006E0F, 2,00, RMX,MR4,NNN, C_MMX+0, "MOVD" },
{ 0x00FFFF, 0x007E0F, 2,00, MR4,RMX,NNN, C_MMX+0, "MOVD" },
{ 0x00FFFF, 0x006F0F, 2,00, RMX,MR8,NNN, C_MMX+0, "MOVQ" },
{ 0x00FFFF, 0x007F0F, 2,00, MR8,RMX,NNN, C_MMX+0, "MOVQ" },
{ 0x00FFFF, 0x00630F, 2,00, RMX,MR8,NNN, C_MMX+2, "PACKSSWB" },
{ 0x00FFFF, 0x006B0F, 2,00, RMX,MR8,NNN, C_MMX+4, "PACKSSDW" },
{ 0x00FFFF, 0x00670F, 2,00, RMX,MR8,NNN, C_MMX+2, "PACKUSWB" },
{ 0x00FFFF, 0x00FC0F, 2,00, RMX,MR8,NNN, C_MMX+1, "PADDB" },
{ 0x00FFFF, 0x00FD0F, 2,00, RMX,MR8,NNN, C_MMX+2, "PADDW" },
{ 0x00FFFF, 0x00FE0F, 2,00, RMX,MR8,NNN, C_MMX+4, "PADDD" },
{ 0x00FFFF, 0x00F80F, 2,00, RMX,MR8,NNN, C_MMX+1, "PSUBB" },
{ 0x00FFFF, 0x00F90F, 2,00, RMX,MR8,NNN, C_MMX+2, "PSUBW" },
{ 0x00FFFF, 0x00FA0F, 2,00, RMX,MR8,NNN, C_MMX+4, "PSUBD" },
{ 0x00FFFF, 0x00EC0F, 2,00, RMX,MR8,NNN, C_MMX+1, "PADDSB" },
{ 0x00FFFF, 0x00ED0F, 2,00, RMX,MR8,NNN, C_MMX+2, "PADDSW" },
{ 0x00FFFF, 0x00E80F, 2,00, RMX,MR8,NNN, C_MMX+1, "PSUBSB" },
{ 0x00FFFF, 0x00E90F, 2,00, RMX,MR8,NNN, C_MMX+2, "PSUBSW" },
{ 0x00FFFF, 0x00DC0F, 2,00, RMX,MR8,NNN, C_MMX+1, "PADDUSB" },
{ 0x00FFFF, 0x00DD0F, 2,00, RMX,MR8,NNN, C_MMX+2, "PADDUSW" },
{ 0x00FFFF, 0x00D80F, 2,00, RMX,MR8,NNN, C_MMX+1, "PSUBUSB" },
{ 0x00FFFF, 0x00D90F, 2,00, RMX,MR8,NNN, C_MMX+2, "PSUBUSW" },
{ 0x00FFFF, 0x00DB0F, 2,00, RMX,MR8,NNN, C_MMX+0, "PAND" },
{ 0x00FFFF, 0x00DF0F, 2,00, RMX,MR8,NNN, C_MMX+0, "PANDN" },
{ 0x00FFFF, 0x00740F, 2,00, RMX,MR8,NNN, C_MMX+1, "PCMPEQB" },
{ 0x00FFFF, 0x00750F, 2,00, RMX,MR8,NNN, C_MMX+2, "PCMPEQW" },
{ 0x00FFFF, 0x00760F, 2,00, RMX,MR8,NNN, C_MMX+4, "PCMPEQD" },
{ 0x00FFFF, 0x00640F, 2,00, RMX,MR8,NNN, C_MMX+1, "PCMPGTB" },
{ 0x00FFFF, 0x00650F, 2,00, RMX,MR8,NNN, C_MMX+2, "PCMPGTW" },
{ 0x00FFFF, 0x00660F, 2,00, RMX,MR8,NNN, C_MMX+4, "PCMPGTD" },
{ 0x00FFFF, 0x00F50F, 2,00, RMX,MR8,NNN, C_MMX+2, "PMADDWD" },
{ 0x00FFFF, 0x00E50F, 2,00, RMX,MR8,NNN, C_MMX+2, "PMULHW" },
{ 0x00FFFF, 0x00D50F, 2,00, RMX,MR8,NNN, C_MMX+2, "PMULLW" },
{ 0x00FFFF, 0x00EB0F, 2,00, RMX,MR8,NNN, C_MMX+0, "POR" },
{ 0x00FFFF, 0x00F10F, 2,00, RMX,MR8,NNN, C_MMX+2, "PSLLW" },
{ 0x38FFFF, 0x30710F, 2,00, MR8,IM1,NNN, C_MMX+2, "PSLLW" },
{ 0x00FFFF, 0x00F20F, 2,00, RMX,MR8,NNN, C_MMX+4, "PSLLD" },
{ 0x38FFFF, 0x30720F, 2,00, MR8,IM1,NNN, C_MMX+4, "PSLLD" },
{ 0x00FFFF, 0x00F30F, 2,00, RMX,MR8,NNN, C_MMX+0, "PSLLQ" },
{ 0x38FFFF, 0x30730F, 2,00, MR8,IM1,NNN, C_MMX+0, "PSLLQ" },
{ 0x00FFFF, 0x00E10F, 2,00, RMX,MR8,NNN, C_MMX+2, "PSRAW" },
{ 0x38FFFF, 0x20710F, 2,00, MR8,IM1,NNN, C_MMX+2, "PSRAW" },
{ 0x00FFFF, 0x00E20F, 2,00, RMX,MR8,NNN, C_MMX+4, "PSRAD" },
{ 0x38FFFF, 0x20720F, 2,00, MR8,IM1,NNN, C_MMX+4, "PSRAD" },
{ 0x00FFFF, 0x00D10F, 2,00, RMX,MR8,NNN, C_MMX+2, "PSRLW" },
{ 0x38FFFF, 0x10710F, 2,00, MR8,IM1,NNN, C_MMX+2, "PSRLW" },
{ 0x00FFFF, 0x00D20F, 2,00, RMX,MR8,NNN, C_MMX+4, "PSRLD" },
{ 0x38FFFF, 0x10720F, 2,00, MR8,IM1,NNN, C_MMX+4, "PSRLD" },
{ 0x00FFFF, 0x00D30F, 2,00, RMX,MR8,NNN, C_MMX+0, "PSRLQ" },
{ 0x38FFFF, 0x10730F, 2,00, MR8,IM1,NNN, C_MMX+0, "PSRLQ" },
{ 0x00FFFF, 0x00680F, 2,00, RMX,MR8,NNN, C_MMX+1, "PUNPCKHBW" },
{ 0x00FFFF, 0x00690F, 2,00, RMX,MR8,NNN, C_MMX+2, "PUNPCKHWD" },
{ 0x00FFFF, 0x006A0F, 2,00, RMX,MR8,NNN, C_MMX+4, "PUNPCKHDQ" },
{ 0x00FFFF, 0x00600F, 2,00, RMX,MR8,NNN, C_MMX+1, "PUNPCKLBW" },
{ 0x00FFFF, 0x00610F, 2,00, RMX,MR8,NNN, C_MMX+2, "PUNPCKLWD" },
{ 0x00FFFF, 0x00620F, 2,00, RMX,MR8,NNN, C_MMX+4, "PUNPCKLDQ" },
{ 0x00FFFF, 0x00EF0F, 2,00, RMX,MR8,NNN, C_MMX+0, "PXOR" },
// AMD extensions to MMX command set (including Athlon/PIII extensions).
{ 0x00FFFF, 0x000E0F, 2,00, NNN,NNN,NNN, C_MMX+0, "FEMMS" },
{ 0x38FFFF, 0x000D0F, 2,00, MD8,NNN,NNN, C_MMX+0, "PREFETCH" },
{ 0x38FFFF, 0x080D0F, 2,00, MD8,NNN,NNN, C_MMX+0, "PREFETCHW" },
{ 0x00FFFF, 0x00F70F, 2,00, RMX,RR8,PDI, C_MMX+1, "MASKMOVQ" },
{ 0x00FFFF, 0x00E70F, 2,00, MD8,RMX,NNN, C_MMX+0, "MOVNTQ" },
{ 0x00FFFF, 0x00E00F, 2,00, RMX,MR8,NNN, C_MMX+1, "PAVGB" },
{ 0x00FFFF, 0x00E30F, 2,00, RMX,MR8,NNN, C_MMX+2, "PAVGW" },
{ 0x00FFFF, 0x00C50F, 2,00, RR4,RMX,IM1, C_MMX+2, "PEXTRW" },
{ 0x00FFFF, 0x00C40F, 2,00, RMX,MR2,IM1, C_MMX+2, "PINSRW" },
{ 0x00FFFF, 0x00EE0F, 2,00, RMX,MR8,NNN, C_MMX+2, "PMAXSW" },
{ 0x00FFFF, 0x00DE0F, 2,00, RMX,MR8,NNN, C_MMX+1, "PMAXUB" },
{ 0x00FFFF, 0x00EA0F, 2,00, RMX,MR8,NNN, C_MMX+2, "PMINSW" },
{ 0x00FFFF, 0x00DA0F, 2,00, RMX,MR8,NNN, C_MMX+1, "PMINUB" },
{ 0x00FFFF, 0x00D70F, 2,00, RG4,RR8,NNN, C_MMX+1, "PMOVMSKB" },
{ 0x00FFFF, 0x00E40F, 2,00, RMX,MR8,NNN, C_MMX+2, "PMULHUW" },
{ 0x38FFFF, 0x00180F, 2,00, MD8,NNN,NNN, C_MMX+0, "PREFETCHNTA" },
{ 0x38FFFF, 0x08180F, 2,00, MD8,NNN,NNN, C_MMX+0, "PREFETCHT0" },
{ 0x38FFFF, 0x10180F, 2,00, MD8,NNN,NNN, C_MMX+0, "PREFETCHT1" },
{ 0x38FFFF, 0x18180F, 2,00, MD8,NNN,NNN, C_MMX+0, "PREFETCHT2" },
{ 0x00FFFF, 0x00F60F, 2,00, RMX,MR8,NNN, C_MMX+1, "PSADBW" },
{ 0x00FFFF, 0x00700F, 2,00, RMX,MR8,IM1, C_MMX+2, "PSHUFW" },
{ 0xFFFFFF, 0xF8AE0F, 2,00, NNN,NNN,NNN, C_MMX+0, "SFENCE" },
// AMD 3DNow! instructions (including Athlon extensions).
{ 0x00FFFF, 0xBF0F0F, 2,00, RMX,MR8,NNN, C_NOW+1, "PAVGUSB" },
{ 0x00FFFF, 0x9E0F0F, 2,00, R3D,MRD,NNN, C_NOW+4, "PFADD" },
{ 0x00FFFF, 0x9A0F0F, 2,00, R3D,MRD,NNN, C_NOW+4, "PFSUB" },
{ 0x00FFFF, 0xAA0F0F, 2,00, R3D,MRD,NNN, C_NOW+4, "PFSUBR" },
{ 0x00FFFF, 0xAE0F0F, 2,00, R3D,MRD,NNN, C_NOW+4, "PFACC" },
{ 0x00FFFF, 0x900F0F, 2,00, RMX,MRD,NNN, C_NOW+4, "PFCMPGE" },
{ 0x00FFFF, 0xA00F0F, 2,00, RMX,MRD,NNN, C_NOW+4, "PFCMPGT" },
{ 0x00FFFF, 0xB00F0F, 2,00, RMX,MRD,NNN, C_NOW+4, "PFCMPEQ" },
{ 0x00FFFF, 0x940F0F, 2,00, R3D,MRD,NNN, C_NOW+4, "PFMIN" },
{ 0x00FFFF, 0xA40F0F, 2,00, R3D,MRD,NNN, C_NOW+4, "PFMAX" },
{ 0x00FFFF, 0x0D0F0F, 2,00, R3D,MR8,NNN, C_NOW+4, "PI2FD" },
{ 0x00FFFF, 0x1D0F0F, 2,00, RMX,MRD,NNN, C_NOW+4, "PF2ID" },
{ 0x00FFFF, 0x960F0F, 2,00, R3D,MRD,NNN, C_NOW+4, "PFRCP" },
{ 0x00FFFF, 0x970F0F, 2,00, R3D,MRD,NNN, C_NOW+4, "PFRSQRT" },
{ 0x00FFFF, 0xB40F0F, 2,00, R3D,MRD,NNN, C_NOW+4, "PFMUL" },
{ 0x00FFFF, 0xA60F0F, 2,00, R3D,MRD,NNN, C_NOW+4, "PFRCPIT1" },
{ 0x00FFFF, 0xA70F0F, 2,00, R3D,MRD,NNN, C_NOW+4, "PFRSQIT1" },
{ 0x00FFFF, 0xB60F0F, 2,00, R3D,MRD,NNN, C_NOW+4, "PFRCPIT2" },
{ 0x00FFFF, 0xB70F0F, 2,00, RMX,MR8,NNN, C_NOW+2, "PMULHRW" },
{ 0x00FFFF, 0x1C0F0F, 2,00, RMX,MRD,NNN, C_NOW+4, "PF2IW" },
{ 0x00FFFF, 0x8A0F0F, 2,00, R3D,MRD,NNN, C_NOW+4, "PFNACC" },
{ 0x00FFFF, 0x8E0F0F, 2,00, R3D,MRD,NNN, C_NOW+4, "PFPNACC" },
{ 0x00FFFF, 0x0C0F0F, 2,00, R3D,MR8,NNN, C_NOW+4, "PI2FW" },
{ 0x00FFFF, 0xBB0F0F, 2,00, R3D,MRD,NNN, C_NOW+4, "PSWAPD" },
// Some alternative mnemonics for Assembler, not used by Disassembler (so
// implicit pseudooperands are not marked).
{ 0x0000FF, 0x0000A6, 1,00, NNN,NNN,NNN, C_CMD+0, "CMPSB" },
{ 0x00FFFF, 0x00A766, 2,00, NNN,NNN,NNN, C_CMD+0, "CMPSW" },
{ 0x0000FF, 0x0000A7, 1,00, NNN,NNN,NNN, C_CMD+0, "CMPSD" },
{ 0x0000FF, 0x0000AC, 1,00, NNN,NNN,NNN, C_CMD+0, "LODSB" },
{ 0x00FFFF, 0x00AD66, 2,00, NNN,NNN,NNN, C_CMD+0, "LODSW" },
{ 0x0000FF, 0x0000AD, 1,00, NNN,NNN,NNN, C_CMD+0, "LODSD" },
{ 0x0000FF, 0x0000A4, 1,00, NNN,NNN,NNN, C_CMD+0, "MOVSB" },
{ 0x00FFFF, 0x00A566, 2,00, NNN,NNN,NNN, C_CMD+0, "MOVSW" },
{ 0x0000FF, 0x0000A5, 1,00, NNN,NNN,NNN, C_CMD+0, "MOVSD" },
{ 0x0000FF, 0x0000AE, 1,00, NNN,NNN,NNN, C_CMD+0, "SCASB" },
{ 0x00FFFF, 0x00AF66, 1,00, NNN,NNN,NNN, C_CMD+0, "SCASW" },
{ 0x0000FF, 0x0000AF, 1,00, NNN,NNN,NNN, C_CMD+0, "SCASD" },
{ 0x0000FF, 0x0000AA, 1,00, NNN,NNN,NNN, C_CMD+0, "STOSB" },
{ 0x00FFFF, 0x00AB66, 2,00, NNN,NNN,NNN, C_CMD+0, "STOSW" },
{ 0x0000FF, 0x0000AB, 1,00, NNN,NNN,NNN, C_CMD+0, "STOSD" },
{ 0x00FFFF, 0x00A4F3, 1,00, NNN,NNN,NNN, C_REP+0, "REP MOVSB" },
{ 0xFFFFFF, 0xA5F366, 2,00, NNN,NNN,NNN, C_REP+0, "REP MOVSW" },
{ 0x00FFFF, 0x00A5F3, 1,00, NNN,NNN,NNN, C_REP+0, "REP MOVSD" },
{ 0x00FFFF, 0x00ACF3, 1,00, NNN,NNN,NNN, C_REP+0, "REP LODSB" },
{ 0xFFFFFF, 0xADF366, 2,00, NNN,NNN,NNN, C_REP+0, "REP LODSW" },
{ 0x00FFFF, 0x00ADF3, 1,00, NNN,NNN,NNN, C_REP+0, "REP LODSD" },
{ 0x00FFFF, 0x00AAF3, 1,00, NNN,NNN,NNN, C_REP+0, "REP STOSB" },
{ 0xFFFFFF, 0xABF366, 2,00, NNN,NNN,NNN, C_REP+0, "REP STOSW" },
{ 0x00FFFF, 0x00ABF3, 1,00, NNN,NNN,NNN, C_REP+0, "REP STOSD" },
{ 0x00FFFF, 0x00A6F3, 1,00, NNN,NNN,NNN, C_REP+0, "REPE CMPSB" },
{ 0xFFFFFF, 0xA7F366, 2,00, NNN,NNN,NNN, C_REP+0, "REPE CMPSW" },
{ 0x00FFFF, 0x00A7F3, 1,00, NNN,NNN,NNN, C_REP+0, "REPE CMPSD" },
{ 0x00FFFF, 0x00AEF3, 1,00, NNN,NNN,NNN, C_REP+0, "REPE SCASB" },
{ 0xFFFFFF, 0xAFF366, 2,00, NNN,NNN,NNN, C_REP+0, "REPE SCASW" },
{ 0x00FFFF, 0x00AFF3, 1,00, NNN,NNN,NNN, C_REP+0, "REPE SCASD" },
{ 0x00FFFF, 0x00A6F2, 1,00, NNN,NNN,NNN, C_REP+0, "REPNE CMPSB" },
{ 0xFFFFFF, 0xA7F266, 2,00, NNN,NNN,NNN, C_REP+0, "REPNE CMPSW" },
{ 0x00FFFF, 0x00A7F2, 1,00, NNN,NNN,NNN, C_REP+0, "REPNE CMPSD" },
{ 0x00FFFF, 0x00AEF2, 1,00, NNN,NNN,NNN, C_REP+0, "REPNE SCASB" },
{ 0xFFFFFF, 0xAFF266, 2,00, NNN,NNN,NNN, C_REP+0, "REPNE SCASW" },
{ 0x00FFFF, 0x00AFF2, 1,00, NNN,NNN,NNN, C_REP+0, "REPNE SCASD" },
{ 0x0000FF, 0x00006C, 1,00, NNN,NNN,NNN, C_CMD+C_RARE+0, "INSB" },
{ 0x00FFFF, 0x006D66, 2,00, NNN,NNN,NNN, C_CMD+C_RARE+0, "INSW" },
{ 0x0000FF, 0x00006D, 1,00, NNN,NNN,NNN, C_CMD+C_RARE+0, "INSD" },
{ 0x0000FF, 0x00006E, 1,00, NNN,NNN,NNN, C_CMD+C_RARE+0, "OUTSB" },
{ 0x00FFFF, 0x006F66, 2,00, NNN,NNN,NNN, C_CMD+C_RARE+0, "OUTSW" },
{ 0x0000FF, 0x00006F, 1,00, NNN,NNN,NNN, C_CMD+C_RARE+0, "OUTSD" },
{ 0x00FFFF, 0x006CF3, 1,00, NNN,NNN,NNN, C_REP+0, "REP INSB" },
{ 0xFFFFFF, 0x6DF366, 2,00, NNN,NNN,NNN, C_REP+0, "REP INSW" },
{ 0x00FFFF, 0x006DF3, 1,00, NNN,NNN,NNN, C_REP+0, "REP INSD" },
{ 0x00FFFF, 0x006EF3, 1,00, NNN,NNN,NNN, C_REP+0, "REP OUTSB" },
{ 0xFFFFFF, 0x6FF366, 2,00, NNN,NNN,NNN, C_REP+0, "REP OUTSW" },
{ 0x00FFFF, 0x006FF3, 1,00, NNN,NNN,NNN, C_REP+0, "REP OUTSD" },
{ 0x0000FF, 0x0000E1, 1,00, JOB,NNN,NNN, C_JMC+0, "$LOOP*Z" },
{ 0x0000FF, 0x0000E0, 1,00, JOB,NNN,NNN, C_JMC+0, "$LOOP*NZ" },
{ 0x0000FF, 0x00009B, 1,00, NNN,NNN,NNN, C_CMD+0, "FWAIT" },
{ 0x0000FF, 0x0000D7, 1,00, NNN,NNN,NNN, C_CMD+0, "XLATB" },
{ 0x00FFFF, 0x00C40F, 2,00, RMX,RR4,IM1, C_MMX+2, "PINSRW" },
{ 0x00FFFF, 0x0020CD, 2,00, VXD,NNN,NNN, C_CAL+C_RARE+0, "VxDCall" },
// Pseudocommands used by Assembler for masked search only.
{ 0x0000F0, 0x000070, 1,CC, JOB,NNN,NNN, C_JMC+0, "JCC" },
{ 0x00F0FF, 0x00800F, 2,CC, JOW,NNN,NNN, C_JMC+0, "JCC" },
{ 0x00F0FF, 0x00900F, 2,CC, MR1,NNN,NNN, C_CMD+1, "SETCC" },
{ 0x00F0FF, 0x00400F, 2,CC, REG,MRG,NNN, C_CMD+0, "CMOVCC" },
// End of command table.
{ 0x000000, 0x000000, 0,00, NNN,NNN,NNN, C_CMD+0, "" }
};
const t_cmddata vxdcmd = // Decoding of VxD calls (Win95/98)
{ 0x00FFFF, 0x0020CD, 2,00, VXD,NNN,NNN, C_CAL+C_RARE+0, "VxDCall" };
// Bit combinations that can be potentially dangerous when executed:
const t_cmddata dangerous[] = {
{ 0x00FFFF, 0x00DCF7, 0,0,0,0,0,C_DANGER95,
"Win95/98 may crash when NEG ESP is executed" },
{ 0x00FFFF, 0x00D4F7, 0,0,0,0,0,C_DANGER95,
"Win95/98 may crash when NOT ESP is executed" },
{ 0x00FFFF, 0x0020CD, 0,0,0,0,0,C_DANGER95,
"Win95/98 may crash when VxD call is executed in user mode" },
{ 0xF8FFFF, 0xC8C70F, 0,0,0,0,1,C_DANGERLOCK,
"LOCK CMPXCHG8B may crash some processors when executed" },
{ 0x000000, 0x000000, 0,0,0,0,0,0, "" }
};
// Decodes address into symb (nsymb bytes long, including the terminating zero
// character) and comments its possible meaning. Returns number of bytes in
// symb not including terminating zero.
int Decodeaddress(ulong addr,char *symb,int nsymb,char *comment) {
// Environment-specific routine! Do it yourself!
return 0;
};
// Decodes and prints 32-bit float f into string s (which must be at least 16
// bytes long). Returns resulting length of the string.
int Printfloat4(char *s,float f) {
void *F = &f;
int k;
if (*(ulong *)F==(ulong)0x7F800000L)
k=sprintf(s,"+INF 7F800000");
else if (*(ulong *)F==0xFF800000L)
k=sprintf(s,"-INF FF800000");
else if ((*(ulong *)F & 0xFF800000L)==0x7F800000L)
k=sprintf(s,"+NAN "LFMT08,*(ulong *)F);
else if ((*(ulong *)F & 0xFF800000L)==0xFF800000L)
k=sprintf(s,"-NAN "LFMT08,*(ulong *)F);
#if 0
else if (f==0.0) // By default, 0 is printed without
k=sprintf(s,"0.0"); // decimal point, which I don't want.
#endif
else
k=sprintf(s,"%#.7g",f);
return k;
};
// Decodes and prints 64-bit double d into string s (at least 25 bytes long).
// Returns resulting length of the string.
int Printfloat8(char *s,double d) {
int k;
void *D = &d;
ulong lod,hid;
lod=((ulong *)D)[0];
hid=((ulong *)D)[1];
if (lod==0 && hid==0x7F800000L)
k=sprintf(s,"+INF 7F800000 00000000");
else if (lod==0 && hid==0xFF800000L)
k=sprintf(s,"-INF FF800000 00000000");
else if ((hid & 0xFFF00000L)==0x7FF00000)
k=sprintf(s,"+NAN "LFMT08" "LFMT08,hid,lod);
else if ((hid & 0xFFF00000L)==0xFFF00000)
k=sprintf(s,"-NAN "LFMT08" "LFMT08,hid,lod);
else if (d==0.0) // Print 0 with decimal point
k=sprintf(s,"0.0");
else
k=sprintf(s,"%#.16lg",d);
return k;
};
// Decodes and prints 80-bit long double ext into string s (at least 32 bytes
// long). Procedure correctly displays all, even invalid, numbers without
// arithmetical exceptions. Returns resulting length of the string.
int Printfloat10(char *s,long double ext) {
int k;
char *e=(char *)&ext;
if (*(ulong *)e==0 && *(unsigned short *)(e+4)==0 && *(ulong *)(e+6)==0x7FFF8000L)
k=sprintf(s,"+INF 7FFF 80000000 00000000");
else if (*(ulong *)e==0 && *(unsigned short *)(e+4)==0 &&
*(ulong *)(e+6)==0xFFFF8000L)
k=sprintf(s,"-INF FFFF 80000000 00000000");
else if ((*(ulong *)(e+6) & 0x7FFF8000L)==0x7FFF8000L)
k=sprintf(s,"%cNAN %04X "LFMT08" "LFMT08,(e[9] & 0x80)==0?'+':'-',
(int)(*(unsigned short *)(e+8)),*(ulong *)(e+4),*(ulong *)e);
else if ((*(ulong *)(e+6) & 0x7FFF0000L)==0x7FFF0000L)
k=sprintf(s,"%c??? %04X "LFMT08" "LFMT08,(e[9] & 0x80)==0?'+':'-',
(int)(*(unsigned short *)(e+8)),*(ulong *)(e+4),*(ulong *)e);
else if ((*(ulong *)(e+6) & 0x7FFF0000L)!=0 &&
(*(ulong *)(e+6) & 0x00008000)==0)
k=sprintf(s,"%cUNORM %04X "LFMT08" "LFMT08,(e[9] & 0x80)==0?'+':'-',
(int)(*(unsigned short *)(e+8)),*(ulong *)(e+4),*(ulong *)e);
else if (*(ulong *)e==0 && *(unsigned short *)(e+4)==0 &&
*(ulong *)(e+6)==0x80000000L)
k=sprintf(s,"-0.0"); // Negative floating 0.0
else if (ext==0.0)
k=sprintf(s,"0.0"); // Print 0 with decimal point
#if __WINDOWS__
// Visual Studio only?
else if ((ext>=-1.e10 && ext<-1.0) || (ext>1.0 && ext<=1.e10))
k=sprintf(s,"%#.20g", (double) ext);
else if ((ext>=-1.0 && ext<=-1.e-5) || (ext>=1.e-5 && ext<=1.0))
k=sprintf(s,"%#.19f", (float)ext);
else
k=sprintf(s,"%#.19e", (double)ext);
#else
else if ((ext>=-1.e10 && ext<-1.0) || (ext>1.0 && ext<=1.e10))
k=sprintf(s,"%#.20Lg",ext);
else if ((ext>=-1.0 && ext<=-1.e-5) || (ext>=1.e-5 && ext<=1.0))
k=sprintf(s,"%#.19Lf",ext);
else
k=sprintf(s,"%#.19Le",ext);
#endif
return k;
};
// Decodes and prints 64-bit 3DNow! element f into string s (which must be at
// least 30 bytes long). Returns resulting length of the string.
int Print3dnow(char *s,char *f) {
int n;
n=Printfloat4(s,*(float *)(f+4));
n+=sprintf(s+n,", ");
n+=Printfloat4(s+n,*(float *)f);
return n;
};
// Function attempts to calculate address of assembler instruction which is n
// lines back in the listing. Maximal stepback is limited to 127. In general,
// this is rather non-trivial task. Proposed solution may cause problems which
// however are not critical here.
ulong Disassembleback(unsigned char *block,ulong base,ulong size,ulong ip,int n) {
int i;
ulong abuf[131],addr,back,cmdsize;
unsigned char *pdata;
t_disasm da;
abuf[0] = 0;
if (block==NULL) return 0; // Error, no code!
if (n<0) n=0; else if (n>127) n=127; // Try to correct obvious errors
if (ip>base+size) ip=base+size;
if (n==0) return ip; // Obvious answers
if (ip<=base+n) return base;
back=MAXCMDSIZE*(n+3); // Command length limited to MAXCMDSIZE
if (ip<base+back) back=ip-base;
addr=ip-back;
pdata=block+(addr-base);
for (i=0; addr<ip; i++) {
abuf[i%128]=addr;
cmdsize=Disasm(pdata,back,addr,&da,DISASM_SIZE);
pdata+=cmdsize;
addr+=cmdsize;
back-=cmdsize; };
if (i<n) return abuf[0];
else return abuf[(i-n+128)%128];
};
// Function attempts to calculate address of assembler instruction which is n
// lines forward in the listing.
ulong Disassembleforward(unsigned char *block,ulong base,ulong size,ulong ip,int n) {
int i;
ulong cmdsize;
unsigned char *pdata;
t_disasm da;
if (block==NULL) return 0; // Error, no code!
if (ip<base) ip=base; // Try to correct obvious errors
if (ip>base+size) ip=base+size;
if (n<=0) return ip;
pdata=block+(ip-base);
size-=(ip-base);
for (i=0; i<n && size>0; i++) {
cmdsize=Disasm(pdata,size,ip,&da,DISASM_SIZE);
pdata+=cmdsize;
ip+=cmdsize;
size-=cmdsize; };
return ip;
};
// Service function, checks whether command at offset addr in data is a valid
// filling command (usually some kind of NOP) used to align code to a specified
// (align=power of 2, 0 means no alignment) border. Returns length of filling
// command in bytes or 0 if command is not a recognized filling.
int Isfilling(ulong addr,unsigned char *data,ulong size,ulong align) {
if (data==NULL) return 0; // Invalid parameters
// Convert power of 2 to bitmask.
align--;
// Many compilers and assemblers use NOP or INT3 as filling:
if (addr<size && (data[addr]==NOP || data[addr]==INT3) &&
(addr & align)!=0)
return 1;
// Borland compilers use XCHG EBX,EBX (87,DB) to fill holes. For the sake of
// completeness, allow any XCHG or MOV of register with self.
if (addr+1<size &&
((data[addr] & 0xFE)==0x86 || (data[addr] & 0xFC)==0x88) &&
(data[addr+1] & 0xC0)==0xC0 &&
(((data[addr+1]>>3)^data[addr+1]) & 0x07)==0 &&
(addr & align)!=0x0F && (addr & align)!=0x00)
return 2;
// Some other programs use LEA EAX,[EAX] (8D,40,00). For completeness, allow
// any register except ESP (here address is constructed differently):
if (addr+2<size &&
data[addr]==0x8D && (data[addr+1] & 0xC0)==0x40 && data[addr+2]==0x00 &&
(data[addr+1] & 0x07)!=GREG_ESP &&
(((data[addr+1]>>3)^data[addr+1]) & 0x07)==0)
return 3;
// WATCOM compilers use LEA EAX,[EAX] with SIB and 8-bit zero (8D,44,20,00)
// and without SIB but with 32-bit immediate zero (8D,80,00,00,00,00) and
// alike:
if (addr+3<size &&
data[addr]==0x8D && (data[addr+1] & 0xC0)==0x40 && data[addr+3]==0x00 &&
(((data[addr+1]>>3)^data[addr+2]) & 0x07)==0)
return 4;
if (addr+5<size && data[addr]==0x8D &&
(data[addr+1] & 0xC0)==0x80 && *(ulong *)(data+addr+2)==0 &&
(data[addr+1] & 0x07)!=GREG_ESP &&
(((data[addr+1]>>3)^data[addr+1]) & 0x07)==0)
return 6;
// Unable to recognize this code as a valid filling.
return 0;
};
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+343
View File
@@ -0,0 +1,343 @@
// Free Disassembler and Assembler -- Header file
//
// Copyright (C) 2001 Oleh Yuschuk
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#ifndef _INCLUDE_OLLY_
#define _INCLUDE_OLLY_
#define Disasm Disasm_olly
//#define strupr str
//#define strlwr //
#define pow10l //
#define strnicmp strncmp
#define memicmp memcmp
#define Sleep sleep
// If you prefere Borland, this will force necessary setting (but, as a side
// effect, may cause plenty of warnings if other include files will be compiled
// with different options):
#ifdef __BORLANDC__
#pragma option -K // Unsigned char
#endif
//typedef unsigned char char
#if 0
#if (char)0xFF!=255
#error Please set default char type to unsigned
#endif
#endif
#define NEGLIMIT (-16384) // Limit to display constans as signed
#define PSEUDOOP 128 // Base for pseudooperands
#define TEXTLEN 256 // Maximal length of text string
#undef WS
#undef SS
// Special command features.
#define WW 0x01 // Bit W (size of operand)
#define SS 0x02 // Bit S (sign extension of immediate)
#define WS 0x03 // Bits W and S
#define W3 0x08 // Bit W at position 3
#define CC 0x10 // Conditional jump
#define FF 0x20 // Forced 16-bit size
#define LL 0x40 // Conditional loop
#define PR 0x80 // Protected command
#define WP 0x81 // I/O command with bit W
// All possible types of operands in 80x86. A bit more than you expected, he?
#define NNN 0 // No operand
#define REG 1 // Integer register in Reg field
#define RCM 2 // Integer register in command byte
#define RG4 3 // Integer 4-byte register in Reg field
#define RAC 4 // Accumulator (AL/AX/EAX, implicit)
#define RAX 5 // AX (2-byte, implicit)
#define RDX 6 // DX (16-bit implicit port address)
#define RCL 7 // Implicit CL register (for shifts)
#define RS0 8 // Top of FPU stack (ST(0), implicit)
#define RST 9 // FPU register (ST(i)) in command byte
#define RMX 10 // MMX register MMx
#define R3D 11 // 3DNow! register MMx
#define MRG 12 // Memory/register in ModRM byte
#define MR1 13 // 1-byte memory/register in ModRM byte
#define MR2 14 // 2-byte memory/register in ModRM byte
#define MR4 15 // 4-byte memory/register in ModRM byte
#define RR4 16 // 4-byte memory/register (register only)
#define MR8 17 // 8-byte memory/MMX register in ModRM
#define RR8 18 // 8-byte MMX register only in ModRM
#define MRD 19 // 8-byte memory/3DNow! register in ModRM
#define RRD 20 // 8-byte memory/3DNow! (register only)
#define MRJ 21 // Memory/reg in ModRM as JUMP target
#define MMA 22 // Memory address in ModRM byte for LEA
#define MML 23 // Memory in ModRM byte (for LES)
#define MMS 24 // Memory in ModRM byte (as SEG:OFFS)
#define MM6 25 // Memory in ModRm (6-byte descriptor)
#define MMB 26 // Two adjacent memory locations (BOUND)
#define MD2 27 // Memory in ModRM (16-bit integer)
#define MB2 28 // Memory in ModRM (16-bit binary)
#define MD4 29 // Memory in ModRM byte (32-bit integer)
#define MD8 30 // Memory in ModRM byte (64-bit integer)
#define MDA 31 // Memory in ModRM byte (80-bit BCD)
#define MF4 32 // Memory in ModRM byte (32-bit float)
#define MF8 33 // Memory in ModRM byte (64-bit float)
#define MFA 34 // Memory in ModRM byte (80-bit float)
#define MFE 35 // Memory in ModRM byte (FPU environment)
#define MFS 36 // Memory in ModRM byte (FPU state)
#define MFX 37 // Memory in ModRM byte (ext. FPU state)
#define MSO 38 // Source in string op's ([ESI])
#define MDE 39 // Destination in string op's ([EDI])
#define MXL 40 // XLAT operand ([EBX+AL])
#define IMM 41 // Immediate data (8 or 16/32)
#define IMU 42 // Immediate unsigned data (8 or 16/32)
#define VXD 43 // VxD service
#define IMX 44 // Immediate sign-extendable byte
#define C01 45 // Implicit constant 1 (for shifts)
#define IMS 46 // Immediate byte (for shifts)
#define IM1 47 // Immediate byte
#define IM2 48 // Immediate word (ENTER/RET)
#define IMA 49 // Immediate absolute near data address
#define JOB 50 // Immediate byte offset (for jumps)
#define JOW 51 // Immediate full offset (for jumps)
#define JMF 52 // Immediate absolute far jump/call addr
#define SGM 53 // Segment register in ModRM byte
#define SCM 54 // Segment register in command byte
#define CRX 55 // Control register CRx
#define DRX 56 // Debug register DRx
// Pseudooperands (implicit operands, never appear in assembler commands). Must
// have index equal to or exceeding PSEUDOOP.
#define PRN (PSEUDOOP+0) // Near return address
#define PRF (PSEUDOOP+1) // Far return address
#define PAC (PSEUDOOP+2) // Accumulator (AL/AX/EAX)
#define PAH (PSEUDOOP+3) // AH (in LAHF/SAHF commands)
#define PFL (PSEUDOOP+4) // Lower byte of flags (in LAHF/SAHF)
#define PS0 (PSEUDOOP+5) // Top of FPU stack (ST(0))
#define PS1 (PSEUDOOP+6) // ST(1)
#define PCX (PSEUDOOP+7) // CX/ECX
#define PDI (PSEUDOOP+8) // EDI (in MMX extensions)
// Errors detected during command disassembling.
#define DAE_NOERR 0 // No error
#define DAE_BADCMD 1 // Unrecognized command
#define DAE_CROSS 2 // Command crosses end of memory block
#define DAE_BADSEG 3 // Undefined segment register
#define DAE_MEMORY 4 // Register where only memory allowed
#define DAE_REGISTER 5 // Memory where only register allowed
#define DAE_INTERN 6 // Internal error
#ifndef uchar
#define uchar unsigned char
#endif
#ifndef uint
#define uint unsigned int
#endif
//XXX Fix 64b issues
#define ulong unsigned int
#define slong int
#define LFMT "%d"
#define LFMT08 "0x%08x"
//typedef unsigned char uchar; // Unsigned character (byte)
//typedef unsigned short ushort; // Unsigned short
//typedef unsigned int uint; // Unsigned integer
//typedef unsigned long ulong; // Unsigned long
typedef struct t_addrdec {
int defseg;
char *descr;
} t_addrdec;
typedef struct t_cmddata {
ulong mask; // Mask for first 4 bytes of the command
ulong code; // Compare masked bytes with this
unsigned len; // Length of the main command code
unsigned char bits; // Special bits within the command
unsigned char arg1,arg2,arg3; // Types of possible arguments
unsigned type; // C_xxx + additional information
char *name; // Symbolic name for this command
} t_cmddata;
// Initialized constant data structures used by all programs from assembler
// package. Contain names of register, register combinations or commands and
// their properties.
extern const char *regname[3][9];
extern const char *segname[8];
extern const char *sizename[11];
extern const t_addrdec addr16[8];
extern const t_addrdec addr32[8];
extern const char *fpuname[9];
extern const char *mmxname[9];
extern const char *crname[9];
extern const char *drname[9];
extern const char *condition[16];
extern const t_cmddata cmddata[];
extern const t_cmddata vxdcmd;
extern const t_cmddata dangerous[];
////////////////////////////////////////////////////////////////////////////////
//////////////////// ASSEMBLER, DISASSEMBLER AND EXPRESSIONS ///////////////////
#define MAXCMDSIZE 16 // Maximal length of 80x86 command
#define MAXCALSIZE 8 // Max length of CALL without prefixes
#define NMODELS 8 // Number of assembler search models
#define INT3 0xCC // Code of 1-byte breakpoint
#define NOP 0x90 // Code of 1-byte NOP command
#define TRAPFLAG 0x00000100 // Trap flag in CPU flag register
#define GREG_EAX 0 // Indexes of general-purpose registers
#define GREG_ECX 1 // in t_reg.
#define GREG_EDX 2
#define GREG_EBX 3
#define GREG_ESP 4
#define GREG_EBP 5
#define GREG_ESI 6
#define GREG_EDI 7
#define SEG_UNDEF -1
#define SEG_ES 0 // Indexes of segment/selector registers
#define SEG_CS 1
#define SEG_SS 2
#define SEG_DS 3
#define SEG_FS 4
#define SEG_GS 5
#define C_TYPEMASK 0xF0 // Mask for command type
#define C_CMD 0x00 // Ordinary instruction
#define C_PSH 0x10 // 1-word PUSH instruction
#define C_POP 0x20 // 1-word POP instruction
#define C_MMX 0x30 // MMX instruction
#define C_FLT 0x40 // FPU instruction
#define C_JMP 0x50 // JUMP instruction
#define C_JMC 0x60 // Conditional JUMP instruction
#define C_CAL 0x70 // CALL instruction
#define C_RET 0x80 // RET instruction
#define C_FLG 0x90 // Changes system flags
#define C_RTF 0xA0 // C_JMP and C_FLG simultaneously
#define C_REP 0xB0 // Instruction with REPxx prefix
#define C_PRI 0xC0 // Privileged instruction
#define C_DAT 0xD0 // Data (address) doubleword
#define C_NOW 0xE0 // 3DNow! instruction
#define C_BAD 0xF0 // Unrecognized command
#define C_RARE 0x08 // Rare command, seldom used in programs
#define C_SIZEMASK 0x07 // MMX data size or special flag
#define C_EXPL 0x01 // (non-MMX) Specify explicit memory size
#define C_DANGER95 0x01 // Command is dangerous under Win95/98
#define C_DANGER 0x03 // Command is dangerous everywhere
#define C_DANGERLOCK 0x07 // Dangerous with LOCK prefix
#define DEC_TYPEMASK 0x1F // Type of memory byte
#define DEC_UNKNOWN 0x00 // Unknown type
#define DEC_BYTE 0x01 // Accessed as byte
#define DEC_WORD 0x02 // Accessed as short
#define DEC_NEXTDATA 0x03 // Subsequent byte of code or data
#define DEC_DWORD 0x04 // Accessed as long
#define DEC_FLOAT4 0x05 // Accessed as float
#define DEC_FWORD 0x06 // Accessed as descriptor/long pointer
#define DEC_FLOAT8 0x07 // Accessed as double
#define DEC_QWORD 0x08 // Accessed as 8-byte integer
#define DEC_FLOAT10 0x09 // Accessed as long double
#define DEC_TBYTE 0x0A // Accessed as 10-byte integer
#define DEC_STRING 0x0B // Zero-terminated ASCII string
#define DEC_UNICODE 0x0C // Zero-terminated UNICODE string
#define DEC_3DNOW 0x0D // Accessed as 3Dnow operand
#define DEC_BYTESW 0x11 // Accessed as byte index to switch
#define DEC_NEXTCODE 0x13 // Subsequent byte of command
#define DEC_COMMAND 0x1D // First byte of command
#define DEC_JMPDEST 0x1E // Jump destination
#define DEC_CALLDEST 0x1F // Call (and maybe jump) destination
#define DEC_PROCMASK 0x60 // Procedure analysis
#define DEC_PROC 0x20 // Start of procedure
#define DEC_PBODY 0x40 // Body of procedure
#define DEC_PEND 0x60 // End of procedure
#define DEC_CHECKED 0x80 // Byte was analysed
#define DECR_TYPEMASK 0x3F // Type of register or memory
#define DECR_BYTE 0x21 // Byte register
#define DECR_WORD 0x22 // Short integer register
#define DECR_DWORD 0x24 // Long integer register
#define DECR_QWORD 0x28 // MMX register
#define DECR_FLOAT10 0x29 // Floating-point register
#define DECR_SEG 0x2A // Segment register
#define DECR_3DNOW 0x2D // 3Dnow! register
#define DECR_ISREG 0x20 // Mask to check that operand is register
#define DISASM_SIZE 0 // Determine command size only
#define DISASM_DATA 1 // Determine size and analysis data
#define DISASM_FILE 3 // Disassembly, no symbols
#define DISASM_CODE 4 // Full disassembly
// Warnings issued by Disasm():
#define DAW_FARADDR 0x0001 // Command is a far jump, call or return
#define DAW_SEGMENT 0x0002 // Command loads segment register
#define DAW_PRIV 0x0004 // Privileged command
#define DAW_IO 0x0008 // I/O command
#define DAW_SHIFT 0x0010 // Shift constant out of range 1..31
#define DAW_PREFIX 0x0020 // Superfluous prefix
#define DAW_LOCK 0x0040 // Command has LOCK prefix
#define DAW_STACK 0x0080 // Unaligned stack operation
#define DAW_DANGER95 0x1000 // May mess up Win95 if executed
#define DAW_DANGEROUS 0x3000 // May mess up any OS if executed
typedef struct t_disasm { // Results of disassembling
ulong ip; // Instrucion pointer
char dump[TEXTLEN]; // Hexadecimal dump of the command
char result[TEXTLEN]; // Disassembled command
char comment[TEXTLEN]; // Brief comment
int cmdtype; // One of C_xxx
int memtype; // Type of addressed variable in memory
int nprefix; // Number of prefixes
int indexed; // Address contains register(s)
ulong jmpconst; // Constant jump address
ulong jmptable; // Possible address of switch table
ulong adrconst; // Constant part of address
ulong immconst; // Immediate constant
int zeroconst; // Whether contains zero constant
int fixupoffset; // Possible offset of 32-bit fixups
int fixupsize; // Possible total size of fixups or 0
int error; // Error while disassembling command
int warnings; // Combination of DAW_xxx
} t_disasm;
typedef struct t_asmmodel { // Model to search for assembler command
char code[MAXCMDSIZE]; // Binary code
char mask[MAXCMDSIZE]; // Mask for binary code (0: bit ignored)
int length; // Length of code, bytes (0: empty)
int jmpsize; // Offset size if relative jump
int jmpoffset; // Offset relative to IP
int jmppos; // Position of jump offset in command
} t_asmmodel;
int Assemble(char *cmd,ulong ip,t_asmmodel *model,int attempt,
int constsize,char *errtext);
int Checkcondition(int code,ulong flags);
int Decodeaddress(ulong addr,char *symb,int nsymb,char *comment);
ulong Disasm(const unsigned char *src,ulong srcsize,ulong srcip,
t_disasm *disasm,int disasmmode);
ulong Disassembleback(unsigned char *block,ulong base,ulong size,ulong ip,int n);
ulong Disassembleforward(unsigned char *block,ulong base,ulong size,ulong ip,int n);
int Isfilling(ulong addr,unsigned char *data,ulong size,ulong align);
int Print3dnow(char *s,char *f);
int Printfloat10(char *s,long double ext);
int Printfloat4(char *s,float f);
int Printfloat8(char *s,double d);
char * strupr (char *a);
char * strlwr (char *a);
#endif
+23
View File
@@ -0,0 +1,23 @@
include ../../global.mk
include $(TOP)/libr/config.mk
PYTHON=python2
SRC=$(shell ls *.c)
OUT=$(subst .c,.o,$(SRC))
CFLAGS+=-DHAVE_STRING_H=1
all: $(OUT)
$(OUT):
$(CC) $(CFLAGS) $(LDFLAGS) -c `echo $@|sed -e 's,\.o,\.c,g'` -o $@
sync:
rm -rf tmp
mkdir -p tmp
git clone --depth 1 git://github.com/radare/udis86.git
cd udis86/libudis86 ; ${PYTHON} ../scripts/ud_itab.py ../docs/x86/optable.xml .
cp -f udis86/libudis86/*.[ch] .
rm -rf udis86
clean mrproper:
rm -f *.o *.d
File diff suppressed because it is too large. Load diff
+202
View File
@@ -0,0 +1,202 @@
/* udis86 - libudis86/decode.h
*
* Copyright (c) 2002-2009 Vivek Thampi
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef UD_DECODE_H
#define UD_DECODE_H
#include "types.h"
#include "udint.h"
#include "itab.h"
#define MAX_INSN_LENGTH 15
/* itab prefix bits */
#define P_none ( 0 )
#define P_inv64 ( 1 << 0 )
#define P_INV64(n) ( ( n >> 0 ) & 1 )
#define P_def64 ( 1 << 1 )
#define P_DEF64(n) ( ( n >> 1 ) & 1 )
#define P_oso ( 1 << 2 )
#define P_OSO(n) ( ( n >> 2 ) & 1 )
#define P_aso ( 1 << 3 )
#define P_ASO(n) ( ( n >> 3 ) & 1 )
#define P_rexb ( 1 << 4 )
#define P_REXB(n) ( ( n >> 4 ) & 1 )
#define P_rexw ( 1 << 5 )
#define P_REXW(n) ( ( n >> 5 ) & 1 )
#define P_rexr ( 1 << 6 )
#define P_REXR(n) ( ( n >> 6 ) & 1 )
#define P_rexx ( 1 << 7 )
#define P_REXX(n) ( ( n >> 7 ) & 1 )
#define P_seg ( 1 << 8 )
#define P_SEG(n) ( ( n >> 8 ) & 1 )
#define P_vexl ( 1 << 9 )
#define P_VEXL(n) ( ( n >> 9 ) & 1 )
#define P_vexw ( 1 << 10 )
#define P_VEXW(n) ( ( n >> 10 ) & 1 )
#define P_str ( 1 << 11 )
#define P_STR(n) ( ( n >> 11 ) & 1 )
#define P_strz ( 1 << 12 )
#define P_STR_ZF(n) ( ( n >> 12 ) & 1 )
/* operand type constants -- order is important! */
enum ud_operand_code {
OP_NONE,
OP_A, OP_E, OP_M, OP_G,
OP_I, OP_F,
OP_R0, OP_R1, OP_R2, OP_R3,
OP_R4, OP_R5, OP_R6, OP_R7,
OP_AL, OP_CL, OP_DL,
OP_AX, OP_CX, OP_DX,
OP_eAX, OP_eCX, OP_eDX,
OP_rAX, OP_rCX, OP_rDX,
OP_ES, OP_CS, OP_SS, OP_DS,
OP_FS, OP_GS,
OP_ST0, OP_ST1, OP_ST2, OP_ST3,
OP_ST4, OP_ST5, OP_ST6, OP_ST7,
OP_J, OP_S, OP_O,
OP_I1, OP_I3, OP_sI,
OP_V, OP_W, OP_Q, OP_P,
OP_U, OP_N, OP_MU, OP_H,
OP_L,
OP_R, OP_C, OP_D,
OP_MR
} UD_ATTR_PACKED;
/*
* Operand size constants
*
* Symbolic constants for various operand sizes. Some of these constants
* are given a value equal to the width of the data (SZ_B == 8), such
* that they maybe used interchangeably in the internals. Modifying them
* will most certainly break things!
*/
typedef uint16_t ud_operand_size_t;
#define SZ_NA 0
#define SZ_Z 1
#define SZ_V 2
#define SZ_Y 3
#define SZ_X 4
#define SZ_RDQ 7
#define SZ_B 8
#define SZ_W 16
#define SZ_D 32
#define SZ_Q 64
#define SZ_T 80
#define SZ_O 12
#define SZ_DQ 128 /* double quad */
#define SZ_QQ 256 /* quad quad */
/*
* Complex size types; that encode sizes for operands of type MR (memory or
* register); for internal use only. Id space above 256.
*/
#define SZ_BD ((SZ_B << 8) | SZ_D)
#define SZ_BV ((SZ_B << 8) | SZ_V)
#define SZ_WD ((SZ_W << 8) | SZ_D)
#define SZ_WV ((SZ_W << 8) | SZ_V)
#define SZ_WY ((SZ_W << 8) | SZ_Y)
#define SZ_DY ((SZ_D << 8) | SZ_Y)
#define SZ_WO ((SZ_W << 8) | SZ_O)
#define SZ_DO ((SZ_D << 8) | SZ_O)
#define SZ_QO ((SZ_Q << 8) | SZ_O)
/* resolve complex size type.
*/
static UD_INLINE ud_operand_size_t
Mx_mem_size(ud_operand_size_t size)
{
return (size >> 8) & 0xff;
}
static UD_INLINE ud_operand_size_t
Mx_reg_size(ud_operand_size_t size)
{
return size & 0xff;
}
/* A single operand of an entry in the instruction table.
* (internal use only)
*/
struct ud_itab_entry_operand
{
enum ud_operand_code type;
ud_operand_size_t size;
};
/* A single entry in an instruction table.
*(internal use only)
*/
struct ud_itab_entry
{
enum ud_mnemonic_code mnemonic;
struct ud_itab_entry_operand operand1;
struct ud_itab_entry_operand operand2;
struct ud_itab_entry_operand operand3;
struct ud_itab_entry_operand operand4;
uint8_t operand1_access;
uint8_t operand2_access;
uint32_t prefix;
struct ud_eflags eflags;
enum ud_type implicit_register_uses[32];
enum ud_type implicit_register_defs[32];
};
struct ud_lookup_table_list_entry {
const uint16_t *table;
enum ud_table_type type;
const char *meta;
};
extern struct ud_itab_entry ud_itab[];
extern struct ud_lookup_table_list_entry ud_lookup_table_list[];
#endif /* UD_DECODE_H */
/* vim:cindent
* vim:expandtab
* vim:ts=4
* vim:sw=4
*/
+34
View File
@@ -0,0 +1,34 @@
#ifndef _UDIS86_ESIL_H
#define _UDIS86_ESIL_H
/* This may be useful for other architectures */
#define esilprintf(op, fmt, arg...) snprintf (op->esil, sizeof (op->esil) - 3, fmt, ##arg)
#define UDIS86_ESIL_ARGUMENTS const UDis86OPInfo *info, RAnalOp *op, const char *dst, const char *src, const char *src2
typedef struct udis86_op_info {
ut64 n;
int bits;
ut64 bitmask;
int regsz;
int oplen;
const char *pc;
const char *sp;
const char *bp;
} UDis86OPInfo;
typedef struct udis86_esil_t {
int argc;
void (*callback) (UDIS86_ESIL_ARGUMENTS);
} UDis86Esil;
#define _JOIN(a1, a2) a1 ## a2
#define JOIN(a1, a2) _JOIN (a1, a2)
#define UDIS86_ESIL_HANDLER(name) JOIN (JOIN (__x86_, name), _to_esil)
#define UDIS86_ESIL_PROTO(name) void UDIS86_ESIL_HANDLER (name) (UDIS86_ESIL_ARGUMENTS)
#define UDIS86_ESIL(name, fmt, arg...) UDIS86_ESIL_PROTO (name) { esilprintf (op, fmt, ##arg); }
UDis86Esil *udis86_esil_get_handler (enum ud_mnemonic_code);
#endif /* _UDIS86_ESIL_H */
+119
View File
@@ -0,0 +1,119 @@
/* udis86 - libudis86/extern.h
*
* Copyright (c) 2002-2009, 2013 Vivek Thampi
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef UD_EXTERN_H
#define UD_EXTERN_H
#ifdef __cplusplus
extern "C" {
#endif
#include "types.h"
#if defined(_MSC_VER) && defined(_USRDLL)
# ifdef LIBUDIS86_EXPORTS
# define LIBUDIS86_DLLEXTERN __declspec(dllexport)
# else
# define LIBUDIS86_DLLEXTERN __declspec(dllimport)
# endif
#else
# define LIBUDIS86_DLLEXTERN
#endif
/* ============================= PUBLIC API ================================= */
extern LIBUDIS86_DLLEXTERN void ud_init(struct ud*);
extern LIBUDIS86_DLLEXTERN void ud_set_mode(struct ud*, uint8_t);
extern LIBUDIS86_DLLEXTERN void ud_set_pc(struct ud*, uint64_t);
extern LIBUDIS86_DLLEXTERN void ud_set_input_hook(struct ud*, int (*)(struct ud*));
extern LIBUDIS86_DLLEXTERN void ud_set_input_buffer(struct ud*, const uint8_t*, size_t);
#ifndef __UD_STANDALONE__
extern LIBUDIS86_DLLEXTERN void ud_set_input_file(struct ud*, FILE*);
#endif /* __UD_STANDALONE__ */
extern LIBUDIS86_DLLEXTERN void ud_set_vendor(struct ud*, unsigned);
extern LIBUDIS86_DLLEXTERN void ud_set_syntax(struct ud*, void (*)(struct ud*));
extern LIBUDIS86_DLLEXTERN void ud_input_skip(struct ud*, size_t);
extern LIBUDIS86_DLLEXTERN int ud_input_end(const struct ud*);
extern LIBUDIS86_DLLEXTERN unsigned int ud_decode(struct ud*);
extern LIBUDIS86_DLLEXTERN unsigned int ud_disassemble(struct ud*);
extern LIBUDIS86_DLLEXTERN void ud_translate_intel(struct ud*);
extern LIBUDIS86_DLLEXTERN void ud_translate_att(struct ud*);
extern LIBUDIS86_DLLEXTERN const char* ud_insn_asm(const struct ud* u);
extern LIBUDIS86_DLLEXTERN const uint8_t* ud_insn_ptr(const struct ud* u);
extern LIBUDIS86_DLLEXTERN uint64_t ud_insn_off(const struct ud*);
extern LIBUDIS86_DLLEXTERN const char* ud_insn_hex(struct ud*);
extern LIBUDIS86_DLLEXTERN unsigned int ud_insn_len(const struct ud* u);
extern LIBUDIS86_DLLEXTERN const struct ud_operand* ud_insn_opr(const struct ud *u, unsigned int n);
extern LIBUDIS86_DLLEXTERN int ud_opr_is_sreg(const struct ud_operand *opr);
extern LIBUDIS86_DLLEXTERN int ud_opr_is_gpr(const struct ud_operand *opr);
extern LIBUDIS86_DLLEXTERN enum ud_mnemonic_code ud_insn_mnemonic(const struct ud *u);
extern LIBUDIS86_DLLEXTERN const char* ud_lookup_mnemonic(enum ud_mnemonic_code c);
extern LIBUDIS86_DLLEXTERN const struct ud_eflags* ud_lookup_eflags(struct ud *u);
extern LIBUDIS86_DLLEXTERN const enum ud_type* ud_lookup_implicit_reg_used_list(struct ud *u);
extern LIBUDIS86_DLLEXTERN const enum ud_type* ud_lookup_implicit_reg_defined_list(struct ud *u);
extern LIBUDIS86_DLLEXTERN void ud_set_user_opaque_data(struct ud*, void*);
extern LIBUDIS86_DLLEXTERN void* ud_get_user_opaque_data(const struct ud*);
extern LIBUDIS86_DLLEXTERN void ud_set_asm_buffer(struct ud *u, char *buf, size_t size);
extern LIBUDIS86_DLLEXTERN void ud_set_sym_resolver(struct ud *u,
const char* (*resolver)(struct ud*,
uint64_t addr,
int64_t *offset));
/* ========================================================================== */
#ifdef __cplusplus
}
#endif
#endif /* UD_EXTERN_H */
+116
View File
@@ -0,0 +1,116 @@
/* udis86 - libudis86/input.h
*
* Copyright (c) 2002-2009 Vivek Thampi
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef UD_INPUT_H
#define UD_INPUT_H
#include "types.h"
#include "udint.h"
uint8_t ud_inp_next(struct ud* u);
/*
* inp_start
* Should be called before each de-code operation.
*/
static inline void
inp_start(struct ud *u)
{
u->inp_ctr = 0;
}
/* inp_reset
* Resets the current pointer to its position before the current
* instruction disassembly was started.
*/
static inline void
inp_reset(struct ud *u)
{
u->inp_curr -= u->inp_ctr;
u->inp_ctr = 0;
}
/* inp_sess
* Returns the pointer to current session.
*/
static inline uint8_t*
inp_sess(struct ud *u)
{
return u->inp_sess;
}
/*
* inp_curr
* Returns the current input byte.
*/
static inline uint8_t
inp_curr(const struct ud *u)
{
return u->inp_cache[u->inp_curr];
}
/*
* inp_back
* Move back a single byte in the stream.
*/
static inline void
inp_back(struct ud* u)
{
if (u->inp_ctr > 0) {
--u->inp_curr;
--u->inp_ctr;
}
}
/*
* inp_peek
* Peek next byte in input.
*/
static inline uint8_t
inp_peek(struct ud* u)
{
uint8_t r = ud_inp_next(u);
if (!u->error) {
inp_back(u); /* Don't backup if there was an error */
}
return r;
}
/*
* inp_len
* Returns the number of bytes input in the current
* session.
*/
static inline size_t
inp_len(const struct ud *u)
{
return u->inp_ctr;
}
#endif /* UD_INPUT_H */
/*
vim: set ts=2 sw=2 expandtab
*/
File diff suppressed because it is too large. Load diff
+939
View File
@@ -0,0 +1,939 @@
#ifndef UD_ITAB_H
#define UD_ITAB_H
/* itab.h -- generated by udis86:scripts/ud_itab.py, do no edit */
/* ud_table_type -- lookup table types (see decode.c) */
enum ud_table_type {
UD_TAB__OPC_VEX,
UD_TAB__OPC_TABLE,
UD_TAB__OPC_X87,
UD_TAB__OPC_MOD,
UD_TAB__OPC_RM,
UD_TAB__OPC_OSIZE,
UD_TAB__OPC_MODE,
UD_TAB__OPC_VEX_L,
UD_TAB__OPC_3DNOW,
UD_TAB__OPC_REG,
UD_TAB__OPC_ASIZE,
UD_TAB__OPC_VEX_W,
UD_TAB__OPC_SSE,
UD_TAB__OPC_VENDOR
};
/* ud_mnemonic -- mnemonic constants */
enum ud_mnemonic_code {
UD_Iaaa,
UD_Iaad,
UD_Iaam,
UD_Iaas,
UD_Iadc,
UD_Iadd,
UD_Iaddpd,
UD_Iaddps,
UD_Iaddsd,
UD_Iaddss,
UD_Iaddsubpd,
UD_Iaddsubps,
UD_Iaesdec,
UD_Iaesdeclast,
UD_Iaesenc,
UD_Iaesenclast,
UD_Iaesimc,
UD_Iaeskeygenassist,
UD_Iand,
UD_Iandnpd,
UD_Iandnps,
UD_Iandpd,
UD_Iandps,
UD_Iarpl,
UD_Iblendpd,
UD_Iblendps,
UD_Iblendvpd,
UD_Iblendvps,
UD_Ibound,
UD_Ibsf,
UD_Ibsr,
UD_Ibswap,
UD_Ibt,
UD_Ibtc,
UD_Ibtr,
UD_Ibts,
UD_Icall,
UD_Icbw,
UD_Icdq,
UD_Icdqe,
UD_Iclc,
UD_Icld,
UD_Iclflush,
UD_Iclgi,
UD_Icli,
UD_Iclts,
UD_Icmc,
UD_Icmova,
UD_Icmovae,
UD_Icmovb,
UD_Icmovbe,
UD_Icmove,
UD_Icmovg,
UD_Icmovge,
UD_Icmovl,
UD_Icmovle,
UD_Icmovne,
UD_Icmovno,
UD_Icmovnp,
UD_Icmovns,
UD_Icmovo,
UD_Icmovp,
UD_Icmovs,
UD_Icmp,
UD_Icmppd,
UD_Icmpps,
UD_Icmpsb,
UD_Icmpsd,
UD_Icmpsq,
UD_Icmpss,
UD_Icmpsw,
UD_Icmpxchg,
UD_Icmpxchg16b,
UD_Icmpxchg8b,
UD_Icomisd,
UD_Icomiss,
UD_Icpuid,
UD_Icqo,
UD_Icrc32,
UD_Icvtdq2pd,
UD_Icvtdq2ps,
UD_Icvtpd2dq,
UD_Icvtpd2pi,
UD_Icvtpd2ps,
UD_Icvtpi2pd,
UD_Icvtpi2ps,
UD_Icvtps2dq,
UD_Icvtps2pd,
UD_Icvtps2pi,
UD_Icvtsd2si,
UD_Icvtsd2ss,
UD_Icvtsi2sd,
UD_Icvtsi2ss,
UD_Icvtss2sd,
UD_Icvtss2si,
UD_Icvttpd2dq,
UD_Icvttpd2pi,
UD_Icvttps2dq,
UD_Icvttps2pi,
UD_Icvttsd2si,
UD_Icvttss2si,
UD_Icwd,
UD_Icwde,
UD_Idaa,
UD_Idas,
UD_Idec,
UD_Idiv,
UD_Idivpd,
UD_Idivps,
UD_Idivsd,
UD_Idivss,
UD_Idppd,
UD_Idpps,
UD_Iemms,
UD_Ienter,
UD_Iextractps,
UD_If2xm1,
UD_Ifabs,
UD_Ifadd,
UD_Ifaddp,
UD_Ifbld,
UD_Ifbstp,
UD_Ifchs,
UD_Ifclex,
UD_Ifcmovb,
UD_Ifcmovbe,
UD_Ifcmove,
UD_Ifcmovnb,
UD_Ifcmovnbe,
UD_Ifcmovne,
UD_Ifcmovnu,
UD_Ifcmovu,
UD_Ifcom,
UD_Ifcom2,
UD_Ifcomi,
UD_Ifcomip,
UD_Ifcomp,
UD_Ifcomp3,
UD_Ifcomp5,
UD_Ifcompp,
UD_Ifcos,
UD_Ifdecstp,
UD_Ifdiv,
UD_Ifdivp,
UD_Ifdivr,
UD_Ifdivrp,
UD_Ifemms,
UD_Iffree,
UD_Iffreep,
UD_Ifiadd,
UD_Ificom,
UD_Ificomp,
UD_Ifidiv,
UD_Ifidivr,
UD_Ifild,
UD_Ifimul,
UD_Ifincstp,
UD_Ifist,
UD_Ifistp,
UD_Ifisttp,
UD_Ifisub,
UD_Ifisubr,
UD_Ifld,
UD_Ifld1,
UD_Ifldcw,
UD_Ifldenv,
UD_Ifldl2e,
UD_Ifldl2t,
UD_Ifldlg2,
UD_Ifldln2,
UD_Ifldpi,
UD_Ifldz,
UD_Ifmul,
UD_Ifmulp,
UD_Ifndisi,
UD_Ifneni,
UD_Ifninit,
UD_Ifnop,
UD_Ifnsave,
UD_Ifnsetpm,
UD_Ifnstcw,
UD_Ifnstenv,
UD_Ifnstsw,
UD_Ifpatan,
UD_Ifprem,
UD_Ifprem1,
UD_Ifptan,
UD_Ifrndint,
UD_Ifrstor,
UD_Ifrstpm,
UD_Ifscale,
UD_Ifsin,
UD_Ifsincos,
UD_Ifsqrt,
UD_Ifst,
UD_Ifstp,
UD_Ifstp1,
UD_Ifstp8,
UD_Ifstp9,
UD_Ifsub,
UD_Ifsubp,
UD_Ifsubr,
UD_Ifsubrp,
UD_Iftst,
UD_Ifucom,
UD_Ifucomi,
UD_Ifucomip,
UD_Ifucomp,
UD_Ifucompp,
UD_Ifxam,
UD_Ifxch,
UD_Ifxch4,
UD_Ifxch7,
UD_Ifxrstor,
UD_Ifxsave,
UD_Ifxtract,
UD_Ifyl2x,
UD_Ifyl2xp1,
UD_Igetsec,
UD_Ihaddpd,
UD_Ihaddps,
UD_Ihlt,
UD_Ihsubpd,
UD_Ihsubps,
UD_Iidiv,
UD_Iimul,
UD_Iin,
UD_Iinc,
UD_Iinsb,
UD_Iinsd,
UD_Iinsertps,
UD_Iinsw,
UD_Iint,
UD_Iint1,
UD_Iint3,
UD_Iinto,
UD_Iinvd,
UD_Iinvept,
UD_Iinvlpg,
UD_Iinvlpga,
UD_Iinvvpid,
UD_Iiretd,
UD_Iiretq,
UD_Iiretw,
UD_Ija,
UD_Ijae,
UD_Ijb,
UD_Ijbe,
UD_Ijcxz,
UD_Ije,
UD_Ijecxz,
UD_Ijg,
UD_Ijge,
UD_Ijl,
UD_Ijle,
UD_Ijmp,
UD_Ijne,
UD_Ijno,
UD_Ijnp,
UD_Ijns,
UD_Ijo,
UD_Ijp,
UD_Ijrcxz,
UD_Ijs,
UD_Ilahf,
UD_Ilar,
UD_Ilddqu,
UD_Ildmxcsr,
UD_Ilds,
UD_Ilea,
UD_Ileave,
UD_Iles,
UD_Ilfence,
UD_Ilfs,
UD_Ilgdt,
UD_Ilgs,
UD_Ilidt,
UD_Illdt,
UD_Ilmsw,
UD_Ilock,
UD_Ilodsb,
UD_Ilodsd,
UD_Ilodsq,
UD_Ilodsw,
UD_Iloop,
UD_Iloope,
UD_Iloopne,
UD_Ilsl,
UD_Ilss,
UD_Iltr,
UD_Imaskmovdqu,
UD_Imaskmovq,
UD_Imaxpd,
UD_Imaxps,
UD_Imaxsd,
UD_Imaxss,
UD_Imfence,
UD_Iminpd,
UD_Iminps,
UD_Iminsd,
UD_Iminss,
UD_Imonitor,
UD_Imontmul,
UD_Imov,
UD_Imovapd,
UD_Imovaps,
UD_Imovbe,
UD_Imovd,
UD_Imovddup,
UD_Imovdq2q,
UD_Imovdqa,
UD_Imovdqu,
UD_Imovhlps,
UD_Imovhpd,
UD_Imovhps,
UD_Imovlhps,
UD_Imovlpd,
UD_Imovlps,
UD_Imovmskpd,
UD_Imovmskps,
UD_Imovntdq,
UD_Imovntdqa,
UD_Imovnti,
UD_Imovntpd,
UD_Imovntps,
UD_Imovntq,
UD_Imovq,
UD_Imovq2dq,
UD_Imovsb,
UD_Imovsd,
UD_Imovshdup,
UD_Imovsldup,
UD_Imovsq,
UD_Imovss,
UD_Imovsw,
UD_Imovsx,
UD_Imovsxd,
UD_Imovupd,
UD_Imovups,
UD_Imovzx,
UD_Impsadbw,
UD_Imul,
UD_Imulpd,
UD_Imulps,
UD_Imulsd,
UD_Imulss,
UD_Imwait,
UD_Ineg,
UD_Inop,
UD_Inot,
UD_Ior,
UD_Iorpd,
UD_Iorps,
UD_Iout,
UD_Ioutsb,
UD_Ioutsd,
UD_Ioutsw,
UD_Ipabsb,
UD_Ipabsd,
UD_Ipabsw,
UD_Ipackssdw,
UD_Ipacksswb,
UD_Ipackusdw,
UD_Ipackuswb,
UD_Ipaddb,
UD_Ipaddd,
UD_Ipaddq,
UD_Ipaddsb,
UD_Ipaddsw,
UD_Ipaddusb,
UD_Ipaddusw,
UD_Ipaddw,
UD_Ipalignr,
UD_Ipand,
UD_Ipandn,
UD_Ipavgb,
UD_Ipavgusb,
UD_Ipavgw,
UD_Ipblendvb,
UD_Ipblendw,
UD_Ipclmulqdq,
UD_Ipcmpeqb,
UD_Ipcmpeqd,
UD_Ipcmpeqq,
UD_Ipcmpeqw,
UD_Ipcmpestri,
UD_Ipcmpestrm,
UD_Ipcmpgtb,
UD_Ipcmpgtd,
UD_Ipcmpgtq,
UD_Ipcmpgtw,
UD_Ipcmpistri,
UD_Ipcmpistrm,
UD_Ipextrb,
UD_Ipextrd,
UD_Ipextrq,
UD_Ipextrw,
UD_Ipf2id,
UD_Ipf2iw,
UD_Ipfacc,
UD_Ipfadd,
UD_Ipfcmpeq,
UD_Ipfcmpge,
UD_Ipfcmpgt,
UD_Ipfmax,
UD_Ipfmin,
UD_Ipfmul,
UD_Ipfnacc,
UD_Ipfpnacc,
UD_Ipfrcp,
UD_Ipfrcpit1,
UD_Ipfrcpit2,
UD_Ipfrsqit1,
UD_Ipfrsqrt,
UD_Ipfsub,
UD_Ipfsubr,
UD_Iphaddd,
UD_Iphaddsw,
UD_Iphaddw,
UD_Iphminposuw,
UD_Iphsubd,
UD_Iphsubsw,
UD_Iphsubw,
UD_Ipi2fd,
UD_Ipi2fw,
UD_Ipinsrb,
UD_Ipinsrd,
UD_Ipinsrq,
UD_Ipinsrw,
UD_Ipmaddubsw,
UD_Ipmaddwd,
UD_Ipmaxsb,
UD_Ipmaxsd,
UD_Ipmaxsw,
UD_Ipmaxub,
UD_Ipmaxud,
UD_Ipmaxuw,
UD_Ipminsb,
UD_Ipminsd,
UD_Ipminsw,
UD_Ipminub,
UD_Ipminud,
UD_Ipminuw,
UD_Ipmovmskb,
UD_Ipmovsxbd,
UD_Ipmovsxbq,
UD_Ipmovsxbw,
UD_Ipmovsxdq,
UD_Ipmovsxwd,
UD_Ipmovsxwq,
UD_Ipmovzxbd,
UD_Ipmovzxbq,
UD_Ipmovzxbw,
UD_Ipmovzxdq,
UD_Ipmovzxwd,
UD_Ipmovzxwq,
UD_Ipmuldq,
UD_Ipmulhrsw,
UD_Ipmulhrw,
UD_Ipmulhuw,
UD_Ipmulhw,
UD_Ipmulld,
UD_Ipmullw,
UD_Ipmuludq,
UD_Ipop,
UD_Ipopa,
UD_Ipopad,
UD_Ipopcnt,
UD_Ipopfd,
UD_Ipopfq,
UD_Ipopfw,
UD_Ipor,
UD_Iprefetch,
UD_Iprefetchnta,
UD_Iprefetcht0,
UD_Iprefetcht1,
UD_Iprefetcht2,
UD_Ipsadbw,
UD_Ipshufb,
UD_Ipshufd,
UD_Ipshufhw,
UD_Ipshuflw,
UD_Ipshufw,
UD_Ipsignb,
UD_Ipsignd,
UD_Ipsignw,
UD_Ipslld,
UD_Ipslldq,
UD_Ipsllq,
UD_Ipsllw,
UD_Ipsrad,
UD_Ipsraw,
UD_Ipsrld,
UD_Ipsrldq,
UD_Ipsrlq,
UD_Ipsrlw,
UD_Ipsubb,
UD_Ipsubd,
UD_Ipsubq,
UD_Ipsubsb,
UD_Ipsubsw,
UD_Ipsubusb,
UD_Ipsubusw,
UD_Ipsubw,
UD_Ipswapd,
UD_Iptest,
UD_Ipunpckhbw,
UD_Ipunpckhdq,
UD_Ipunpckhqdq,
UD_Ipunpckhwd,
UD_Ipunpcklbw,
UD_Ipunpckldq,
UD_Ipunpcklqdq,
UD_Ipunpcklwd,
UD_Ipush,
UD_Ipusha,
UD_Ipushad,
UD_Ipushfd,
UD_Ipushfq,
UD_Ipushfw,
UD_Ipxor,
UD_Ircl,
UD_Ircpps,
UD_Ircpss,
UD_Ircr,
UD_Irdmsr,
UD_Irdpmc,
UD_Irdrand,
UD_Irdtsc,
UD_Irdtscp,
UD_Irep,
UD_Irepne,
UD_Iret,
UD_Iretf,
UD_Irol,
UD_Iror,
UD_Iroundpd,
UD_Iroundps,
UD_Iroundsd,
UD_Iroundss,
UD_Irsm,
UD_Irsqrtps,
UD_Irsqrtss,
UD_Isahf,
UD_Isalc,
UD_Isar,
UD_Isbb,
UD_Iscasb,
UD_Iscasd,
UD_Iscasq,
UD_Iscasw,
UD_Iseta,
UD_Isetae,
UD_Isetb,
UD_Isetbe,
UD_Isete,
UD_Isetg,
UD_Isetge,
UD_Isetl,
UD_Isetle,
UD_Isetne,
UD_Isetno,
UD_Isetnp,
UD_Isetns,
UD_Iseto,
UD_Isetp,
UD_Isets,
UD_Isfence,
UD_Isgdt,
UD_Ishl,
UD_Ishld,
UD_Ishr,
UD_Ishrd,
UD_Ishufpd,
UD_Ishufps,
UD_Isidt,
UD_Iskinit,
UD_Isldt,
UD_Ismsw,
UD_Isqrtpd,
UD_Isqrtps,
UD_Isqrtsd,
UD_Isqrtss,
UD_Istc,
UD_Istd,
UD_Istgi,
UD_Isti,
UD_Istmxcsr,
UD_Istosb,
UD_Istosd,
UD_Istosq,
UD_Istosw,
UD_Istr,
UD_Isub,
UD_Isubpd,
UD_Isubps,
UD_Isubsd,
UD_Isubss,
UD_Iswapgs,
UD_Isyscall,
UD_Isysenter,
UD_Isysexit,
UD_Isysret,
UD_Itest,
UD_Iucomisd,
UD_Iucomiss,
UD_Iud2,
UD_Iunpckhpd,
UD_Iunpckhps,
UD_Iunpcklpd,
UD_Iunpcklps,
UD_Ivaddpd,
UD_Ivaddps,
UD_Ivaddsd,
UD_Ivaddss,
UD_Ivaddsubpd,
UD_Ivaddsubps,
UD_Ivaesdec,
UD_Ivaesdeclast,
UD_Ivaesenc,
UD_Ivaesenclast,
UD_Ivaesimc,
UD_Ivaeskeygenassist,
UD_Ivandnpd,
UD_Ivandnps,
UD_Ivandpd,
UD_Ivandps,
UD_Ivblendpd,
UD_Ivblendps,
UD_Ivblendvpd,
UD_Ivblendvps,
UD_Ivbroadcastsd,
UD_Ivbroadcastss,
UD_Ivcmppd,
UD_Ivcmpps,
UD_Ivcmpsd,
UD_Ivcmpss,
UD_Ivcomisd,
UD_Ivcomiss,
UD_Ivcvtdq2pd,
UD_Ivcvtdq2ps,
UD_Ivcvtpd2dq,
UD_Ivcvtpd2ps,
UD_Ivcvtps2dq,
UD_Ivcvtps2pd,
UD_Ivcvtsd2si,
UD_Ivcvtsd2ss,
UD_Ivcvtsi2sd,
UD_Ivcvtsi2ss,
UD_Ivcvtss2sd,
UD_Ivcvtss2si,
UD_Ivcvttpd2dq,
UD_Ivcvttps2dq,
UD_Ivcvttsd2si,
UD_Ivcvttss2si,
UD_Ivdivpd,
UD_Ivdivps,
UD_Ivdivsd,
UD_Ivdivss,
UD_Ivdppd,
UD_Ivdpps,
UD_Iverr,
UD_Iverw,
UD_Ivextractf128,
UD_Ivextractps,
UD_Ivhaddpd,
UD_Ivhaddps,
UD_Ivhsubpd,
UD_Ivhsubps,
UD_Ivinsertf128,
UD_Ivinsertps,
UD_Ivlddqu,
UD_Ivmaskmovdqu,
UD_Ivmaskmovpd,
UD_Ivmaskmovps,
UD_Ivmaxpd,
UD_Ivmaxps,
UD_Ivmaxsd,
UD_Ivmaxss,
UD_Ivmcall,
UD_Ivmclear,
UD_Ivminpd,
UD_Ivminps,
UD_Ivminsd,
UD_Ivminss,
UD_Ivmlaunch,
UD_Ivmload,
UD_Ivmmcall,
UD_Ivmovapd,
UD_Ivmovaps,
UD_Ivmovd,
UD_Ivmovddup,
UD_Ivmovdqa,
UD_Ivmovdqu,
UD_Ivmovhlps,
UD_Ivmovhpd,
UD_Ivmovhps,
UD_Ivmovlhps,
UD_Ivmovlpd,
UD_Ivmovlps,
UD_Ivmovmskpd,
UD_Ivmovmskps,
UD_Ivmovntdq,
UD_Ivmovntdqa,
UD_Ivmovntpd,
UD_Ivmovntps,
UD_Ivmovq,
UD_Ivmovsd,
UD_Ivmovshdup,
UD_Ivmovsldup,
UD_Ivmovss,
UD_Ivmovupd,
UD_Ivmovups,
UD_Ivmpsadbw,
UD_Ivmptrld,
UD_Ivmptrst,
UD_Ivmread,
UD_Ivmresume,
UD_Ivmrun,
UD_Ivmsave,
UD_Ivmulpd,
UD_Ivmulps,
UD_Ivmulsd,
UD_Ivmulss,
UD_Ivmwrite,
UD_Ivmxoff,
UD_Ivmxon,
UD_Ivorpd,
UD_Ivorps,
UD_Ivpabsb,
UD_Ivpabsd,
UD_Ivpabsw,
UD_Ivpackssdw,
UD_Ivpacksswb,
UD_Ivpackusdw,
UD_Ivpackuswb,
UD_Ivpaddb,
UD_Ivpaddd,
UD_Ivpaddq,
UD_Ivpaddsb,
UD_Ivpaddsw,
UD_Ivpaddusb,
UD_Ivpaddusw,
UD_Ivpaddw,
UD_Ivpalignr,
UD_Ivpand,
UD_Ivpandn,
UD_Ivpavgb,
UD_Ivpavgw,
UD_Ivpblendvb,
UD_Ivpblendw,
UD_Ivpclmulqdq,
UD_Ivpcmpeqb,
UD_Ivpcmpeqd,
UD_Ivpcmpeqq,
UD_Ivpcmpeqw,
UD_Ivpcmpestri,
UD_Ivpcmpestrm,
UD_Ivpcmpgtb,
UD_Ivpcmpgtd,
UD_Ivpcmpgtq,
UD_Ivpcmpgtw,
UD_Ivpcmpistri,
UD_Ivpcmpistrm,
UD_Ivperm2f128,
UD_Ivpermilpd,
UD_Ivpermilps,
UD_Ivpextrb,
UD_Ivpextrd,
UD_Ivpextrq,
UD_Ivpextrw,
UD_Ivphaddd,
UD_Ivphaddsw,
UD_Ivphaddw,
UD_Ivphminposuw,
UD_Ivphsubd,
UD_Ivphsubsw,
UD_Ivphsubw,
UD_Ivpinsrb,
UD_Ivpinsrd,
UD_Ivpinsrq,
UD_Ivpinsrw,
UD_Ivpmaddubsw,
UD_Ivpmaddwd,
UD_Ivpmaxsb,
UD_Ivpmaxsd,
UD_Ivpmaxsw,
UD_Ivpmaxub,
UD_Ivpmaxud,
UD_Ivpmaxuw,
UD_Ivpminsb,
UD_Ivpminsd,
UD_Ivpminsw,
UD_Ivpminub,
UD_Ivpminud,
UD_Ivpminuw,
UD_Ivpmovmskb,
UD_Ivpmovsxbd,
UD_Ivpmovsxbq,
UD_Ivpmovsxbw,
UD_Ivpmovsxwd,
UD_Ivpmovsxwq,
UD_Ivpmovzxbd,
UD_Ivpmovzxbq,
UD_Ivpmovzxbw,
UD_Ivpmovzxdq,
UD_Ivpmovzxwd,
UD_Ivpmovzxwq,
UD_Ivpmuldq,
UD_Ivpmulhrsw,
UD_Ivpmulhuw,
UD_Ivpmulhw,
UD_Ivpmulld,
UD_Ivpmullw,
UD_Ivpor,
UD_Ivpsadbw,
UD_Ivpshufb,
UD_Ivpshufd,
UD_Ivpshufhw,
UD_Ivpshuflw,
UD_Ivpsignb,
UD_Ivpsignd,
UD_Ivpsignw,
UD_Ivpslld,
UD_Ivpslldq,
UD_Ivpsllq,
UD_Ivpsllw,
UD_Ivpsrad,
UD_Ivpsraw,
UD_Ivpsrld,
UD_Ivpsrldq,
UD_Ivpsrlq,
UD_Ivpsrlw,
UD_Ivpsubb,
UD_Ivpsubd,
UD_Ivpsubq,
UD_Ivpsubsb,
UD_Ivpsubsw,
UD_Ivpsubusb,
UD_Ivpsubusw,
UD_Ivpsubw,
UD_Ivptest,
UD_Ivpunpckhbw,
UD_Ivpunpckhdq,
UD_Ivpunpckhqdq,
UD_Ivpunpckhwd,
UD_Ivpunpcklbw,
UD_Ivpunpckldq,
UD_Ivpunpcklqdq,
UD_Ivpunpcklwd,
UD_Ivpxor,
UD_Ivrcpps,
UD_Ivrcpss,
UD_Ivroundpd,
UD_Ivroundps,
UD_Ivroundsd,
UD_Ivroundss,
UD_Ivrsqrtps,
UD_Ivrsqrtss,
UD_Ivshufpd,
UD_Ivshufps,
UD_Ivsqrtpd,
UD_Ivsqrtps,
UD_Ivsqrtsd,
UD_Ivsqrtss,
UD_Ivstmxcsr,
UD_Ivsubpd,
UD_Ivsubps,
UD_Ivsubsd,
UD_Ivsubss,
UD_Ivtestpd,
UD_Ivtestps,
UD_Ivucomisd,
UD_Ivucomiss,
UD_Ivunpckhpd,
UD_Ivunpckhps,
UD_Ivunpcklpd,
UD_Ivunpcklps,
UD_Ivxorpd,
UD_Ivxorps,
UD_Ivzeroall,
UD_Ivzeroupper,
UD_Iwait,
UD_Iwbinvd,
UD_Iwrmsr,
UD_Ixadd,
UD_Ixchg,
UD_Ixcryptcbc,
UD_Ixcryptcfb,
UD_Ixcryptctr,
UD_Ixcryptecb,
UD_Ixcryptofb,
UD_Ixgetbv,
UD_Ixlatb,
UD_Ixor,
UD_Ixorpd,
UD_Ixorps,
UD_Ixrstor,
UD_Ixsave,
UD_Ixsetbv,
UD_Ixsha1,
UD_Ixsha256,
UD_Ixstore,
UD_Iinvalid,
UD_I3dnow,
UD_Inone,
UD_Idb,
UD_Ipause,
UD_MAX_MNEMONIC_CODE
} UD_ATTR_PACKED;
extern const char * ud_mnemonics_str[];
#endif /* UD_ITAB_H */
+230
View File
@@ -0,0 +1,230 @@
/* udis86 - libudis86/syn-att.c
*
* Copyright (c) 2002-2009 Vivek Thampi
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "types.h"
#include "extern.h"
#include "decode.h"
#include "itab.h"
#include "syn.h"
#include "udint.h"
/* -----------------------------------------------------------------------------
* opr_cast() - Prints an operand cast.
* -----------------------------------------------------------------------------
*/
static void
opr_cast(struct ud* u, struct ud_operand* op)
{
switch(op->size) {
case 16 : case 32 :
ud_asmprintf(u, "*"); break;
default: break;
}
}
/* -----------------------------------------------------------------------------
* gen_operand() - Generates assembly output for each operand.
* -----------------------------------------------------------------------------
*/
static void
gen_operand(struct ud* u, struct ud_operand* op)
{
switch(op->type) {
case UD_OP_CONST:
ud_asmprintf(u, "$0x%x", op->lval.udword);
break;
case UD_OP_REG:
ud_asmprintf(u, "%%%s", ud_reg_tab[op->base - UD_R_AL]);
break;
case UD_OP_MEM:
if (u->br_far) {
opr_cast(u, op);
}
if (u->pfx_seg) {
ud_asmprintf(u, "%%%s:", ud_reg_tab[u->pfx_seg - UD_R_AL]);
}
if (op->offset != 0) {
ud_syn_print_mem_disp(u, op, 0);
}
if (op->base) {
ud_asmprintf(u, "(%%%s", ud_reg_tab[op->base - UD_R_AL]);
}
if (op->index) {
if (op->base) {
ud_asmprintf(u, ",");
} else {
ud_asmprintf(u, "(");
}
ud_asmprintf(u, "%%%s", ud_reg_tab[op->index - UD_R_AL]);
}
if (op->scale) {
ud_asmprintf(u, ",%d", op->scale);
}
if (op->base || op->index) {
ud_asmprintf(u, ")");
}
break;
case UD_OP_IMM:
ud_asmprintf(u, "$");
ud_syn_print_imm(u, op);
break;
case UD_OP_JIMM:
ud_syn_print_addr(u, ud_syn_rel_target(u, op));
break;
case UD_OP_PTR:
switch (op->size) {
case 32:
ud_asmprintf(u, "$0x%x, $0x%x", op->lval.ptr.seg,
op->lval.ptr.off & 0xFFFF);
break;
case 48:
ud_asmprintf(u, "$0x%x, $0x%x", op->lval.ptr.seg,
op->lval.ptr.off);
break;
}
break;
default: return;
}
}
/* =============================================================================
* translates to AT&T syntax
* =============================================================================
*/
extern void
ud_translate_att(struct ud *u)
{
//int size = 0;
int star = 0;
/* check if P_OSO prefix is used */
if (! P_OSO(u->itab_entry->prefix) && u->pfx_opr) {
switch (u->dis_mode) {
case 16:
ud_asmprintf(u, "o32 ");
break;
case 32:
case 64:
ud_asmprintf(u, "o16 ");
break;
}
}
/* check if P_ASO prefix was used */
if (! P_ASO(u->itab_entry->prefix) && u->pfx_adr) {
switch (u->dis_mode) {
case 16:
ud_asmprintf(u, "a32 ");
break;
case 32:
ud_asmprintf(u, "a16 ");
break;
case 64:
ud_asmprintf(u, "a32 ");
break;
}
}
if (u->pfx_lock)
ud_asmprintf(u, "lock ");
if (u->pfx_rep) {
ud_asmprintf(u, "rep ");
} else if (u->pfx_repe) {
ud_asmprintf(u, "repe ");
} else if (u->pfx_repne) {
ud_asmprintf(u, "repne ");
}
/* special instructions */
switch (u->mnemonic) {
case UD_Iretf:
ud_asmprintf(u, "lret ");
break;
case UD_Idb:
ud_asmprintf(u, ".byte 0x%x", u->operand[0].lval.ubyte);
return;
case UD_Ijmp:
case UD_Icall:
if (u->br_far) ud_asmprintf(u, "l");
if (u->operand[0].type == UD_OP_REG) {
star = 1;
}
ud_asmprintf(u, "%s", ud_lookup_mnemonic(u->mnemonic));
break;
case UD_Ibound:
case UD_Ienter:
if (u->operand[0].type != UD_NONE)
gen_operand(u, &u->operand[0]);
if (u->operand[1].type != UD_NONE) {
ud_asmprintf(u, ",");
gen_operand(u, &u->operand[1]);
}
return;
default:
ud_asmprintf(u, "%s", ud_lookup_mnemonic(u->mnemonic));
}
/*
if (size == 8) {
ud_asmprintf(u, "b");
} else if (size == 16) {
ud_asmprintf(u, "w");
} else if (size == 64) {
ud_asmprintf(u, "q");
}
*/
if (star) {
ud_asmprintf(u, " *");
} else {
ud_asmprintf(u, " ");
}
if (u->operand[3].type != UD_NONE) {
gen_operand(u, &u->operand[3]);
ud_asmprintf(u, ", ");
}
if (u->operand[2].type != UD_NONE) {
gen_operand(u, &u->operand[2]);
ud_asmprintf(u, ", ");
}
if (u->operand[1].type != UD_NONE) {
gen_operand(u, &u->operand[1]);
ud_asmprintf(u, ", ");
}
if (u->operand[0].type != UD_NONE) {
gen_operand(u, &u->operand[0]);
}
}
/*
vim: set ts=2 sw=2 expandtab
*/
+224
View File
@@ -0,0 +1,224 @@
/* udis86 - libudis86/syn-intel.c
*
* Copyright (c) 2002-2013 Vivek Thampi
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "types.h"
#include "extern.h"
#include "decode.h"
#include "itab.h"
#include "syn.h"
#include "udint.h"
/* -----------------------------------------------------------------------------
* opr_cast() - Prints an operand cast.
* -----------------------------------------------------------------------------
*/
static void
opr_cast(struct ud* u, struct ud_operand* op)
{
if (u->br_far) {
ud_asmprintf(u, "far ");
}
switch(op->size) {
case 8: ud_asmprintf(u, "byte " ); break;
case 16: ud_asmprintf(u, "word " ); break;
case 32: ud_asmprintf(u, "dword "); break;
case 64: ud_asmprintf(u, "qword "); break;
case 80: ud_asmprintf(u, "tword "); break;
case 128: ud_asmprintf(u, "oword "); break;
case 256: ud_asmprintf(u, "yword "); break;
default: break;
}
}
/* -----------------------------------------------------------------------------
* gen_operand() - Generates assembly output for each operand.
* -----------------------------------------------------------------------------
*/
static void gen_operand(struct ud* u, struct ud_operand* op, int syn_cast)
{
switch(op->type) {
case UD_OP_REG:
ud_asmprintf(u, "%s", ud_reg_tab[op->base - UD_R_AL]);
break;
case UD_OP_MEM:
if (syn_cast) {
opr_cast(u, op);
}
ud_asmprintf(u, "[");
if (u->pfx_seg) {
ud_asmprintf(u, "%s:", ud_reg_tab[u->pfx_seg - UD_R_AL]);
}
if (op->base) {
ud_asmprintf(u, "%s", ud_reg_tab[op->base - UD_R_AL]);
}
if (op->index) {
ud_asmprintf(u, "%s%s", op->base != UD_NONE? "+" : "",
ud_reg_tab[op->index - UD_R_AL]);
if (op->scale) {
ud_asmprintf(u, "*%d", op->scale);
}
}
if (op->offset != 0) {
ud_syn_print_mem_disp(u, op, (op->base != UD_NONE ||
op->index != UD_NONE) ? 1 : 0);
}
ud_asmprintf(u, "]");
break;
case UD_OP_IMM:
ud_syn_print_imm(u, op);
break;
case UD_OP_JIMM:
ud_syn_print_addr(u, ud_syn_rel_target(u, op));
break;
case UD_OP_PTR:
switch (op->size) {
case 32:
ud_asmprintf(u, "word 0x%x:0x%x", op->lval.ptr.seg,
op->lval.ptr.off & 0xFFFF);
break;
case 48:
ud_asmprintf(u, "dword 0x%x:0x%x", op->lval.ptr.seg,
op->lval.ptr.off);
break;
}
break;
case UD_OP_CONST:
if (syn_cast) opr_cast(u, op);
ud_asmprintf(u, "%d", op->lval.udword);
break;
default: return;
}
}
/* =============================================================================
* translates to intel syntax
* =============================================================================
*/
extern void
ud_translate_intel(struct ud* u)
{
/* check if P_OSO prefix is used */
if (!P_OSO(u->itab_entry->prefix) && u->pfx_opr) {
switch (u->dis_mode) {
case 16: ud_asmprintf(u, "o32 "); break;
case 32:
case 64: ud_asmprintf(u, "o16 "); break;
}
}
/* check if P_ASO prefix was used */
if (!P_ASO(u->itab_entry->prefix) && u->pfx_adr) {
switch (u->dis_mode) {
case 16: ud_asmprintf(u, "a32 "); break;
case 32: ud_asmprintf(u, "a16 "); break;
case 64: ud_asmprintf(u, "a32 "); break;
}
}
if (u->pfx_seg &&
u->operand[0].type != UD_OP_MEM &&
u->operand[1].type != UD_OP_MEM ) {
ud_asmprintf(u, "%s ", ud_reg_tab[u->pfx_seg - UD_R_AL]);
}
if (u->pfx_lock) {
ud_asmprintf(u, "lock ");
}
if (u->pfx_rep) {
ud_asmprintf(u, "rep ");
} else if (u->pfx_repe) {
ud_asmprintf(u, "repe ");
} else if (u->pfx_repne) {
ud_asmprintf(u, "repne ");
}
/* print the instruction mnemonic */
ud_asmprintf(u, "%s", ud_lookup_mnemonic(u->mnemonic));
if (u->operand[0].type != UD_NONE) {
int cast = 0;
ud_asmprintf(u, " ");
if (u->operand[0].type == UD_OP_MEM) {
if (u->operand[1].type == UD_OP_IMM ||
u->operand[1].type == UD_OP_CONST ||
u->operand[1].type == UD_NONE ||
(u->operand[0].size != u->operand[1].size)) {
cast = 1;
} else if (u->operand[1].type == UD_OP_REG &&
u->operand[1].base == UD_R_CL) {
switch (u->mnemonic) {
case UD_Ircl:
case UD_Irol:
case UD_Iror:
case UD_Ircr:
case UD_Ishl:
case UD_Ishr:
case UD_Isar:
cast = 1;
break;
default: break;
}
}
}
gen_operand(u, &u->operand[0], cast);
}
if (u->operand[1].type != UD_NONE) {
int cast = 0;
ud_asmprintf(u, ", ");
if (u->operand[1].type == UD_OP_MEM &&
u->operand[0].size != u->operand[1].size &&
!ud_opr_is_sreg(&u->operand[0])) {
cast = 1;
}
gen_operand(u, &u->operand[1], cast);
}
if (u->operand[2].type != UD_NONE) {
int cast = 0;
ud_asmprintf(u, ", ");
if (u->operand[2].type == UD_OP_MEM &&
u->operand[2].size != u->operand[1].size) {
cast = 1;
}
gen_operand(u, &u->operand[2], cast);
}
if (u->operand[3].type != UD_NONE) {
ud_asmprintf(u, ", ");
gen_operand(u, &u->operand[3], 0);
}
}
/*
vim: set ts=2 sw=2 expandtab
*/
Loaded 100 of 408 files, more files were not shown because too many files have changed in this diff. Show more