mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-25 02:25:40 +00:00
baccfef741
Reorder fields mbedtls_ssl_handshake_params in order to save code on Arm Thumb builds. The general idea is to put often-used fields in the direct access window of 128 elements from the beginning of the structure. The reordering is a human selection based on a report of field offset and use counts, and informed by measuring the code size with various arrangements. Some notes: * I moved most byte-sized fields at the beginning where they're sure to be in the direct access window. * I moved buffering earlier because it can be around the threshold depending on the configuration, and it's accessed in a lot of places. * I moved several fields, including update_checksum and friends, early so that they're guaranteed to be in the early access window. * I tried moving randbytes or premaster to the early access window, but I couldn't find a placement which would save code size, presumably because they're bumping too many other fields, and they're mostly accessed through memcpy and friends which translates to instructions that don't have an offset for free anyway. Results (arm-none-eabi-gcc 7.3.1, build_arm_none_eabi_gcc_m0plus build): library/ssl_cli.o: 20200 -> 20104 (diff: 96) library/ssl_msg.o: 25978 -> 25942 (diff: 36) library/ssl_srv.o: 22691 -> 22467 (diff: 224) library/ssl_tls.o: 23570 -> 23390 (diff: 180) Results (same architecture, config-suite-b.h + MBEDTLS_ECDH_LEGACY_CONTEXT + MBEDTLS_ECP_RESTARTABLE): library/ssl_cli.o: 3012 -> 2928 (diff: 84) library/ssl_msg.o: 2932 -> 2924 (diff: 8) library/ssl_srv.o: 3288 -> 3232 (diff: 56) library/ssl_tls.o: 6032 -> 5904 (diff: 128) Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com> |
||
---|---|---|
.. | ||
mbedtls | ||
psa | ||
.gitignore | ||
CMakeLists.txt |