1
0
mirror of https://github.com/angr/pyvex synced 2026-06-21 13:47:01 +00:00

56 Commits

Author SHA1 Message Date
Brian Caswell 6ef0032cf4 pyvex_c: widen HashHW value slot to ULong (fix 64-bit guest-pointer truncation on 32-bit hosts) (#541)
* pyvex_c: widen HashHW value slot to ULong

HashHW (lifted from libvex/ir_opt.c) caches (IR-temp -> resolved
constant) bindings during data_ref extraction. Values were typed
HWord (= unsigned long, host-pointer-width). On 32-bit hosts that's
4 bytes, but the guest can be 64-bit (AMD64, AArch64), so cached
guest pointers were silently truncated.

Symptom on wasm32-emscripten with an AMD64 guest: pyvex.lift returns
data_addr=0x6320 for a load whose actual target is 0x100006320 (high
32 bits dropped). Native x86-64 SysV hides the bug because long is
64-bit there.

Fix: store HashHW values as ULong unconditionally. Keys are
pyvex-internal IR-temp identifiers and can stay HWord.

Adds tests/test_data_refs_64bit_target.py to lock in the expected
value.

Fixes #539

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* tests: drop archinfo dep, add class docstring

archinfo isn't a pyvex test dependency, so the new test failed to
collect on all CI runners. Use the bundled pyvex.ARCH_AMD64 constant
instead. Also add the class docstring that the ecosystem lint flagged.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Brian Caswell <brian@demoray.net>
2026-05-18 20:03:44 -07:00
pre-commit-ci[bot] 83ea90305b [pre-commit.ci] pre-commit autoupdate (#453)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.9.3 → v0.9.4](https://github.com/astral-sh/ruff-pre-commit/compare/v0.9.3...v0.9.4)
- [github.com/psf/black: 24.10.0 → 25.1.0](https://github.com/psf/black/compare/24.10.0...25.1.0)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-02-03 11:38:16 -07:00
mborgerson a7a6b9925b ARM: Don't rewrite blcc default jumpkind (#441)
* ARM: Don't rewrite blcc default jumpkind

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-12-11 17:11:25 -07:00
pre-commit-ci[bot] add7ccfdf7 [pre-commit.ci] pre-commit autoupdate (#407)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.5.1 → v0.5.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.5.1...v0.5.2)

* Fix ruff errors

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Kevin Phoenix <kevin@kphoenix.us>
2024-07-15 12:59:16 -07:00
pre-commit-ci[bot] 25165e157d [pre-commit.ci] pre-commit autoupdate (#405)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.4.10 → v0.5.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.10...v0.5.0)

* Apply ruff fixes

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Kevin Phoenix <kevin@kphoenix.us>
2024-07-01 13:16:43 -07:00
Audrey Dutcher 0f32e9dbb7 Remove archinfo dependency (#308)
* plugins 2: no more plugins

* homebrew arches

* lint

* I think this is related to thumb mode?

* Remove archinfo from tests

* Remove archinfo from setup.cfg

* Fix fuzzing

* Fix ARM32 -> ARM

* Fix missing closing brace in PyvexArch.__repr__

* Get register offsets directly from vex_ffi

* Fix test cases failures related to little endian instructions

* Resore riscv64le

* Also in __init__.py

* Add subregister map

* Fix another test

* Don't treat rMSR r value as a vex offset, treat it as a register

* Fix remaining failing test cases

* Add some backwards compatibility for register indicies

* Revert _lookup_register to original behaviour

* Fix arch name

* Fix registers with vex_name

* Fix LDM instruction using register numbers

---------

Co-authored-by: Kevin Phoenix <kevin@kphoenix.us>
2023-12-01 17:16:52 -07:00
Kevin Phoenix a1fb2a4d08 Remove full binary test (#346) 2023-08-31 16:11:27 -07:00
Kevin Phoenix b0df47c461 Swap Lifter.lift and Lifter._lift to respect public/private semantics (#344) 2023-08-31 12:50:42 -07:00
Kevin Phoenix 61fb26f223 Rewrite test_tmsr and test_tmsr to not use angr (#345) 2023-08-30 15:25:38 -07:00
Kevin Phoenix 0b5eadd81d Add multiplatform CI (#339)
* Add multiplatform CI

* Checkout vex on windows

* Fix workflow files

* Add pytest-xdist to testing deps

* Skip angr tests if angr is not installed

* Missed one

* Skip resources test on non-linux
2023-08-17 14:57:43 -07:00
pre-commit-ci[bot] 6c2607fddc [pre-commit.ci] pre-commit autoupdate (#297)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/psf/black: 22.12.0 → 23.1.0](https://github.com/psf/black/compare/22.12.0...23.1.0)
- [github.com/charliermarsh/ruff-pre-commit: v0.0.231 → v0.0.241](https://github.com/charliermarsh/ruff-pre-commit/compare/v0.0.231...v0.0.241)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2023-02-06 14:57:17 -07:00
Kevin Phoenix dfd137fc8d Refactor PyVEX to pass lint (#294)
* Refactor PyVEX to pass lint

* Re-add irop_enums_to_ints to pyvex namespace

* Replace log.trace with log.debug

* Register lifters in one place instead of relying on lifter import order

* Fix pylint errors

* Rename lift.py to lift_function.py
2023-02-02 13:55:53 -07:00
Kevin Phoenix 23503e7919 Use black (#291)
* Use black

* Fix the lint error
2023-01-13 14:23:57 -07:00
Eric Gustafson 46049a1498 Add generalized aam and aad instructions for x86 (#178)
* Add spotters for generalized versions of aam/aad

* lint

Co-authored-by: Audrey Dutcher <audrey@rhelmot.io>
2022-05-26 14:47:25 -07:00
Kevin Phoenix a9f4e876e6 Remove future dependency (#270)
* Remove future dependency

* Fix syntax error

* Make linter happy

* Change ignore to disable for pylint
2022-04-05 13:54:32 -07:00
Adersh 20c97ff8b9 remove nose dependencies (#250)
* remove nose dependencies

* resolve lint error

* fix lint errors

* fix lint errors

* fix lint error
2021-12-21 11:55:51 -07:00
Mohit Patil 8cf6a994c3 Diabled auto_load_libs in test_spotter.py (#244) 2021-11-09 20:44:09 -07:00
degrigis 2422f8244f added spotter for tMRS/tMSR (#232)
* added spotter for tMRS/tMSR

* added tmsr/tmrs test case

Signed-off-by: degrigis <degrigis@ucsb.edu>
2021-05-28 18:07:23 -07:00
Audrey Dutcher 372f808843 Fix test_spotter 2021-04-29 14:52:28 -07:00
mephi42 045f7d05c8 s390x: test lifting of vector instructions 2020-01-24 14:48:42 -07:00
mephi42 e7cf6e73d9 Adapt to s390x valgrind update
https://github.com/angr/vex/pull/25
2020-01-24 14:48:42 -07:00
Saullo Carvalho Castelo Branco f2bcfc4025 Remove __future__.print_function 2019-06-08 14:30:49 -07:00
Saullo Carvalho Castelo Branco 48852a6a5c Replace xrange for range 2019-06-08 14:30:49 -07:00
Eric Gustafson 2d81b07b86 Fix another broken CM binary test. 2019-03-29 14:50:37 -07:00
Fish 2f2aa7567a ARM: Add a test case for treating LDMFD SP, {xxx, SP, PC} as ret. (#184) 2019-03-29 14:50:30 -07:00
Audrey Dutcher 67fb4f7c5e Rewire s390x test to not rely on exact output of vex 2018-10-24 00:12:15 -07:00
mephi42 ca1a4b694c Add test/test_s390x_exrl.py
Testcase for https://github.com/angr/vex/pull/20
2018-10-23 20:41:17 -07:00
Audrey Dutcher cb441dcc5b Add test/fixes for max_bytes behavior 2018-10-15 15:14:55 -07:00
Eric Gustafson 98dfa56c77 Purge IRCallee's addr attribute from existence. (#168)
* Purge IRCallee's addr attribute from existence.  It's a pointer into your stack. Why was this even here?

* lint

* burn it to the grouuuuuuuund

* god.
2018-10-10 11:06:21 -07:00
Fish 047ce34638 Fix a corner case in arm_post_processor_determine_calls(). 2018-09-26 20:43:08 -07:00
Eric Gustafson b11a997618 Merge branch 'py3k' into wip/arm_spotter
do the mergey-merge
2018-09-25 14:46:13 -07:00
Audrey Dutcher 479426e9d2 fish. 2018-09-24 12:01:03 -07:00
Fish 18f5e5d754 Fix test cases. 2018-09-24 00:59:51 -07:00
Eric Gustafson f1eaa839e4 Merge branch 'py3k' into wip/arm_spotter
merge latest
2018-09-16 20:22:53 -07:00
Audrey Dutcher e6ae8ec725 *snaps fingers angrily* 2018-09-13 19:16:35 -07:00
Eric Gustafson 7c481187a4 Add a test for some nasty junk from ARMC 2018-08-29 09:53:30 -04:00
Fish 16bca4a915 Implement fallback logic for IRSB.exit_statements. Closes #153. (#154)
.
2018-08-23 23:26:21 -04:00
Fish c9818d9e61 Fix a bug in gymrat where blocks of maximum size are always marked as NoDecode. (#151)
* Fix a bug in gymrat where blocks of maximum size are always marked as NoDecode.

* Fix the test case.
2018-08-17 17:24:20 -07:00
Audrey Dutcher 7a5d7a27bc Fix py3k regressions 2018-07-30 17:17:44 -07:00
Fish 51a4121953 Make lifting faster. (#141)
See https://github.com/angr/angr/pull/1092 for more details.

* The initial commit.

* Redo the lifting logic to avoid redundant IRSB copying.

* Move get_defaultexit_target() from Python to C to speed things up.

* Add a check to make sure LibVEX_Lift() does not return NULL.

* Implement IRSB.instruction_addresses.

* Implement IRSB.has_statements.

* Fix IRSB.addr.

* Fix a NULL-deref in pyvex.c.

* Postprocessor: Do not remove NoOp statements.

Otherwise it will cause a mismatch between statement indices and the
indices in IRSB.exit_statements (which are generated in PyVEX C).

* FixesPostProcessor: Get the IRSB address correctly.

* Remove NoOp statements in the C world.

* Restore the IRSB size calculation.

* Make sure exit_statements is not None before accessing.

* Enable tests for PyVEX itself.

* Implement ARM call jumpkind fixer in C for a better performance.

* Implement MIPS32 post-processing in C world.

* Add a missing undefine.

* Fix test.py.

* Add stddef.h to pyvex.c.

* Implement data reference collection in pyvex_c.

* Lint the code.

* Expose PyVEXError.

* More linting.

* oops

* Expose get_type_size and get_type_spec_size.

* Expose IRTypeEnv.

* Postprocessor: Support NeedStatementsNotification.

* Reorganize lifting/__init__.py.

* Remove the IRSB.addr property, replace with raw attribute

* Make check against MAX_DATA_REFS more explicit

* Move from data ref tuples to a DataRef class

* Lint block.py: Define data_refs and _instruction_addresses in __init__

* Make pyvex.lift positional arguments match pyvex.IRSB

* The kosher way to do this is .lift()

* Split pyvex.c into several smaller C files

(committing as fish to preserve authorship)
2018-07-27 05:45:12 +08:00
Fish a0a5a35edf Lifter: Do not extend a basic block if the lifter intentionally ends it with a NoDecode. (#146)
* Lifter: Do not extend a basic block if the lifter intentionally ends it with a NoDecode.

The rationale behind is that we want to differentiate between NoDecode
that are caused by unsupported instructions and NoDecode caused by
decodeable instructions. For example, `ud2` is a valid instruction on X86
and AMD64, but it means "undefined instruction". On AMD64, VEX will create
a basic block that has an instruction of two bytes (which is the size of
the ud2 instruction), but with the `next` of the basic block pointing to
that instruction. In our existing implementation, we will ignore ud2 and
keep lifting, which is an incorrect behavior.

This commit will detect these intentional NoDecode cases. In such cases,
the Lifter will return a basic block that terminates after the
"undecodeable" instruction, with NoDecode as the jumpkind.

* Add a test case.
2018-07-14 02:01:23 +08:00
Fish 34167b7989 Add {RdTmp,Const}.get_instance(). (#139) 2018-06-30 22:20:36 -07:00
Fish 51f9a8386d ARM post-processing: Mark ldmdb r11, {xxx, pc} as a ret. (#134) 2018-06-23 13:02:36 -07:00
Audrey Dutcher 1a2be78cd8 Swap endians on cortex-m spotter tests 2018-04-26 13:37:02 -07:00
lockshaw 9af0380014 Fix pyvex tests breaking due to ARMEL endness fix 2018-04-21 01:30:40 -07:00
tyb0807 562ccbfc14 Py3k compatible 2018-03-26 18:22:44 -07:00
Fish 9a8fcf21e5 Rename .lift to .lifting to avoid the lift() method shadowing the lift module. (#127)
* Rename .lift to .lifting to avoid the lift() method shadowing the lift module.

* Tidy the code and make future development easier.

- Remove all absolute import of pyvex.
- Remove all absolute import of Python modules that should be relative
  imports.
- Split lifting.__init__.py into separate files.
- Delay an import from angr to avoid circular import.
2018-03-19 23:20:20 -07:00
Nilocunger d44d1f9b20 Fix IRSB property caching (#125)
* Fix IRSB size caching for block extension

* Update to use slots and add test

* Speed up extension cache change
2018-02-27 05:03:43 -08:00
lockshaw 8489511902 Remove unused variable in test 2018-02-25 15:13:46 -08:00
lockshaw a398d63857 Improve performance and remove libvex block concat 2018-02-25 15:13:46 -08:00