Skip to content

Add AArch64 objects with floating-point arguments - #216

Open
zardus wants to merge 2 commits into
masterfrom
feature/aarch64-fp-args
Open

Add AArch64 objects with floating-point arguments#216
zardus wants to merge 2 commits into
masterfrom
feature/aarch64-fp-args

Conversation

@zardus

@zardus zardus commented Aug 29, 2026

Copy link
Copy Markdown
Member

THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS

Problem

Nothing tracked here lets a consumer assert what angr does with an AArch64 floating-point
argument. tests_src/manyfloatsum.c is the repository's own input for that question and
ls tests/*/manyfloatsum returns i386, s390x and x86_64, so the three architectures
angr's run_manyfloatsum covers are all ones whose floating-point arguments share the
integer registers or the stack. No object here takes a homogeneous floating-point aggregate
by value either: the AArch64 aggregate-argument object added in #214 holds Point{long,long},
Big{long x5} and Blob{int[4]}, all integer.

Root cause

AAPCS64 passes floating-point and short-vector arguments in v0-v7, a register file no
other architecture built here uses that way, and an aggregate whose members are all the same
floating-point type is spread one member per register. Neither shape exists in any committed
AArch64 object.

Fix

Two objects, both reproduced byte for byte from the commands recorded with them.
tests/aarch64/manyfloatsum, 13488 bytes, is the existing tests_src/manyfloatsum.c built
with aarch64-unknown-linux-gnu-gcc -O0 -Wl,--dynamic-linker=/lib/ld-linux-aarch64.so.1 -Wl,--build-id=none -Wl,--strip-debug -Wl,-z,max-page-size=4096, then patchelf --remove-rpath. tests/aarch64/hfa_args_aarch64.so, 5872 bytes, is built from
tests_src/arch/aarch64/hfa_args_aarch64.c with the recipe at the top of that source; its
four functions take a two-double aggregate, a three-float aggregate, an aggregate beside an
integer and a double, and an aggregate that arrives one register too late to fit.

Testing

Loading hfa_args_aarch64.so with angr at a9ca247a5 and asking for the argument locations
of take_pair raises TypeError: <SimCCAArch64> doesn't know how to store aggregate type,
and calling sum_floats in manyfloatsum returns a symbolic w0 where the same call on
tests/x86_64/manyfloatsum returns 171.0. The consumer is the angr pull request that links
this one.

Validation: #216 (comment)

session: sharpen

tests/aarch64/manyfloatsum is the existing tests_src/manyfloatsum.c built for
AArch64, which had builds for i386, s390x and x86_64 only.
tests_src/arch/aarch64/hfa_args_aarch64.c is new: its functions take
homogeneous floating-point aggregates, which AAPCS64 spreads one member per
SIMD register.
@zardus

zardus commented Aug 29, 2026

Copy link
Copy Markdown
Member Author

THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS

Validation record for head 7d39a530e025b8632e7ccb81acd9f7b00ed0b981 against baseline a87538bc248531d2a1d22434143e8b9752459bac.

  • Shape scan: ls tests/*/manyfloatsumi386 s390x x86_64 at the baseline, those three plus aarch64 at the head
  • Recipe: both objects rebuilt from the recorded commands in a clean directory and compared byte for byte — identical
  • tests/aarch64/manyfloatsum: ELF64, little endian, DYN (PIE), AArch64, entry 0x740, 13488 bytes, sha256 0812a058cb7db4b9bc941384bf69f8fbd9aa3be856c3aff31e78dd169e8f9d15
  • tests/aarch64/hfa_args_aarch64.so: ELF64, little endian, DYN (shared object), AArch64, 5872 bytes, sha256 5a6c1e78d73e6c6e553d6c9a40ddd54487d52a510ac00c2e40c9ae7d82c1b7e1

Read back with angr at a9ca247a5bcadf0ad8ecccb61be5f76dc4cd5050, which is what the fixtures make assertable:

