Compare commits

..
136 Commits
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
187 changed files with 33105 additions and 1266 deletions

No files matched your search

+31 -27
View File
@@ -1,20 +1,21 @@
dist:
- trusty
sudo:
- false
os:
- linux
compiler:
- clang
addons:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.6
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++
- gcc-7
- llvm-dev
- libatomic-ops-dev
- mono-xbuild
- curl
- make
- tcc
- libboost-dev
- libqt4-dev
@@ -31,58 +32,61 @@ addons:
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 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 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 vala && r2pm -i valabind && r2pm -i r2api-python"
# - 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/radare/radare2-extras/jobs/199500082
# - 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-net && 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" # need to do this properly
- TESTS="r2pm -i vala"
- TESTS="r2pm -i valabind"
- TESTS="r2pm -i vapi"
# - 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 && r2pm -i yara-r2"
- TESTS="r2pm -i x86zyan"
sudo:
- false
language:
- c
- rust
rust:
- stable
cache:
- ccache
- apt
@@ -90,9 +94,10 @@ cache:
before_script:
- 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 7
- git clone https://github.com/radare/radare2-regressions
- git clone https://github.com/radare/radare2 && cd radare2
- 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
@@ -103,7 +108,6 @@ before_script:
- export LIBR_UTIL=${WORKING_DIR}/radare2/libr/util
- export PKG_CONFIG_PATH=${WORKING_DIR}/radare2/pkgcfg
- export GOPATH=${WORKING_DIR}/
- curl -sSf https://static.rust-lang.org/rustup.sh | sh
- r2pm init
- export R2PM_GITDIR=${WORKING_DIR}
- cd radare2-extras
+5 -4
View File
@@ -1,6 +1,5 @@
VERSION=@VERSION@
HAVE_LIB_YARA=@HAVE_LIB_YARA@
PREFIX=@PREFIX@
include options.mk
DESTDIR?=
TAR=tar -cvf
CZ=xz -f
@@ -24,7 +23,9 @@ help:
@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
+2 -2
View File
@@ -1,4 +1,4 @@
radare2-extras [![Build Status](https://travis-ci.org/radare/radare2-extras.svg?branch=master)](https://travis-ci.org/radare/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.
@@ -33,4 +33,4 @@ Building
The recommended way to build and install those plugins for users
is to use r2pm. See the radare2-pm repository for details:
https://github.com/radare/radare2-pm
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;
}
+2 -2
View File
@@ -5,7 +5,7 @@
"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
+44 -30
View File
@@ -1,9 +1,10 @@
#!/bin/sh
# This script was automatically generated by ACR v1.3
# 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 {
@@ -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"
@@ -103,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='2.2.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-2.2.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]...
@@ -178,7 +180,7 @@ take_environ() {
}
show_version() {
echo "radare2-extras-2.2.0 configuration script done with acr v1.3.
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
@@ -186,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
@@ -202,9 +204,9 @@ case $flag in
show_version ; ;;
-r|--r|--report)
echo "PKGNAME: radare2-extras"
echo "VERSION: 2.2.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
@@ -306,14 +308,15 @@ type ${PKGCONFIG} > /dev/null 2>&1 || echo "ERROR: Cannot find PKGCONFIG ${PKGCO
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
@@ -329,17 +332,26 @@ if [ $? = 0 ]; then
echo yes
else
eval ${VAR}=0
echo no ; fi }
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
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"
@@ -350,23 +362,25 @@ HAVE_LIB_EWF="0"; fi
[ -z "${PKGCONFIG}" ] && PKGCONFIG=pkg-config
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
[ -z "${PKGCONFIG}" ] && PKGCONFIG=pkg-config
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
@@ -403,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 2.2.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
+2 -2
View File
@@ -2212,7 +2212,7 @@ static int r_cmd_dwarf_call (void *user, const char *input) {
return true;
}
static int r_cmd_dwarf_deinit () {
static int r_cmd_dwarf_fini () {
int res = DW_DLV_ERROR;
if (fd && dbg) {
@@ -2236,7 +2236,7 @@ RCorePlugin r_core_plugin_dwarf = {
.desc = "DWARF parser to analyse various structure and set flags (global variables and function declaration)",
.license = "gpl",
.call = r_cmd_dwarf_call,
.deinit = r_cmd_dwarf_deinit
.fini = r_cmd_dwarf_fini
};
#ifndef CORELIB
+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
+22 -14
View File
@@ -1,9 +1,10 @@
#!/bin/sh
# This script was automatically generated by ACR v1.3
# 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 {
@@ -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"
@@ -175,7 +177,7 @@ take_environ() {
}
show_version() {
echo "radare2-keystone-0.1 configuration script done with acr v1.3.
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
@@ -183,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
@@ -329,24 +331,30 @@ if [ $? = 0 ]; then
echo yes
else
eval ${VAR}=0
echo no
echo "this library is required."
do_remove
exit 1 ; fi }
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
@@ -383,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);
+39
View File
@@ -4,12 +4,24 @@ 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_net
$(MAKE) -C anal m68k_net
@@ -17,14 +29,32 @@ m68k:
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)
@@ -38,4 +68,13 @@ m68k-install:
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
+11
View File
@@ -1,10 +1,21 @@
bea:
cd p ; $(MAKE) anal_x86_bea.$(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_net.$(LIBEXT)
rm -f p/anal_atombios.{$(LIBEXT),o}
include ../../options.mk
+2
View File
@@ -3,7 +3,9 @@ ARCHS=
ARCHS+=x86_bea.mk
#ARCHS+=x86_im.mk
ARCHS+=x86_simple.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
+4 -2
View File
@@ -58,6 +58,8 @@ static unsigned opcodes_types[] = {
[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,
@@ -174,7 +176,7 @@ static struct evm_sigs_info *sigs_info = 0;
static int evm_oplen(ut8 opcode) {
int ret;
EvmOpDef *opdef = &opcodes[opcode];
const EvmOpDef *opdef = &opcodes[opcode];
if (opdef->txt) {
return opdef->len;
@@ -451,7 +453,7 @@ static int evm_load_symbol_map (RAnal *anal, const char *file) {
if (sigs_info) {
sigs_info->rio = r_io_new ();
sigs_info->riodesc = r_io_open (sigs_info->rio, file, R_IO_READ, 0644);
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));
+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 */
+1
View File
@@ -1,4 +1,5 @@
OBJ_evm=anal_evm.o
OBJ_evm+=../../asm/arch/evm/evm.o
CFLAGS+=-I../../asm/arch/evm/
STATIC_OBJ+=${OBJ_evm}
+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}
+25 -3
View File
@@ -1,4 +1,10 @@
D=$(HOME)/.config/radare2/plugins
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)
@@ -6,6 +12,12 @@ bea:
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)
@@ -24,11 +36,18 @@ m68k_net:
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
cp -f p/asm_x86_zyan.$(LIBEXT) $(D)
mkdir -p $(R2PM_PLUGDIR)
cp -f p/asm_x86_zyan.$(LIBEXT) $(R2PM_PLUGDIR)
zyan-uninstall:
$(RM) $(D)/asm_x86_zyan.$(LIBEXT)
$(RM) $(R2PM_PLUGDIR)/asm_x86_zyan.$(LIBEXT)
clean:
rm -f p/asm_x86_bea.$(LIBEXT)
@@ -36,5 +55,8 @@ clean:
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
+79 -10
View File
@@ -6,6 +6,75 @@
#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;
@@ -18,13 +87,13 @@ static void settxtf(EvmOp *op, const char *fmt, ...) {
}
}
int evm_asm(const char *str, unsigned char *buf, int buf_len) {
int evm_asm(const char *str, RStrBuf *buf, int buf_len) {
int i, len = -1;
for (i = 0; i < 0xff; i++) {
EvmOpDef *opdef = &opcodes[i];
const EvmOpDef *opdef = &opcodes[i];
if (opdef->txt) {
if (!strcmp (opdef->txt, str)) {
buf[0] = i;
r_strbuf_appendf (buf, "%d", i);
return 1;
}
}
@@ -36,7 +105,7 @@ int evm_asm(const char *str, unsigned char *buf, int buf_len) {
int evm_dis(EvmOp *op, const unsigned char *buf, int buf_len) {
op->len = 1;
op->op = buf[0];
EvmOpDef *opdef = &opcodes[buf[0]];
const EvmOpDef *opdef = &opcodes[buf[0]];
if (opdef->txt) {
op->txt = opdef->txt;
op->len = opdef->len;
@@ -79,13 +148,13 @@ int evm_dis(EvmOp *op, const unsigned char *buf, int buf_len) {
case EVM_OP_PUSH31:
case EVM_OP_PUSH32:
{
int i, pushSize = buf[0] - EVM_OP_PUSH1;
op->imm = 0;
for (i = 0; i < pushSize + 1; i++) {
op->imm <<= 8;
op->imm |= buf[i + 1];
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%x", pushSize + 1, op->imm);
settxtf (op, "push%d 0x%s", pushSize + 1, hexbuf);
op->len = 2 + pushSize;
}
break;
+5 -70
View File
@@ -1,6 +1,7 @@
#ifndef EVM_EVM_H
#define EVM_EVM_H
#include <r_util.h>
typedef enum {
EVM_OP_STOP = 0x00,
@@ -42,6 +43,8 @@ typedef enum {
EVM_OP_GASPRICE,
EVM_OP_EXTCODESIZE,
EVM_OP_EXTCODECOPY,
EVM_OP_RETURNDATASIZE,
EVM_OP_RETURNDATACOPY,
EVM_OP_BLOCKHASH = 0x40,
EVM_OP_COINBASE,
@@ -147,7 +150,6 @@ typedef enum {
typedef struct EvmOp {
EvmOpcodes op;
int len;
uint64_t imm;
const char *txt;
char txt_buf[32];
} EvmOp;
@@ -157,75 +159,8 @@ typedef struct {
int len;
} EvmOpDef;
static 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_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 },
};
extern const EvmOpDef opcodes[256];
int evm_dis(EvmOp *op, const unsigned char *buf, int buf_len);
int evm_asm(const char *str, 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
+3 -3
View File
@@ -159,7 +159,7 @@ int r_pyc_disasm (RAsmOp *opstruct, const ut8 *code, RList *cobjs, RList *intern
op = code[i];
i += 1;
name = op_name[op];
strcpy (opstruct->buf_asm, name);
r_strbuf_set (&opstruct->buf_asm, name);
if (name == NULL) {
return 0;
}
@@ -171,7 +171,7 @@ int r_pyc_disasm (RAsmOp *opstruct, const ut8 *code, RList *cobjs, RList *intern
extended_arg = oparg*65536;
arg = parse_arg (op, oparg, names, consts, varnames, interned_table);
if (arg != NULL) {
strcat (opstruct->buf_asm, r_str_newf ("%20s", arg));
r_strbuf_appendf (&opstruct->buf_asm, "%20s", arg);
}
}
return i;
@@ -304,4 +304,4 @@ void dump_cobj (pyc_code_object *c) {
eprintf("varnames_start\n");
dump(c->varnames->data);
eprintf("varnames_end\n");
}
}
+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"
+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
*/
+219
View File
@@ -0,0 +1,219 @@
/* udis86 - libudis86/syn.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 "decode.h"
#include "syn.h"
#include "udint.h"
#include <inttypes.h>
/*
* Register Table - Order Matters (types.h)!
*
*/
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"
};
uint64_t
ud_syn_rel_target(struct ud *u, struct ud_operand *opr)
{
uint64_t trunc_mask = 0xffffffffffffffffull;
if (u->dis_mode <32) trunc_mask >>= (64 - u->opr_mode);
switch (opr->size) {
case 8 : return (u->pc + opr->lval.sbyte) & trunc_mask;
case 16: {
int delta = (opr->lval.sword & trunc_mask);
if ((u->pc + delta) > 0xffff)
return (u->pc & 0xf0000) + ((u->pc + delta) & 0xffff);
return (u->pc + delta);
}
case 32: return (u->pc + opr->lval.sdword) & trunc_mask;
default: UD_ASSERT(!"invalid relative offset size.");
return 0ull;
}
}
/*
* asmprintf
* Printf style function for printing translated assembly
* output. Returns the number of characters written and
* moves the buffer pointer forward. On an overflow,
* returns a negative number and truncates the output.
*/
int
ud_asmprintf(struct ud *u, const char *fmt, ...)
{
int ret;
int avail;
va_list ap;
va_start(ap, fmt);
avail = u->asm_buf_size - u->asm_buf_fill - 1 /* nullchar */;
ret = vsnprintf((char*) u->asm_buf + u->asm_buf_fill, avail, fmt, ap);
if (ret < 0 || ret > avail) {
u->asm_buf_fill = u->asm_buf_size - 1;
} else {
u->asm_buf_fill += ret;
}
va_end(ap);
return ret;
}
void
ud_syn_print_addr(struct ud *u, uint64_t addr)
{
const char *name = NULL;
if (u->sym_resolver) {
int64_t offset = 0;
name = u->sym_resolver(u, addr, &offset);
if (name) {
if (offset) {
ud_asmprintf(u, "%s%+" PRId64, name, offset);
} else {
ud_asmprintf(u, "%s", name);
}
return;
}
}
ud_asmprintf(u, "0x%" PRIx64, addr);
}
void
ud_syn_print_imm(struct ud* u, const struct ud_operand *op)
{
uint64_t v;
if (op->_oprcode == OP_sI && op->size != u->opr_mode) {
if (op->size == 8) {
v = (int64_t)op->lval.sbyte;
} else {
UD_ASSERT(op->size == 32);
v = (int64_t)op->lval.sdword;
}
if (u->opr_mode < 64) {
v = v & ((1ull << u->opr_mode) - 1ull);
}
} else {
switch (op->size) {
case 8 : v = op->lval.ubyte; break;
case 16: v = op->lval.uword; break;
case 32: v = op->lval.udword; break;
case 64: v = op->lval.uqword; break;
default: UD_ASSERT(!"invalid offset"); v = 0; /* keep cc happy */
}
}
ud_asmprintf(u, "0x%" PRIx64, v);
}
void
ud_syn_print_mem_disp(struct ud* u, const struct ud_operand *op, int sign)
{
UD_ASSERT(op->offset != 0);
if (op->base == UD_NONE && op->index == UD_NONE) {
uint64_t v;
UD_ASSERT(op->scale == UD_NONE && op->offset != 8);
/* unsigned mem-offset */
switch (op->offset) {
case 16: v = op->lval.uword; break;
case 32: v = op->lval.udword; break;
case 64: v = op->lval.uqword; break;
default: UD_ASSERT(!"invalid offset"); v = 0; /* keep cc happy */
}
ud_asmprintf(u, "0x%" PRIx64, v);
} else {
int64_t v;
UD_ASSERT(op->offset != 64);
switch (op->offset) {
case 8 : v = op->lval.sbyte; break;
case 16: v = op->lval.sword; break;
case 32: v = op->lval.sdword; break;
default: UD_ASSERT(!"invalid offset"); v = 0; /* keep cc happy */
}
if (v < 0) {
ud_asmprintf(u, "-0x%" PRIx64, -v);
} else if (v > 0) {
ud_asmprintf(u, "%s0x%" PRIx64, sign? "+" : "", v);
}
}
}
/*
vim: set ts=2 sw=2 expandtab
*/
+53
View File
@@ -0,0 +1,53 @@
/* udis86 - libudis86/syn.h
*
* Copyright (c) 2002-2009
* 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_SYN_H
#define UD_SYN_H
#include "types.h"
#ifndef __UD_STANDALONE__
# include <stdarg.h>
#endif /* __UD_STANDALONE__ */
extern const char* ud_reg_tab[];
uint64_t ud_syn_rel_target(struct ud*, struct ud_operand*);
#ifdef __GNUC__
int ud_asmprintf(struct ud *u, const char *fmt, ...)
__attribute__ ((format (printf, 2, 3)));
#else
int ud_asmprintf(struct ud *u, const char *fmt, ...);
#endif
void ud_syn_print_addr(struct ud *u, uint64_t addr);
void ud_syn_print_imm(struct ud* u, const struct ud_operand *op);
void ud_syn_print_mem_disp(struct ud* u, const struct ud_operand *, int sign);
#endif /* UD_SYN_H */
/*
vim: set ts=2 sw=2 expandtab
*/
+297
View File
@@ -0,0 +1,297 @@
/* udis86 - libudis86/types.h
*
* 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.
*/
#ifndef UD_TYPES_H
#define UD_TYPES_H
#ifdef __KERNEL__
/*
* -D__KERNEL__ is automatically passed on the command line when
* building something as part of the Linux kernel. Assume standalone
* mode.
*/
# include <linux/kernel.h>
# include <linux/string.h>
# ifndef __UD_STANDALONE__
# define __UD_STANDALONE__ 1
# endif
#endif /* __KERNEL__ */
#if !defined(__UD_STANDALONE__)
# include <stdint.h>
# include <stdio.h>
#endif
/* gcc specific extensions */
#ifdef __GNUC__
# define UD_ATTR_PACKED __attribute__((packed))
#else
# define UD_ATTR_PACKED
#endif /* UD_ATTR_PACKED */
/* -----------------------------------------------------------------------------
* All possible "types" of objects in udis86. Order is Important!
* -----------------------------------------------------------------------------
*/
enum ud_type
{
UD_NONE,
/* 8 bit GPRs */
UD_R_AL, UD_R_CL, UD_R_DL, UD_R_BL,
UD_R_AH, UD_R_CH, UD_R_DH, UD_R_BH,
UD_R_SPL, UD_R_BPL, UD_R_SIL, UD_R_DIL,
UD_R_R8B, UD_R_R9B, UD_R_R10B, UD_R_R11B,
UD_R_R12B, UD_R_R13B, UD_R_R14B, UD_R_R15B,
/* 16 bit GPRs */
UD_R_AX, UD_R_CX, UD_R_DX, UD_R_BX,
UD_R_SP, UD_R_BP, UD_R_SI, UD_R_DI,
UD_R_R8W, UD_R_R9W, UD_R_R10W, UD_R_R11W,
UD_R_R12W, UD_R_R13W, UD_R_R14W, UD_R_R15W,
/* 32 bit GPRs */
UD_R_EAX, UD_R_ECX, UD_R_EDX, UD_R_EBX,
UD_R_ESP, UD_R_EBP, UD_R_ESI, UD_R_EDI,
UD_R_R8D, UD_R_R9D, UD_R_R10D, UD_R_R11D,
UD_R_R12D, UD_R_R13D, UD_R_R14D, UD_R_R15D,
/* 64 bit GPRs */
UD_R_RAX, UD_R_RCX, UD_R_RDX, UD_R_RBX,
UD_R_RSP, UD_R_RBP, UD_R_RSI, UD_R_RDI,
UD_R_R8, UD_R_R9, UD_R_R10, UD_R_R11,
UD_R_R12, UD_R_R13, UD_R_R14, UD_R_R15,
/* segment registers */
UD_R_ES, UD_R_CS, UD_R_SS, UD_R_DS,
UD_R_FS, UD_R_GS,
/* control registers*/
UD_R_CR0, UD_R_CR1, UD_R_CR2, UD_R_CR3,
UD_R_CR4, UD_R_CR5, UD_R_CR6, UD_R_CR7,
UD_R_CR8, UD_R_CR9, UD_R_CR10, UD_R_CR11,
UD_R_CR12, UD_R_CR13, UD_R_CR14, UD_R_CR15,
/* debug registers */
UD_R_DR0, UD_R_DR1, UD_R_DR2, UD_R_DR3,
UD_R_DR4, UD_R_DR5, UD_R_DR6, UD_R_DR7,
UD_R_DR8, UD_R_DR9, UD_R_DR10, UD_R_DR11,
UD_R_DR12, UD_R_DR13, UD_R_DR14, UD_R_DR15,
/* mmx registers */
UD_R_MM0, UD_R_MM1, UD_R_MM2, UD_R_MM3,
UD_R_MM4, UD_R_MM5, UD_R_MM6, UD_R_MM7,
/* x87 registers */
UD_R_ST0, UD_R_ST1, UD_R_ST2, UD_R_ST3,
UD_R_ST4, UD_R_ST5, UD_R_ST6, UD_R_ST7,
/* extended multimedia registers */
UD_R_XMM0, UD_R_XMM1, UD_R_XMM2, UD_R_XMM3,
UD_R_XMM4, UD_R_XMM5, UD_R_XMM6, UD_R_XMM7,
UD_R_XMM8, UD_R_XMM9, UD_R_XMM10, UD_R_XMM11,
UD_R_XMM12, UD_R_XMM13, UD_R_XMM14, UD_R_XMM15,
/* 256B multimedia registers */
UD_R_YMM0, UD_R_YMM1, UD_R_YMM2, UD_R_YMM3,
UD_R_YMM4, UD_R_YMM5, UD_R_YMM6, UD_R_YMM7,
UD_R_YMM8, UD_R_YMM9, UD_R_YMM10, UD_R_YMM11,
UD_R_YMM12, UD_R_YMM13, UD_R_YMM14, UD_R_YMM15,
UD_R_RIP,
/* Operand Types */
UD_OP_REG, UD_OP_MEM, UD_OP_PTR, UD_OP_IMM,
UD_OP_JIMM, UD_OP_CONST
};
enum ud_eflag_state
{
UD_FLAG_UNCHANGED,
UD_FLAG_TESTED,
UD_FLAG_MODIFIED,
UD_FLAG_RESET,
UD_FLAG_SET,
UD_FLAG_UNDEFINED,
UD_FLAG_PRIOR
};
enum ud_operand_access
{
UD_OP_ACCESS_READ = 1,
UD_OP_ACCESS_WRITE = 2
};
/* This structure describes the state of the EFLAGS register
* once an instruction has been executed.
*/
struct ud_eflags
{
enum ud_eflag_state of_state;
enum ud_eflag_state sf_state;
enum ud_eflag_state zf_state;
enum ud_eflag_state af_state;
enum ud_eflag_state pf_state;
enum ud_eflag_state cf_state;
enum ud_eflag_state tf_state;
enum ud_eflag_state if_state;
enum ud_eflag_state df_state;
enum ud_eflag_state nt_state;
enum ud_eflag_state rf_state;
};
#include "itab.h"
union ud_lval {
int8_t sbyte;
uint8_t ubyte;
int16_t sword;
uint16_t uword;
int32_t sdword;
uint32_t udword;
int64_t sqword;
uint64_t uqword;
struct {
uint16_t seg;
uint32_t off;
} ptr;
};
/* -----------------------------------------------------------------------------
* struct ud_operand - Disassembled instruction Operand.
* -----------------------------------------------------------------------------
*/
struct ud_operand {
enum ud_type type;
uint16_t size;
enum ud_type base;
enum ud_type index;
uint8_t scale;
uint8_t offset;
union ud_lval lval;
uint8_t signed_lval;
uint8_t access;
/*
* internal use only
*/
uint64_t _legacy; /* this will be removed in 1.8 */
uint8_t _oprcode;
};
/* -----------------------------------------------------------------------------
* struct ud - The udis86 object.
* -----------------------------------------------------------------------------
*/
struct ud
{
/*
* input buffering
*/
int (*inp_hook) (struct ud*);
#ifndef __UD_STANDALONE__
FILE* inp_file;
#endif
const uint8_t* inp_buf;
size_t inp_buf_size;
size_t inp_buf_index;
uint8_t inp_curr;
size_t inp_ctr;
uint8_t inp_sess[64];
int inp_end;
int inp_peek;
void (*translator)(struct ud*);
uint64_t insn_offset;
char insn_hexcode[64];
/*
* Assembly output buffer
*/
char *asm_buf;
size_t asm_buf_size;
size_t asm_buf_fill;
char asm_buf_int[128];
/*
* Symbol resolver for use in the translation phase.
*/
const char* (*sym_resolver)(struct ud*, uint64_t addr, int64_t *offset);
uint8_t dis_mode;
uint64_t pc;
uint8_t vendor;
enum ud_mnemonic_code mnemonic;
struct ud_operand operand[4];
uint8_t error;
uint8_t _rex;
uint8_t pfx_rex;
uint8_t pfx_seg;
uint8_t pfx_opr;
uint8_t pfx_adr;
uint8_t pfx_lock;
uint8_t pfx_str;
uint8_t pfx_rep;
uint8_t pfx_repe;
uint8_t pfx_repne;
uint8_t opr_mode;
uint8_t adr_mode;
uint8_t br_far;
uint8_t br_near;
uint8_t have_modrm;
uint8_t modrm;
uint8_t modrm_offset;
uint8_t vex_op;
uint8_t vex_b1;
uint8_t vex_b2;
uint8_t primary_opcode;
void * user_opaque_data;
struct ud_itab_entry * itab_entry;
struct ud_lookup_table_list_entry *le;
};
/* -----------------------------------------------------------------------------
* Type-definitions
* -----------------------------------------------------------------------------
*/
typedef enum ud_type ud_type_t;
typedef enum ud_mnemonic_code ud_mnemonic_code_t;
typedef struct ud ud_t;
typedef struct ud_operand ud_operand_t;
#define UD_SYN_INTEL ud_translate_intel
#define UD_SYN_ATT ud_translate_att
#define UD_EOI (-1)
#define UD_INP_CACHE_SZ 32
#define UD_VENDOR_AMD 0
#define UD_VENDOR_INTEL 1
#define UD_VENDOR_ANY 2
#endif
/*
vim: set ts=2 sw=2 expandtab
*/
+97
View File
@@ -0,0 +1,97 @@
/* udis86 - libudis86/udint.h -- definitions for internal use only
*
* 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 _UDINT_H_
#define _UDINT_H_
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif /* HAVE_CONFIG_H */
#if defined(UD_DEBUG) && HAVE_ASSERT_H
# include <assert.h>
# define UD_ASSERT(_x) assert(_x)
#else
# define UD_ASSERT(_x)
#endif /* !HAVE_ASSERT_H */
#if defined(UD_DEBUG)
#define UDERR(u, msg) \
do { \
(u)->error = 1; \
fprintf(stderr, "decode-error: %s:%d: %s", \
__FILE__, __LINE__, (msg)); \
} while (0)
#else
#define UDERR(u, m) \
do { \
(u)->error = 1; \
} while (0)
#endif /* !LOGERR */
#define UD_RETURN_ON_ERROR(u) \
do { \
if ((u)->error != 0) { \
return (u)->error; \
} \
} while (0)
#define UD_RETURN_WITH_ERROR(u, m) \
do { \
UDERR(u, m); \
return (u)->error; \
} while (0)
#ifndef __UD_STANDALONE__
# define UD_NON_STANDALONE(x) x
#else
# define UD_NON_STANDALONE(x)
#endif
/* printf formatting int64 specifier */
#ifdef FMT64
# undef FMT64
#endif
#if defined(_MSC_VER) || defined(__BORLANDC__) || __WINDOWS__ || __MINGW32__ && !defined(__CYGWIN__)
# define FMT64 "I64"
#else
# if defined(__APPLE__)
# define FMT64 "ll"
# elif defined(__amd64__) || defined(__x86_64__)
# define FMT64 "l"
# else
# define FMT64 "ll"
# endif /* !x64 */
#endif
/* define an inline macro */
#if defined(_MSC_VER) || defined(__BORLANDC__)
# define UD_INLINE __inline /* MS Visual Studio requires __inline
instead of inline for C code */
#else
# define UD_INLINE inline
#endif
#endif /* _UDINT_H_ */
+506
View File
@@ -0,0 +1,506 @@
/* udis86 - libudis86/udis86.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 "udint.h"
#include "extern.h"
#include "decode.h"
#include <string.h>
#if !defined(__UD_STANDALONE__)
# if HAVE_STRING_H
# include <string.h>
# endif
#endif /* !__UD_STANDALONE__ */
static void ud_inp_init(struct ud *u);
/* =============================================================================
* ud_init
* Initializes ud_t object.
* =============================================================================
*/
extern void
ud_init(struct ud* u)
{
memset((void*)u, 0, sizeof(struct ud));
ud_set_mode(u, 16);
u->mnemonic = UD_Iinvalid;
ud_set_pc(u, 0);
#ifndef __UD_STANDALONE__
ud_set_input_file(u, stdin);
#endif /* __UD_STANDALONE__ */
ud_set_asm_buffer(u, u->asm_buf_int, sizeof(u->asm_buf_int));
}
/* =============================================================================
* ud_disassemble
* Disassembles one instruction and returns the number of
* bytes disassembled. A zero means end of disassembly.
* =============================================================================
*/
extern unsigned int
ud_disassemble(struct ud* u)
{
int len;
if (u->inp_end) {
return 0;
}
if ((len = ud_decode(u)) > 0) {
if (u->translator != NULL) {
u->asm_buf[0] = '\0';
u->translator(u);
}
}
return len;
}
/* =============================================================================
* ud_set_mode() - Set Disassemly Mode.
* =============================================================================
*/
extern void
ud_set_mode(struct ud* u, uint8_t m)
{
switch(m) {
case 16:
case 32:
case 64: u->dis_mode = m ; return;
default: u->dis_mode = 16; return;
}
}
/* =============================================================================
* ud_set_vendor() - Set vendor.
* =============================================================================
*/
extern void
ud_set_vendor(struct ud* u, unsigned v)
{
switch(v) {
case UD_VENDOR_INTEL:
u->vendor = v;
break;
case UD_VENDOR_ANY:
u->vendor = v;
break;
default:
u->vendor = UD_VENDOR_AMD;
}
}
/* =============================================================================
* ud_set_pc() - Sets code origin.
* =============================================================================
*/
extern void
ud_set_pc(struct ud* u, uint64_t o)
{
u->pc = o;
}
/* =============================================================================
* ud_set_syntax() - Sets the output syntax.
* =============================================================================
*/
extern void
ud_set_syntax(struct ud* u, void (*t)(struct ud*))
{
u->translator = t;
}
/* =============================================================================
* ud_insn() - returns the disassembled instruction
* =============================================================================
*/
const char*
ud_insn_asm(const struct ud* u)
{
return u->asm_buf;
}
/* =============================================================================
* ud_insn_offset() - Returns the offset.
* =============================================================================
*/
uint64_t
ud_insn_off(const struct ud* u)
{
return u->insn_offset;
}
/* =============================================================================
* ud_insn_hex() - Returns hex form of disassembled instruction.
* =============================================================================
*/
const char*
ud_insn_hex(struct ud* u)
{
u->insn_hexcode[0] = 0;
if (!u->error) {
unsigned int i;
const unsigned char *src_ptr = ud_insn_ptr(u);
char* src_hex;
src_hex = (char*) u->insn_hexcode;
/* for each byte used to decode instruction */
for (i = 0; i < ud_insn_len(u) && i < sizeof(u->insn_hexcode) / 2;
++i, ++src_ptr) {
sprintf(src_hex, "%02x", *src_ptr & 0xFF);
src_hex += 2;
}
}
return u->insn_hexcode;
}
/* =============================================================================
* ud_insn_ptr
* Returns a pointer to buffer containing the bytes that were
* disassembled.
* =============================================================================
*/
extern const uint8_t*
ud_insn_ptr(const struct ud* u)
{
return (u->inp_buf == NULL) ?
u->inp_sess : u->inp_buf + (u->inp_buf_index - u->inp_ctr);
}
/* =============================================================================
* ud_insn_len
* Returns the count of bytes disassembled.
* =============================================================================
*/
extern unsigned int
ud_insn_len(const struct ud* u)
{
return u->inp_ctr;
}
/* =============================================================================
* ud_insn_get_opr
* Return the operand struct representing the nth operand of
* the currently disassembled instruction. Returns NULL if
* there's no such operand.
* =============================================================================
*/
const struct ud_operand*
ud_insn_opr(const struct ud *u, unsigned int n)
{
if (n > 3 || u->operand[n].type == UD_NONE) {
return NULL;
} else {
return &u->operand[n];
}
}
/* =============================================================================
* ud_opr_is_sreg
* Returns non-zero if the given operand is of a segment register type.
* =============================================================================
*/
int
ud_opr_is_sreg(const struct ud_operand *opr)
{
return opr->type == UD_OP_REG &&
opr->base >= UD_R_ES &&
opr->base <= UD_R_GS;
}
/* =============================================================================
* ud_opr_is_sreg
* Returns non-zero if the given operand is of a general purpose
* register type.
* =============================================================================
*/
int
ud_opr_is_gpr(const struct ud_operand *opr)
{
return opr->type == UD_OP_REG &&
opr->base >= UD_R_AL &&
opr->base <= UD_R_R15;
}
/* =============================================================================
* ud_set_user_opaque_data
* ud_get_user_opaque_data
* Get/set user opaqute data pointer
* =============================================================================
*/
void
ud_set_user_opaque_data(struct ud * u, void* opaque)
{
u->user_opaque_data = opaque;
}
void*
ud_get_user_opaque_data(const struct ud *u)
{
return u->user_opaque_data;
}
/* =============================================================================
* ud_set_asm_buffer
* Allow the user to set an assembler output buffer. If `buf` is NULL,
* we switch back to the internal buffer.
* =============================================================================
*/
void
ud_set_asm_buffer(struct ud *u, char *buf, size_t size)
{
if (buf == NULL) {
ud_set_asm_buffer(u, u->asm_buf_int, sizeof(u->asm_buf_int));
} else {
u->asm_buf = buf;
u->asm_buf_size = size;
}
}
/* =============================================================================
* ud_set_sym_resolver
* Set symbol resolver for relative targets used in the translation
* phase.
*
* The resolver is a function that takes a uint64_t address and returns a
* symbolic name for the that address. The function also takes a second
* argument pointing to an integer that the client can optionally set to a
* non-zero value for offsetted targets. (symbol+offset) The function may
* also return NULL, in which case the translator only prints the target
* address.
*
* The function pointer maybe NULL which resets symbol resolution.
* =============================================================================
*/
void
ud_set_sym_resolver(struct ud *u, const char* (*resolver)(struct ud*,
uint64_t addr,
int64_t *offset))
{
u->sym_resolver = resolver;
}
/* =============================================================================
* ud_insn_mnemonic
* Return the current instruction mnemonic.
* =============================================================================
*/
enum ud_mnemonic_code
ud_insn_mnemonic(const struct ud *u)
{
return u->mnemonic;
}
/* =============================================================================
* ud_lookup_mnemonic
* Looks up mnemonic code in the mnemonic string table.
* Returns NULL if the mnemonic code is invalid.
* =============================================================================
*/
const char*
ud_lookup_mnemonic(enum ud_mnemonic_code c)
{
if (c < UD_MAX_MNEMONIC_CODE) {
return ud_mnemonics_str[c];
} else {
return NULL;
}
}
/* =============================================================================
* ud_lookup_eflags
* Looks up eflags information structure
* Returns NULL if invalid.
* =============================================================================
*/
const struct ud_eflags*
ud_lookup_eflags(struct ud *u)
{
if (u == NULL || u->itab_entry == NULL) {
return NULL;
} else {
return &u->itab_entry->eflags;
}
}
/* =============================================================================
* ud_lookup_implicit_reg_used_list
* Returns the list of register implicitly used.
* The list is terminated by UD_NONE.
* Returns NULL if invalid.
* =============================================================================
*/
const enum ud_type*
ud_lookup_implicit_reg_used_list(struct ud *u) {
if (u == NULL || u->itab_entry == NULL) {
return NULL;
} else {
return u->itab_entry->implicit_register_uses;
}
}
/* =============================================================================
* ud_lookup_implicit_reg_used_list
* Returns the list of register implicitly modified.
* The list is terminated by UD_NONE.
* Returns NULL if invalid.
* =============================================================================
*/
const enum ud_type*
ud_lookup_implicit_reg_defined_list(struct ud *u) {
if (u == NULL || u->itab_entry == NULL) {
return NULL;
} else {
return u->itab_entry->implicit_register_defs;
}
}
/*
* ud_inp_init
* Initializes the input system.
*/
static void
ud_inp_init(struct ud *u)
{
u->inp_hook = NULL;
u->inp_buf = NULL;
u->inp_buf_size = 0;
u->inp_buf_index = 0;
u->inp_curr = 0;
u->inp_ctr = 0;
u->inp_end = 0;
u->inp_peek = UD_EOI;
UD_NON_STANDALONE(u->inp_file = NULL);
}
/* =============================================================================
* ud_inp_set_hook
* Sets input hook.
* =============================================================================
*/
void
ud_set_input_hook(register struct ud* u, int (*hook)(struct ud*))
{
ud_inp_init(u);
u->inp_hook = hook;
}
/* =============================================================================
* ud_inp_set_buffer
* Set buffer as input.
* =============================================================================
*/
void
ud_set_input_buffer(register struct ud* u, const uint8_t* buf, size_t len)
{
ud_inp_init(u);
u->inp_buf = buf;
u->inp_buf_size = len;
u->inp_buf_index = 0;
}
#ifndef __UD_STANDALONE__
/* =============================================================================
* ud_input_set_file
* Set FILE as input.
* =============================================================================
*/
static int
inp_file_hook(struct ud* u)
{
return fgetc(u->inp_file);
}
void
ud_set_input_file(register struct ud* u, FILE* f)
{
ud_inp_init(u);
u->inp_hook = inp_file_hook;
u->inp_file = f;
}
#endif /* __UD_STANDALONE__ */
/* =============================================================================
* ud_input_skip
* Skip n input bytes.
* ============================================================================
*/
void
ud_input_skip(struct ud* u, size_t n)
{
if (u->inp_end) {
return;
}
if (u->inp_buf == NULL) {
while (n--) {
int c = u->inp_hook(u);
if (c == UD_EOI) {
goto eoi;
}
}
return;
} else {
if (n > u->inp_buf_size ||
u->inp_buf_index > u->inp_buf_size - n) {
u->inp_buf_index = u->inp_buf_size;
goto eoi;
}
u->inp_buf_index += n;
return;
}
eoi:
u->inp_end = 1;
UDERR(u, "cannot skip, eoi received\b");
return;
}
/* =============================================================================
* ud_input_end
* Returns non-zero on end-of-input.
* =============================================================================
*/
int
ud_input_end(const struct ud *u)
{
return u->inp_end;
}
/* vim:set ts=2 sw=2 expandtab */
+3
View File
@@ -1,5 +1,6 @@
ARCHS=
ARCHS+=x86_udis.mk
ARCHS+=x86_olly.mk
ARCHS+=x86_tab.mk
ARCHS+=armthumb.mk
@@ -9,6 +10,7 @@ ARCHS+=m68k_net.mk
ARCHS+=blackfin.mk
ARCHS+=x86_bea.mk
ARCHS+=msil.mk
ARCHS+=nios.mk
ARCHS+=swf.mk
ARCHS+=vc4.mk
ARCHS+=mc6809.mk
@@ -16,6 +18,7 @@ ARCHS+=z80_nc.mk
ARCHS+=pyc.mk
ARCHS+=x86_zyan.mk
ARCHS+=evm.mk
ARCHS+=atombios.mk
include ../../plugs.mk
+9 -8
View File
@@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2010-2015 - pancake */
/* radare - LGPL - Copyright 2010-2018 - pancake */
#include <stdio.h>
#include <stdarg.h>
@@ -11,10 +11,13 @@
static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
int *p = (int*)buf; // TODO : endian
op->buf_asm[0]='\0';
op->size = armthumb_disassemble (op->buf_asm, (ut32)a->pc, *p);
if (!op->size)
strncpy (op->buf_asm, " (data)", R_ASM_BUFSIZE);
char buf_asm[64] = {0};
op->size = armthumb_disassemble (buf_asm, (ut32)a->pc, *p);
if (op->size > 0) {
r_strbuf_set (&op->buf_asm, buf_asm);
} else {
r_strbuf_set (&op->buf_asm, " (data)");
}
return op->size;
}
@@ -33,14 +36,12 @@ RAsmPlugin r_asm_plugin_armthumb = {
.arch = "arm",
.bits = 16,
.desc = "ARM THUMB disassembly plugin",
.init = NULL,
.fini = NULL,
.disassemble = &disassemble,
// .assemble = &assemble
};
#ifndef CORELIB
struct r_lib_struct_t radare_plugin = {
RLibStruct radare_plugin = {
.type = R_LIB_TYPE_ASM,
.data = &r_asm_plugin_armthumb,
.version = R2_VERSION
+37
View File
@@ -0,0 +1,37 @@
/* radare - LGPL - Copyright 2018 - damo22 */
#include <r_types.h>
#include <r_lib.h>
#include <r_asm.h>
#include "../arch/atombios/atombios.h"
static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
op->size = atombios_disassemble (buf, r_asm_op_get_asm (op));
return op->size;
}
static int assemble(RAsm *a, RAsmOp *op, const char *buf) {
return 0; // n
}
RAsmPlugin r_asm_plugin_atombios = {
.name = "atombios",
.author = "damo22",
.version = "0.0.1",
.arch = "atombios",
.license = "LGPL3",
.bits = 32 | 64,
.endian = R_SYS_ENDIAN_NONE,
.desc = "AtomBIOS",
.disassemble = &disassemble,
.assemble = &assemble
};
#ifndef CORELIB
RLibStruct radare_plugin = {
.type = R_LIB_TYPE_ASM,
.data = &r_asm_plugin_atombios,
.version = R2_VERSION
};
#endif
+6 -18
View File
@@ -11,7 +11,7 @@
#include "blackfin/bfin-dis.c"
static unsigned long Offset = 0;
static char *buf_global = NULL;
static RStrBuf *buf_global = NULL;
static unsigned char bytes[4];
static int bfin_buffer_read_memory (bfd_vma memaddr, bfd_byte *myaddr, ut32 length, struct disassemble_info *info) {
@@ -28,41 +28,29 @@ static void memory_error_func(int status, bfd_vma memaddr, struct disassemble_in
}
static void print_address(bfd_vma address, struct disassemble_info *info) {
char tmp[32];
if (buf_global == NULL)
return;
sprintf(tmp, "0x%08"PFMT64x"", (ut64)address);
strcat(buf_global, tmp);
r_strbuf_appendf (buf_global, "0x%08"PFMT64x"", (ut64)address);
}
static int buf_fprintf(void *stream, const char *format, ...) {
int flen, glen;
va_list ap;
char *tmp;
if (buf_global == NULL)
return 0;
va_start (ap, format);
flen = strlen (format);
glen = strlen (buf_global);
tmp = malloc (flen + glen + 2);
memcpy (tmp, buf_global, glen);
memcpy (tmp+glen, format, flen);
tmp[flen+glen] = 0;
// XXX: overflow here?
vsprintf (buf_global, tmp, ap);
r_strbuf_vappendf (buf_global, format, ap);
va_end (ap);
free (tmp);
return 0;
}
static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
struct disassemble_info disasm_obj;
op->buf_asm[0]='\0';
r_strbuf_set (&op->buf_asm, "");
op->size = 4;
if (len<4)
return -1;
buf_global = op->buf_asm;
buf_global = &op->buf_asm;
Offset = a->pc;
memcpy (bytes, buf, 4); // TODO handle thumb
@@ -81,7 +69,7 @@ static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
op->size = print_insn_bfin((bfd_vma)Offset, &disasm_obj);
if (op->size == -1)
strncpy (op->buf_asm, " (data)", R_ASM_BUFSIZE);
r_strbuf_set (&op->buf_asm, " (data)");
return op->size;
}
+4 -3
View File
@@ -12,15 +12,16 @@ static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
EvmOp eop = {
0
};
evm_dis (&eop, buf, len);
strncpy (op->buf_asm, eop.txt, sizeof (op->buf_asm));
op->buf_asm[sizeof (op->buf_asm) - 1] = 0;
op->size = eop.len;
r_asm_op_set_asm (op, eop.txt);
return eop.len;
}
static int assemble(RAsm *a, RAsmOp *op, const char *buf) {
op->size = evm_asm (buf, op->buf, sizeof (op->buf));
op->size = evm_asm (buf, &op->buf, sizeof (op->buf));
return op->size;
}
+6 -3
View File
@@ -17,6 +17,7 @@ static int disassemble(RAsm *a, RAsmOp *aop, const ut8 *buf, int len) {
const unsigned char *buf2;
int ilen ;
static struct DisasmPara_68k dp;
char *buf_asm;
/* initialize DisasmPara */
*operands = *opcode = 0;
memcpy (bof, buf, R_MIN(len, sizeof(bof)));
@@ -31,9 +32,11 @@ static int disassemble(RAsm *a, RAsmOp *aop, const ut8 *buf, int len) {
}
ilen = (buf2-(const ut8*)bof);
if (*operands)
snprintf (aop->buf_asm, R_ASM_BUFSIZE, "%s %s", opcode, operands);
else snprintf (aop->buf_asm, R_ASM_BUFSIZE, "%s", opcode);
r_str_rmch (aop->buf_asm, '#');
buf_asm = sdb_fmt ("%s %s", opcode, operands);
else
buf_asm = sdb_fmt ("%s", opcode);
r_str_rmch (buf_asm, '#');
r_asm_op_set_asm (aop, buf_asm);
aop->size = ilen;
return aop->size;
}
+30 -34
View File
@@ -827,8 +827,7 @@ static const char mc6809_index_registers[] = {
/* 0b11 */ 's',
};
static int mc6809_append_indexed_args (char *buf_asm, const ut8 *buf)
{
static int mc6809_append_indexed_args(RStrBuf *buf_asm, const ut8 *buf) {
char postop_buffer[32];
int postop_bytes = 0;
@@ -992,42 +991,43 @@ static int mc6809_append_indexed_args (char *buf_asm, const ut8 *buf)
}
}
}
strcat (buf_asm, postop_buffer);
r_strbuf_append (buf_asm, postop_buffer);
return postop_bytes;
}
static int mc6809_append_pushpull_args(enum instruction_mode mode,
char *buf_asm,
RStrBuf *buf_asm,
const ut8 *opcode_args)
{
strcat (buf_asm, " ");
r_strbuf_append (buf_asm, " ");
if (*opcode_args & 0x80) {
strcat (buf_asm, "pc,");
r_strbuf_append (buf_asm, "pc,");
}
if (*opcode_args & 0x40) {
strcat (buf_asm, (mode == PUSHPULLSYSTEM) ? "u," : "s,");
r_strbuf_append (buf_asm, (mode == PUSHPULLSYSTEM) ? "u," : "s,");
}
if (*opcode_args & 0x20) {
strcat (buf_asm, "y,");
r_strbuf_append (buf_asm, "y,");
}
if (*opcode_args & 0x10) {
strcat (buf_asm, "x,");
r_strbuf_append (buf_asm, "x,");
}
if (*opcode_args & 0x08) {
strcat (buf_asm, "dp,");
r_strbuf_append (buf_asm, "dp,");
}
if (*opcode_args & 0x04) {
strcat (buf_asm, "b,");
r_strbuf_append (buf_asm, "b,");
}
if (*opcode_args & 0x02) {
strcat (buf_asm, "a,");
r_strbuf_append (buf_asm, "a,");
}
if (*opcode_args & 0x01) {
strcat (buf_asm, "cc,");
r_strbuf_append (buf_asm, "cc,");
}
/* Trim off the final unwanted comma */
buf_asm[strlen(buf_asm)-1] = '\0';
/* XXX we miss a proper r_str_buf_trim function here */
r_strbuf_get (buf_asm)[r_strbuf_length(buf_asm)-1] = '\0';
return 2;
}
@@ -1035,7 +1035,7 @@ static int mc6809_disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
ut8 tfrexg_regmasked;
const char *tfrexg_source_reg;
const char *tfrexg_dest_reg;
const char *buf_asm = "invalid";
const mc6809_opcodes_t *mc6809_opcode = &mc6809_opcodes[buf[0]];
/* opcode_args points to the first argument byte of the opcode */
@@ -1066,37 +1066,33 @@ static int mc6809_disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
case PAGE2: /* PAGE2 and PAGE3 shouldn't occur twice in a row */
case PAGE3:
op->size++;
strcpy (op->buf_asm, "INVALID");
break;
case INHERENT:
op->size++;
strcpy (op->buf_asm, mc6809_opcode->name);
buf_asm = sdb_fmt ("%s", mc6809_opcode->name);
break;
case IMMEDIATE:
op->size += 2;
sprintf (op->buf_asm,
"%s #$%02x", mc6809_opcode->name, *opcode_args);
buf_asm = sdb_fmt ("%s #$%02x", mc6809_opcode->name, *opcode_args);
break;
case IMMEDIATELONG:
op->size += 3;
sprintf (op->buf_asm,
"%s #$%04x", mc6809_opcode->name,
buf_asm = sdb_fmt ("%s #$%04x", mc6809_opcode->name,
opcode_args[0] * 256 + opcode_args[1]);
break;
case DIRECT:
op->size += 2;
sprintf (op->buf_asm,
"%s <$%02x", mc6809_opcode->name, *opcode_args);
buf_asm = sdb_fmt ("%s <$%02x", mc6809_opcode->name, *opcode_args);
break;
case RELATIVE:
op->size += 2;
sprintf (op->buf_asm, "%s $%04x",
buf_asm = sdb_fmt ("%s $%04x",
mc6809_opcode->name,
(ut16) (a->pc + (st8) *opcode_args + op->size) & 0xFFFF);
break;
case RELATIVELONG:
op->size += 3;
sprintf (op->buf_asm, "%s $%04x", mc6809_opcode->name,
buf_asm = sdb_fmt ("%s $%04x", mc6809_opcode->name,
(ut16) (a->pc + (st16)(opcode_args[0]*256+opcode_args[1])+op->size) & 0xFFFF);
break;
case TFREXG:
@@ -1105,7 +1101,6 @@ static int mc6809_disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
tfrexg_regmasked = *opcode_args & 0x88;
if (tfrexg_regmasked && tfrexg_regmasked != 0x88) {
op->size += 1;
strcpy (op->buf_asm, "INVALID");
} else {
tfrexg_source_reg = \
mc6809_register_field[(*opcode_args >> 4) & 0x0f];
@@ -1113,10 +1108,9 @@ static int mc6809_disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
mc6809_register_field[*opcode_args & 0x0f];
if (!tfrexg_source_reg || !tfrexg_dest_reg) {
op->size += 1;
strcpy (op->buf_asm, "INVALID");
} else {
op->size += 2;
sprintf (op->buf_asm,
buf_asm = sdb_fmt (
"%s %s,%s",
mc6809_opcode->name,
tfrexg_source_reg,
@@ -1127,19 +1121,19 @@ static int mc6809_disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
break;
case INDEXED:
/* Load Effective Address opcode - variable length */
strcpy (op->buf_asm, mc6809_opcode->name);
op->size += mc6809_append_indexed_args (op->buf_asm,
buf_asm = sdb_fmt ("%s", mc6809_opcode->name);
op->size += mc6809_append_indexed_args (&op->buf_asm,
opcode_args) + 1;
break;
case PUSHPULLSYSTEM:
case PUSHPULLUSER:
strcpy (op->buf_asm, mc6809_opcode->name);
buf_asm = sdb_fmt ("%s", mc6809_opcode->name);
op->size += mc6809_append_pushpull_args(mc6809_opcode->mode,
op->buf_asm,
&op->buf_asm,
opcode_args);
break;
case EXTENDED:
sprintf (op->buf_asm,
buf_asm = sdb_fmt (
"%s $%04x",
mc6809_opcode->name,
opcode_args[0] * 256 + opcode_args[1]);
@@ -1147,6 +1141,8 @@ static int mc6809_disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
break;
}
r_asm_op_set_asm (op, buf_asm);
return op->size;
}
@@ -1167,4 +1163,4 @@ struct r_lib_struct_t radare_plugin = {
.data = &r_asm_plugin_mc6809,
.version = R2_VERSION
};
#endif
#endif
+3 -3
View File
@@ -8,18 +8,18 @@
#include <r_asm.h>
#include "msil/demsil.c"
static int arch_msil_disasm(char *str, const ut8 *buf, ut64 seek) {
static int arch_msil_disasm(RStrBuf *buf_asm, const ut8 *buf, ut64 seek) {
ut32 n;
int o;
DISASMSIL_OFFSET CodeBase = seek;
ILOPCODE_STRUCT ilopar[8];
o = DisasMSIL (buf, 16, CodeBase, ilopar, 8, &n);
sprintf (str,"%s", ilopar[0].Mnemonic);
r_strbuf_setf (buf_asm, "%s", ilopar[0].Mnemonic);
return o;
}
static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
return (op->size = arch_msil_disasm (op->buf_asm, buf, a->pc));
return (op->size = arch_msil_disasm (&op->buf_asm, buf, a->pc));
}
RAsmPlugin r_asm_plugin_msil = {
+93
View File
@@ -0,0 +1,93 @@
/* nios plugin by hewittc at 2018 */
#include <r_asm.h>
#include <r_lib.h>
#include <r_types.h>
#include <r_util.h>
#include "dis-asm.h"
#include "nios/gnu/nios-desc.h"
static RStrBuf *buf_global = NULL;
static ut8 bytes[2];
static int nios_buffer_read_memory(bfd_vma address, bfd_byte *byte, ut32 len, disassemble_info *info) {
memcpy(byte, bytes, len);
return 0;
}
static int nios_symbol_at_address(bfd_vma address, disassemble_info *info) {
return 0;
}
static void nios_memory_error(int status, bfd_vma address, disassemble_info *info) {
//--
}
static void nios_print_address(bfd_vma address, disassemble_info *info) {
if (buf_global) {
r_strbuf_appendf (buf_global, "0x%08"PFMT64x, (ut64) address);
}
}
static int nios_fprintf(void *stream, const char *format, ...) {
if (!buf_global) {
return 0;
}
va_list args;
va_start(args, format);
r_strbuf_vappendf (buf_global, format, args);
va_end(args);
return 0;
}
static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
if (len < 2) {
return -1;
}
buf_global = &op->buf_asm;
memcpy(bytes, buf, 2);
struct disassemble_info info = {0};
info.disassembler_options = "";
info.mach = a->bits == 16 ? MACH_NIOS16 : MACH_NIOS32;
info.buffer = bytes;
info.read_memory_func = &nios_buffer_read_memory;
info.symbol_at_address_func = &nios_symbol_at_address;
info.memory_error_func = &nios_memory_error;
info.print_address_func = &nios_print_address;
info.endian = !a->big_endian;
info.fprintf_func = &nios_fprintf;
info.stream = stdout;
op->size = print_insn_nios((bfd_vma) a->pc, &info);
if (op->size == -1) {
r_strbuf_set(&op->buf_asm, " (data)");
}
return op->size;
}
RAsmPlugin r_asm_plugin_nios = {
.name = "nios",
.arch = "nios",
.desc = "Nios embedded processor",
.license = "GPL3",
.bits = 16 | 32,
.endian = R_SYS_ENDIAN_LITTLE | R_SYS_ENDIAN_BIG,
.disassemble = &disassemble,
};
#ifndef CORELIB
RLibStruct radare_plugin = {
.type = R_LIB_TYPE_ASM,
.data = &r_asm_plugin_nios,
.version = R2_VERSION
};
#endif
+6 -7
View File
@@ -1,4 +1,4 @@
/* radare - GPL3 - Copyright 2009-2015 pancake, nibble */
/* radare - GPL3 - Copyright 2009-2018 pancake, nibble */
#include <stdio.h>
#include <string.h>
@@ -18,13 +18,15 @@ static int disassemble(RAsm *a, RAsmOp *aop, const ut8 *buf, int len) {
static struct DisasmPara_PPC dp;
/* initialize DisasmPara */
memcpy(bof, buf, 4);
memcpy (bof, buf, 4);
dp.opcode = opcode;
dp.operands = operands;
dp.iaddr = &iaddr;
dp.instr = bof;
PPC_Disassemble (&dp, a->big_endian);
snprintf (aop->buf_asm, R_ASM_BUFSIZE, "%s %s", opcode, operands);
char res[64] = {0};
snprintf (res, sizeof (res), "%s %s", opcode, operands);
r_strbuf_set (&aop->buf_asm, res);
aop->size = 4;
return aop->size;
}
@@ -34,14 +36,11 @@ RAsmPlugin r_asm_plugin_ppc_disasm = {
.arch = "ppc",
.bits = 32,
.desc = "Tiny PowerPC disassembly plugin",
.init = NULL,
.fini = NULL,
.disassemble = &disassemble,
.assemble = NULL
};
#ifndef CORELIB
struct r_lib_struct_t radare_plugin = {
RLibStruct radare_plugin = {
.type = R_LIB_TYPE_ASM,
.data = &r_asm_plugin_ppc_disasm,
.version = R2_VERSION
+8 -2
View File
@@ -7,13 +7,19 @@
#include <psosvm/vmas/vmas.h>
static int disassemble(RAsm *a, struct r_asm_op_t *op, const ut8 *buf, int len) {
char buf_asm[64] = {0};
psosvmasm_init();
op->size = psosvm_disasm(buf, op->buf_asm);
op->size = psosvm_disasm(buf, buf_asm);
if (op->size > 0) {
r_asm_op_set_asm (op, buf_asm);
} else {
r_asm_op_set_asm (op, " (data)");
}
return op->size;
}
static int assemble(RAsm *a, RAsmOp *op, const char *buf) {
op->size = psosvm_assemble(op->buf, buf);
op->size = psosvm_assemble((ut8*)r_strbuf_get (&op->buf), buf);
return op->size;
}
+14 -24
View File
@@ -13,7 +13,7 @@
static unsigned long Offset = 0;
static char *buf_global = NULL;
static RStrBuf *buf_global = NULL;
static unsigned char bytes[4];
static int vc4_buffer_read_memory (bfd_vma memaddr, bfd_byte *myaddr, ut32 length, struct disassemble_info *info) {
@@ -30,39 +30,28 @@ static void memory_error_func(int status, bfd_vma memaddr, struct disassemble_in
}
static void print_address(bfd_vma address, struct disassemble_info *info) {
char tmp[32];
if (buf_global == NULL)
return;
snprintf (tmp, sizeof (tmp)-1, "0x%08" PFMT64x, (ut64)address);
strcat (buf_global, tmp);
if (buf_global) {
r_strbuf_appendf (buf_global, "0x%08" PFMT64x, (ut64)address);
}
}
static int buf_fprintf(void *stream, const char *format, ...) {
int flen, glen;
va_list ap;
char *tmp;
if (buf_global == NULL)
if (!buf_global) {
return 0;
}
va_start (ap, format);
flen = strlen (format);
glen = strlen (buf_global);
tmp = malloc (flen + glen + 2);
memcpy (tmp, buf_global, glen);
memcpy (tmp+glen, format, flen);
tmp[flen+glen] = 0;
// XXX: overflow here?
vsprintf (buf_global, tmp, ap);
r_strbuf_vappendf (buf_global, format, ap);
va_end (ap);
free (tmp);
return 0;
}
static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
struct disassemble_info disasm_obj;
op->buf_asm[0]='\0';
if (len<4)
if (len < 4) {
return -1;
buf_global = op->buf_asm;
}
buf_global = &op->buf_asm;
Offset = a->pc;
memcpy (bytes, buf, 4); // TODO handle thumb
@@ -80,8 +69,9 @@ static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
op->size = print_insn_vc4 ((bfd_vma)Offset, &disasm_obj);
if (op->size == -1)
strncpy (op->buf_asm, " (data)", R_ASM_BUFSIZE);
if (op->size == -1) {
r_strbuf_set (&op->buf_asm, " (data)");
}
return op->size;
}
@@ -97,7 +87,7 @@ RAsmPlugin r_asm_plugin_vc4 = {
};
#ifndef CORELIB
struct r_lib_struct_t radare_plugin = {
RLibStruct radare_plugin = {
.type = R_LIB_TYPE_ASM,
.data = &r_asm_plugin_vc4,
.version = R2_VERSION
+1 -1
View File
@@ -24,7 +24,7 @@ static int disassemble(RAsm *a, RAsmOp *aop, const ut8 *buf, int len) {
else disasm_obj.Options = 0;
aop->size = Disasm (&disasm_obj);
snprintf (aop->buf_asm, R_ASM_BUFSIZE, disasm_obj.CompleteInstr);
r_asm_op_set_asm (aop, disasm_obj.CompleteInstr);
return aop->size;
}
+6 -6
View File
@@ -1,4 +1,4 @@
/* radare - LGPL - Copyright 2009-2016 - pancake, nibble */
/* radare - LGPL - Copyright 2009-2018 - pancake, nibble */
#include <stdio.h>
#include <string.h>
@@ -11,8 +11,8 @@
static int disassemble(RAsm *a, RAsmOp *op, const ut8 *buf, int len) {
t_disasm disasm_obj;
op->size = Disasm_olly(buf, len, a->pc, &disasm_obj, DISASM_FILE);
snprintf (op->buf_asm, R_ASM_BUFSIZE, "%s", disasm_obj.result);
op->size = Disasm_olly (buf, len, a->pc, &disasm_obj, DISASM_FILE);
r_asm_op_set_asm (op, disasm_obj.result);
return op->size;
}
@@ -25,7 +25,7 @@ static int assemble(RAsm *a, RAsmOp *op, const char *buf) {
/* constsize == 0: Address constants and inmediate data of 16/32b */
for (constsize = 0; constsize < 4; constsize++) {
for (attempt = 0; ret > 0; attempt++) {
ret = Assemble((char*)buf, a->pc, &asm_obj, attempt, constsize, buf_err);
ret = Assemble ((char*)buf, a->pc, &asm_obj, attempt, constsize, buf_err);
if (ret > 0 && ret < oret) {
oret = ret;
oattempt = attempt;
@@ -35,7 +35,7 @@ static int assemble(RAsm *a, RAsmOp *op, const char *buf) {
}
op->size = R_MAX (0, Assemble ((char*)buf, a->pc, &asm_obj, oattempt, oconstsize, buf_err));
if (op->size > 0) {
memcpy (op->buf, asm_obj.code, R_MIN (R_MIN (16, op->size), sizeof (op->buf)));
r_asm_op_set_buf (op, asm_obj.code, R_MIN (16, op->size));
}
return op->size;
}
@@ -52,7 +52,7 @@ RAsmPlugin r_asm_plugin_x86_olly = {
};
#ifndef CORELIB
struct r_lib_struct_t radare_plugin = {
RLibStruct radare_plugin = {
.type = R_LIB_TYPE_ASM,
.data = &r_asm_plugin_x86_olly,
.version = R2_VERSION
Loaded 100 of 187 files, more files were not shown because too many files have changed in this diff. Show more