diff options
author | Alan Modra <amodra@gmail.com> | 2022-02-15 20:11:03 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2022-02-16 22:05:10 +1030 |
commit | 1f9b1a84350d3755ce8620900a35c3d1997535e6 (patch) | |
tree | faf43bbd8090ba94d17758ac78e56dee925253a5 /gas/expr.c | |
parent | 6e731729881ae4c1a9542843c29a3981166c9e45 (diff) | |
download | gdb-1f9b1a84350d3755ce8620900a35c3d1997535e6.zip gdb-1f9b1a84350d3755ce8620900a35c3d1997535e6.tar.gz gdb-1f9b1a84350d3755ce8620900a35c3d1997535e6.tar.bz2 |
What to do when sh_addralign isn't a power of two
BFD generally doesn't handle anything but a power of two section
alignment, and ELF sh_addralign is required to be an integral power of
two (or zero) by the ELF spec. Of course this is ignored by fuzzers,
and because bfd_log2 rounds up, we can end up with alignment_power
being 32 on a 32-bit object or 64 on a 64-bit object. That then
triggers ubsan warnings in places like bfd_update_compression_header
where we want to convert from alignment_power back to an alignment.
I suppose we could reject object files that have non-compliant
sh_addralign, but I think it's also reasonable to use the greatest
power of two divisor of sh_addralign, ie. the rightmost 1 bit.
* elf.c (_bfd_elf_make_section_from_shdr): Use greatest power
of two divisor of sh_addralign.
(_bfd_elf_assign_file_position_for_section): Likewise.
(assign_file_positions_for_non_load_sections): Likewise.
Diffstat (limited to 'gas/expr.c')
0 files changed, 0 insertions, 0 deletions