sum_floats               expected 171.0    got SYMBOLIC
sum_combo                expected 171.0    got 0
sum_segregated           expected 171.0    got 36
sum_doubles              expected 171.0    got SYMBOLIC
sum_combo_doubles        expected 171.0    got 0
sum_segregated_doubles   expected 171.0    got 0
take_pair      expected 3.75  RAISED TypeError: <SimCCAArch64> doesn't know how to store aggregate type <class 'angr.sim_type.SimStruct'>. Consider overriding next_arg to implement its ABI logic
take_triple    expected 7.0  RAISED TypeError: <SimCCAArch64> doesn't know how to store aggregate type <class 'angr.sim_type.SimStruct'>. Consider overriding next_arg to implement its ABI logic
take_mixed     expected 17.5  RAISED TypeError: <SimCCAArch64> doesn't know how to store aggregate type <class 'angr.sim_type.SimStruct'>. Consider overriding next_arg to implement its ABI logic
spill_pair     expected 55.0  RAISED TypeError: <SimCCAArch64> doesn't know how to store aggregate type <class 'angr.sim_type.SimStruct'>. Consider overriding next_arg to implement its ABI logic

Build toolchain: aarch64-unknown-linux-gnu-gcc (GCC) 15.3.0 from the pinned nixpkgs cross stdenv, then patchelf --remove-rpath on both outputs to strip the store paths the wrapper adds.

Caveats: this repository has no executable test suite, so nothing here runs beyond the readback above; the objects are exercised by the angr pull request that links this one.

@zardus

zardus commented Aug 29, 2026

Copy link
Copy Markdown
Member Author

THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS

Both new objects loaded and called through Project.factory.callable, with angr at
a9ca247a5bcadf0ad8ecccb61be5f76dc4cd5050 and then with the angr pull request that links
this one applied. The arguments are the integers 0..18 for manyfloatsum, as
tests/factory/test_callable.py::run_manyfloatsum supplies them, and small exact values for
hfa_args_aarch64.so.

Before — every floating-point argument is laid out on the stack and every aggregate one
raises, so nothing in either object can be asserted:

angr master
angr: repos/angr/angr/__init__.py
arch AARCH64 cc <SimCCAArch64>
sum_floats               expected 171.0    got SYMBOLIC
sum_combo                expected 171.0    got 0
sum_segregated           expected 171.0    got 36
sum_doubles              expected 171.0    got SYMBOLIC
sum_combo_doubles        expected 171.0    got 0
sum_segregated_doubles   expected 171.0    got 0
angr: repos/angr/angr/__init__.py
take_pair      expected 3.75  RAISED TypeError: <SimCCAArch64> doesn't know how to store aggregate type <class 'angr.sim_type.SimStruct'>. Consider overriding next_arg to implement its ABI logic
take_triple    expected 7.0  RAISED TypeError: <SimCCAArch64> doesn't know how to store aggregate type <class 'angr.sim_type.SimStruct'>. Consider overriding next_arg to implement its ABI logic
take_mixed     expected 17.5  RAISED TypeError: <SimCCAArch64> doesn't know how to store aggregate type <class 'angr.sim_type.SimStruct'>. Consider overriding next_arg to implement its ABI logic
spill_pair     expected 55.0  RAISED TypeError: <SimCCAArch64> doesn't know how to store aggregate type <class 'angr.sim_type.SimStruct'>. Consider overriding next_arg to implement its ABI logic

After — every call returns the value the compiled AArch64 code computes:

with the consumer pull request applied
angr: <angr with the consumer change>/angr/__init__.py
arch AARCH64 cc <SimCCAArch64>
sum_floats               expected 171.0    got 171.0
sum_combo                expected 171.0    got 171.0
sum_segregated           expected 171.0    got 171.0
sum_doubles              expected 171.0    got 171.0
sum_combo_doubles        expected 171.0    got 171.0
sum_segregated_doubles   expected 171.0    got 171.0
angr: <angr with the consumer change>/angr/__init__.py
take_pair      expected     3.75 got 3.75  OK
take_triple    expected      7.0 got 7.0  OK
take_mixed     expected     17.5 got 17.5  OK
spill_pair     expected     55.0 got 55.0  OK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant