]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - bfd/coffcode.h
COFF swap_aux_in
authorAlan Modra <amodra@gmail.com>
Mon, 28 Aug 2023 11:37:52 +0000 (21:07 +0930)
committerAlan Modra <amodra@gmail.com>
Mon, 28 Aug 2023 13:40:57 +0000 (23:10 +0930)
commitdaafebb58dac3de93ac4696dd334530b762ed67f
tree24baa1ec2258e5751a1beb2d0c26fe2664a45063
parent54d57acf610e5db2e70afa234fd4018207606774
COFF swap_aux_in

A low level function like coff_swap_aux_in really has no business
concatenating multiple auxents for the old PE multi-aux scheme of
handling long file names.  In doing so, it assumes multiple internal
auxent buffers are available, which they are not in most calls to
bfd_coff_swap_aux_in, both inside BFD and outside, eg. GDB.  Buffer
overflow fun.  Concatenating multiple auxents belongs at a higher
level.

This required some changes to coff_get_normalized_symtab, which now
uses the external auxents to access the concatenated file name.
(Internal auxents are larger than the x_fname array, so the pieces of
the file name are not adjacent as they are in the external auxents.)

* coffswap.h (coff_swap_aux_in): Do not write more than one
internal auxent.
* coffcode.h (coff_bigobj_swap_aux_in): Likewise.
* coffgen.c (coff_get_normalized_symtab): Normalize strings
after swapping in each symbol so that external auxents are
available.  Use external auxents for multi-aux long file
names.  Formatting.  Wrap long lines.  Remove excess parens
and unnecessary casts.  Don't zalloc when only the string
terminator needs zeroing, and memcpy rather than strncpy.
Delete unnecessary sanity check with unsigned _n_offset.
Return with failure if debug section can't be read, to avoid
trying to read it multiple times.  Correct sanity check
against debug section size.
bfd/coffcode.h
bfd/coffgen.c
bfd/coffswap.h