Add a .file directive to generated .s files
authorStephane Glondu <steph@glondu.net>
Sun, 16 Aug 2015 18:59:14 +0000 (20:59 +0200)
committerMehdi Dogguy <mehdi@debian.org>
Sun, 6 Nov 2016 10:29:41 +0000 (10:29 +0000)
When no .file directive is given, the toolchain records the filename
of the .o file, which is sometimes random, making generated objects
non-deterministic.

We use Location.input_name for adding .file directives to assembly
files. Note: when the file is preprocessed, this reference holds the
name of the temporary file. Hence, files compiled with -pp are still
not deterministic.

Bug-Debian: https://bugs.debian.org/795784
Bug-Debian: https://bugs.debian.org/796336

Gbp-Pq: Name 0010-Add-a-.file-directive-to-generated-.s-files.patch

asmcomp/amd64/emit.mlp
asmcomp/arm/emit.mlp
asmcomp/arm64/emit.mlp
asmcomp/i386/emit.mlp
asmcomp/power/emit.mlp
asmcomp/sparc/emit.mlp

index d56d0f5f2e15347267d377ae0ece60b9cc77b594..4d7aa3020f67c1f55c2a855911b19fe922c9a720 100644 (file)
@@ -794,6 +794,7 @@ let data l =
 let begin_assembly() =
   reset_debug_info();                   (* PR#5603 *)
   float_constants := [];
+  `    .file \"{emit_string (String.escaped !Location.input_name)}\"\n`;
   if !Clflags.dlcode then begin
     (* from amd64.S; could emit these constants on demand *)
     if macosx then
index 4948fb2b1b1a646e172438dc013c461676992138..6f30fba6ea5d29f46e2c8eda2d324daf010511c5 100644 (file)
@@ -892,6 +892,7 @@ let data l =
 
 let begin_assembly() =
   reset_debug_info();
+  `    .file \"{emit_string (String.escaped !Location.input_name)}\"\n`;
   `    .syntax unified\n`;
   begin match !arch with
   | ARMv4   -> `       .arch   armv4t\n`
index 750c2b2379ddef61cd5ffe71a11107520af94b10..5afbb8a40cb79047c7627e012edf5fe3d0f706de 100644 (file)
@@ -942,6 +942,7 @@ let data l =
 
 let begin_assembly() =
   reset_debug_info();
+  `    .file \"{emit_string (String.escaped !Location.input_name)}\"\n`;
   let lbl_begin = Compilenv.make_symbol (Some "data_begin") in
   `    .data\n`;
   `    .globl  {emit_symbol lbl_begin}\n`;
index 98df5f958ba9bc5bc60beb5662a4f35a47e22523..531150fc5ce0f078a9aab224bce6024127eacc1a 100644 (file)
@@ -986,6 +986,7 @@ let data l =
 let begin_assembly() =
   reset_debug_info();                   (* PR#5603 *)
   float_constants := [];
+  `    .file \"{emit_string (String.escaped !Location.input_name)}\"\n`;
   let lbl_begin = Compilenv.make_symbol (Some "data_begin") in
   `    .data\n`;
   `    .globl  {emit_symbol lbl_begin}\n`;
index 434408524dbb69d0a9d1087ec65cd677b05e22b3..343132bba1dc70e75f0649ce45e10b76d59499f1 100644 (file)
@@ -887,6 +887,7 @@ let data l =
 let begin_assembly() =
   defined_functions := StringSet.empty;
   external_functions := StringSet.empty;
+  `    .file \"{emit_string (String.escaped !Location.input_name)}\"\n`;
   (* Emit the beginning of the segments *)
   let lbl_begin = Compilenv.make_symbol (Some "data_begin") in
   emit_string data_space;
index 877a3d52a029c12c2b5094949c8c44270a24a03a..7b041e9c2b1f4228d3d789d5fb6cefbc21d0484c 100644 (file)
@@ -727,6 +727,7 @@ let data l =
 (* Beginning / end of an assembly file *)
 
 let begin_assembly() =
+  `    .file \"{emit_string (String.escaped !Location.input_name)}\"\n`;
   let lbl_begin = Compilenv.make_symbol (Some "data_begin") in
   `    .data\n`;
   `    .global {emit_symbol lbl_begin}\n`;