Page MenuHomePhabricator

Fix a crash with assembler source and -g.

Authored by probinson on Jun 19 2019, 2:24 PM.



llvm-mc or clang with -g normally produces debug info describing the
assembler source itself; however, if that source already contains some
.file/.loc directives, we should instead emit the debug info described
by those directives. For certain assembler sources seen in the wild
(particularly in the Chrome build) this was causing a crash due to
incorrect assumptions about legal sequences of assembler source text.

Fixes PR38994.

Diff Detail

Event Timeline

probinson created this revision.Jun 19 2019, 2:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 19 2019, 2:24 PM

We do not precisely match gcc/gas behavior in some more-peculiar cases, but my assertion is that those should not occur "naturally" and so it's okay. For example:

    .file 1 "a.c"

This will cause gcc/gas to emit an error to the effect that file number 1 is already defined (implicitly, because of the line-table record for the first instruction). Clang/llvm-mc will not, we'll just emit an odd-looking line table. I can see how to cause clang/llvm-mc to emit this error, but it feels like it would be a hack done just to match gcc's (likely unintentional) error-detection behavior for an ill-formed assembler file.

dblaikie accepted this revision.Jun 20 2019, 3:04 PM

Sounds alright to me

This revision is now accepted and ready to land.Jun 20 2019, 3:04 PM
This revision was automatically updated to reflect the committed changes.