aboutsummaryrefslogtreecommitdiff
path: root/libgcc/config/epiphany/ieee-754
diff options
context:
space:
mode:
authorQing Zhao <qing.zhao@oracle.com>2025-06-16 21:08:32 +0000
committerQing Zhao <qing.zhao@oracle.com>2025-07-01 20:22:06 +0000
commit9d579c522d551eaa807e438206e19a91a3def67f (patch)
tree446ae52e8ae1114b4940128684af912a0c1d79a9 /libgcc/config/epiphany/ieee-754
parent7165ca43caf47007f5ceaa46c034618d397d42ec (diff)
downloadgcc-master.zip
gcc-master.tar.gz
gcc-master.tar.bz2
Use the counted_by attribute of pointers in array bound checker.HEADtrunkmaster
Current array bound checker only instruments ARRAY_REF, and the INDEX information is the 2nd operand of the ARRAY_REF. When extending the array bound checker to pointer references with counted_by attributes, the hardest part is to get the INDEX of the corresponding array ref from the offset computation expression of the pointer ref. I.e. Given an OFFSET expression, and the ELEMENT_SIZE, get the index expression from the OFFSET. For example: OFFSET: ((long unsigned int) m * (long unsigned int) SAVE_EXPR <n>) * 4 ELEMENT_SIZE: (sizetype) SAVE_EXPR <n> * 4 get the index as (long unsigned int) m. gcc/c-family/ChangeLog: * c-gimplify.cc (is_address_with_access_with_size): New function. (ubsan_walk_array_refs_r): Instrument an INDIRECT_REF whose base address is .ACCESS_WITH_SIZE or an address computation whose base address is .ACCESS_WITH_SIZE. * c-ubsan.cc (ubsan_instrument_bounds_pointer_address): New function. (struct factor_t): New structure. (get_factors_from_mul_expr): New function. (get_index_from_offset): New function. (get_index_from_pointer_addr_expr): New function. (is_instrumentable_pointer_array_address): New function. (ubsan_array_ref_instrumented_p): Change prototype. Handle MEM_REF in addtional to ARRAY_REF. (ubsan_maybe_instrument_array_ref): Handle MEM_REF in addtional to ARRAY_REF. gcc/testsuite/ChangeLog: * gcc.dg/ubsan/pointer-counted-by-bounds-2.c: New test. * gcc.dg/ubsan/pointer-counted-by-bounds-3.c: New test. * gcc.dg/ubsan/pointer-counted-by-bounds-4.c: New test. * gcc.dg/ubsan/pointer-counted-by-bounds-5.c: New test. * gcc.dg/ubsan/pointer-counted-by-bounds.c: New test.
Diffstat (limited to 'libgcc/config/epiphany/ieee-754')
0 files changed, 0 insertions, 0 deletions