Binutils generated sections seem to be padded to a multiple of 16 bytes, but the aux section definition contains the original, unpadded section length.
The size check used for IMAGE_COMDAT_SELECT_SAME_SIZE previously only checked the size of the section itself. When checking the currently processed object file against the previously chosen comdat section, we easily have access to the aux section definition of the currently processed section, but the previously selected (from a different object file) isn't currently available, as far as I can see.
This patch adds the length as a member to SectionChunk, which is a frequently allocated class, and effort has been spent to minimize its size - so this is a step backwards in that regard.
This fixes statically linking clang-built C++ object files against libstdc++ built with GCC, if the object files contain e.g. typeinfo.
I'm tagging Reid here, who has spent effort on minimizing SectionChunk even though I know he's on leave and probably won't comment.
Are there other suggestions on how to achieve the same, without inflating SectionChunk?
We do have access to the SectionChunk for the leader, which gives the ObjFile that defined it, but we'd have to iterate over all symbols in that COFFObjectFile to find the coff_aux_section_definition that matches the SectionChunk. But maybe that's tolerable for the edge case of comdat collisions with IMAGE_COMDAT_SELECT_SAME_SIZE where the section sizes mismatch?