Included is a patch to CGExpr.cpp to allow for trap calls to be generated inline as opposed to one per function. This has
been found to aid in debugging SIGABRTs triggered by integer overflows in variables that do not influence a memory access in
AOSP.
To check the size impact of inlining calls to abort, 57 binaries were selected from AOSP that have integer sanitization turned on.
The system was compiled with default options for a 32-bit build (shamu) and a 64-bit build (angler). The resulting build has been tested
on a Nexus 6 (shamu) device with no stability issues.
For the 32-bit build, the average file increase was 3.43%. The greatest size increase was 33.88% (libstagefright_m4vh263enc.a, 934630 to 1251270),
and one file actually became slightly smaller libstagefright_timedtext.a, from 750214 to 749886.
For the 64-bit build, the average file increase was 5.35%. The greatest size increase was 41.86% (libstagefright_m4vh263enc.a, 1288622 to 1828030).
Four files were slightly smaller:
init: 1269536 to 1257248
libfs_mgr.a: 262288 to 258776
libinit.a: 4442000 to 4326804
libstagefright_timedtext.a: 892450 to 890250
As for generated code, a function known to have multiple integer overflows, search_ixiy in libstagefright_amrwbenc.so was analyzed
in more depth. The function has 6 calls to abort, all of which are generated inline with the patched compiler. The original 32 bit
version is 536 bytes in size, while the inline abort version is 656. The original 64 bit version is 544, while the inline abort version is 648.
I am happy to provide more detail or perform additional analysis if it helps. From what I've gathered so far, this may not be the best option to enable
by default, but as a debug option, it would be very valuable to anyone developing with the sanitizer.
Note that this will also affect -ftrapv, which might be unexpected, as we mention "sanitize" in the flag name.