String literals in asm files: use asm quoting conventions, not OCaml's#588
Open
xavierleroy wants to merge 1 commit into
Open
String literals in asm files: use asm quoting conventions, not OCaml's#588xavierleroy wants to merge 1 commit into
xavierleroy wants to merge 1 commit into
Conversation
Currently, we use the `%S` format of Printf.printf to emit some string literals in assembly files: filenames in `.file` directives, and `.asciz` directives for DWARF debug information. (String literals coming from C source files follow a different path that doesn't use `%S`. They are not affected by the problem fixed in this commit.) The `%S` format produces an OCaml string literal, which can be misinterpreted by the GNU and Diab assemblers. In particular, OCaml uses decimal escapes `\ddd` (three decimal digits) while assemblers, like C, use octal escapes `\ooo` (three octal digits). Consequently, a "vertical tab" character (ASCII 0x0B) is printed as `\011`, which is interpreted as "horizontal tab" (ASCII 0x09) by the assembler. This commits introduces `PrintAsmaux.quote_string` to produce a string literal in asm / C syntax, with octal escape sequences, and uses it in assembler printers in place of `%S`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, we use the
%Sformat ofPrintf.printfto emit some string literals in assembly files: filenames in.filedirectives, and.ascizdirectives for DWARF debug information.(String literals coming from C source files follow a different path that doesn't use
%S. They are not affected by the problem fixed in this commit.)The
%Sformat produces an OCaml string literal, which can be misinterpreted by the GNU and Diab assemblers. In particular, OCaml uses decimal escapes\ddd(three decimal digits) while assemblers, like C, use octal escapes\ooo(three octal digits). Consequently, a "vertical tab" character (ASCII 0x0B) is printed as\011, which is interpreted as "horizontal tab" (ASCII 0x09) by the assembler.This commits introduces
PrintAsmaux.quote_stringto produce a string literal in asm / C syntax, with octal escape sequences, and uses it in assembler printers in place of%S.