SAFE_BYTE_GET
authorAlan Modra <amodra@gmail.com>
Wed, 12 May 2021 03:21:52 +0000 (12:51 +0930)
committerAlan Modra <amodra@gmail.com>
Wed, 12 May 2021 11:47:35 +0000 (21:17 +0930)
commit6d1ad6f7834d62bedec138aaf3ac872c60702ecd
tree5cc97c318071d405f410fd3c295269811a3a1f1b
parentaf2ddf69ab85add3155cf55f65e6e9f3c9bcb29a
SAFE_BYTE_GET

This rearranges SAFE_BYTE_GET* macros, eliminating some duplication,
and making sure that the _INC variants never increment their PTR arg
past END.  I've added an assertion that should show us places where we
use them improperly with user derived PTR args, which I'm sure the
fuzzers will find for us.

* dwarf.c (SAFE_BYTE_GET_INTERNAL): Define.
(SAFE_BYTE_GET, SAFE_BYTE_GET_AND_INC): Define using the above.
(SAFE_SIGNED_BYTE_GET, SAFE_SIGNED_BYTE_GET_AND_INC): Likewise.
(display_discr_list): Use SAFE_BYTE_GET_AND_INC rather than
SAFE_BYTE_GET followed by increment.
(process_debug_info): Likewise, and test bytes remaining before
incrementing section_begin rather than using pointer comparison.
(display_debug_names): Pass lvalue as SAFE_BYTE_GET PTR.
(process_cu_tu_index): Likewise for SAFE_BYTE_GET_AND_INC.
binutils/ChangeLog
binutils/dwarf.c