PR28691, validate dwarf attribute form
authorAlan Modra <amodra@gmail.com>
Wed, 15 Dec 2021 04:36:26 +0000 (15:06 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 15 Dec 2021 22:27:57 +0000 (08:57 +1030)
commit161cdabc3927b144ffcff9bf7b1daf5fe32a193c
treedbcaf1c769b02d45f1b1974aa6f6252d4c6c4bfd
parent261b07488b9dfe69090e6980f6de9d0f4f3f03ca
PR28691, validate dwarf attribute form

PR28691 is a fuzzing PR that triggers a non-problem of "output changes
per run" with PIEs and/or different compilers.  I've closed similar
PRs before as wontfix, but I guess there will be no end of this type
of PR.  The trigger is an attribute that usually takes one of the
offset/constant reference DW_FORMs being given an indexed string
DW_FORM.  The bfd reader doesn't support indexed strings and returns
an error string instead.  The address of the string varies with PIE
runs and/or compiler, and we allow that address to appear in output.
Fix this by validating integer attribute forms, as we do for string
form attributes.

PR 28691
* dwarf2.c (is_str_attr): Rename to..
(is_str_form): ..this.  Change param type.  Update calls.
(is_int_form): New function.
(read_attribute_value): Handle DW_FORM_addrx2.
(find_abstract_instance): Validate form when using attr.u.val.
(scan_unit_for_symbols, parse_comp_unit): Likewise.
bfd/dwarf2.c