[lld] [lld][COFF] Fix: Merge `.drectve` sections in ObjFile::readSections (PR #86380)

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 25 01:48:19 PDT 2024


================

----------------
mstorsjo wrote:

Coalescing multiple sections of the same type is the standard behaviour for the assembler in these cases. However if there are e.g. comdat sections involved, each of them are kept separate. See e.g. 503bc5f66111f7e4fc79972bb9bfec8bb5606bab for a testcase which adds such a section.

And I wouldn't argue that `llvm-mc` is wrong to coalesce them this way - this is the standard behaviour that is done for all sections. And for other sections (in particular, the `.text` sections), the assembler would be very wrong if it would start injecting some spacing between such snippets. It's totally valid to do e.g. `.text ; instr1; instr2; .data; <define some data>; .text; instr3; instr4`, and one can expect that instr3 follows directly after instr2.

So if there are multiple `.drectve` sections like this, it is up to who generates them to make sure there is proper separation at the end (ending each of them with a space or a null byte or similar). I didn't check your implementation here, but it needs to be able to handle strings separated by null bytes, e.g. as emitted by `.asciz` in 503bc5f66111f7e4fc79972bb9bfec8bb5606bab.

https://github.com/llvm/llvm-project/pull/86380


More information about the llvm-commits mailing list