[PATCH] D86659: [LLD] [COFF] Check the aux section definition size for IMAGE_COMDAT_SELECT_SAME_SIZE

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 13:32:44 PDT 2020


mstorsjo created this revision.
mstorsjo added reviewers: amccarth, ruiu, rnk, zero9178.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
mstorsjo requested review of this revision.

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?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86659

Files:
  lld/COFF/Chunks.cpp
  lld/COFF/Chunks.h
  lld/COFF/InputFiles.cpp
  lld/COFF/InputFiles.h
  lld/test/COFF/Inputs/comdat-binutils.yaml
  lld/test/COFF/Inputs/comdat-llvm.yaml
  lld/test/COFF/comdat-gcc-compatibility2.test

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86659.288092.patch
Type: text/x-patch
Size: 7065 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200826/117b17a7/attachment.bin>


More information about the llvm-commits mailing list