Commit | Line | Data |
---|---|---|
8bd10c10 JL |
1 | From: Stephane Glondu <steph@glondu.net> |
2 | Date: Sun, 16 Aug 2015 20:59:14 +0200 | |
3 | Subject: Add a .file directive to generated .s files | |
4 | ||
5 | When no .file directive is given, the toolchain records the filename | |
6 | of the .o file, which is sometimes random, making generated objects | |
7 | non-deterministic. | |
8 | ||
9 | We use Location.input_name for adding .file directives to assembly | |
10 | files. Note: when the file is preprocessed, this reference holds the | |
11 | name of the temporary file. Hence, files compiled with -pp are still | |
12 | not deterministic. | |
13 | ||
14 | Bug-Debian: https://bugs.debian.org/795784 | |
15 | Bug-Debian: https://bugs.debian.org/796336 | |
16 | --- | |
17 | asmcomp/amd64/emit.mlp | 1 + | |
18 | asmcomp/arm/emit.mlp | 1 + | |
19 | asmcomp/arm64/emit.mlp | 1 + | |
20 | asmcomp/i386/emit.mlp | 1 + | |
21 | asmcomp/power/emit.mlp | 1 + | |
22 | asmcomp/sparc/emit.mlp | 1 + | |
23 | 6 files changed, 6 insertions(+) | |
24 | ||
25 | diff --git a/asmcomp/amd64/emit.mlp b/asmcomp/amd64/emit.mlp | |
26 | index d56d0f5..4d7aa30 100644 | |
27 | --- a/asmcomp/amd64/emit.mlp | |
28 | +++ b/asmcomp/amd64/emit.mlp | |
29 | @@ -794,6 +794,7 @@ let data l = | |
30 | let begin_assembly() = | |
31 | reset_debug_info(); (* PR#5603 *) | |
32 | float_constants := []; | |
33 | + ` .file \"{emit_string (String.escaped !Location.input_name)}\"\n`; | |
34 | if !Clflags.dlcode then begin | |
35 | (* from amd64.S; could emit these constants on demand *) | |
36 | if macosx then | |
37 | diff --git a/asmcomp/arm/emit.mlp b/asmcomp/arm/emit.mlp | |
38 | index 4948fb2..6f30fba 100644 | |
39 | --- a/asmcomp/arm/emit.mlp | |
40 | +++ b/asmcomp/arm/emit.mlp | |
41 | @@ -892,6 +892,7 @@ let data l = | |
42 | ||
43 | let begin_assembly() = | |
44 | reset_debug_info(); | |
45 | + ` .file \"{emit_string (String.escaped !Location.input_name)}\"\n`; | |
46 | ` .syntax unified\n`; | |
47 | begin match !arch with | |
48 | | ARMv4 -> ` .arch armv4t\n` | |
49 | diff --git a/asmcomp/arm64/emit.mlp b/asmcomp/arm64/emit.mlp | |
50 | index 750c2b2..5afbb8a 100644 | |
51 | --- a/asmcomp/arm64/emit.mlp | |
52 | +++ b/asmcomp/arm64/emit.mlp | |
53 | @@ -942,6 +942,7 @@ let data l = | |
54 | ||
55 | let begin_assembly() = | |
56 | reset_debug_info(); | |
57 | + ` .file \"{emit_string (String.escaped !Location.input_name)}\"\n`; | |
58 | let lbl_begin = Compilenv.make_symbol (Some "data_begin") in | |
59 | ` .data\n`; | |
60 | ` .globl {emit_symbol lbl_begin}\n`; | |
61 | diff --git a/asmcomp/i386/emit.mlp b/asmcomp/i386/emit.mlp | |
62 | index 98df5f9..531150f 100644 | |
63 | --- a/asmcomp/i386/emit.mlp | |
64 | +++ b/asmcomp/i386/emit.mlp | |
65 | @@ -986,6 +986,7 @@ let data l = | |
66 | let begin_assembly() = | |
67 | reset_debug_info(); (* PR#5603 *) | |
68 | float_constants := []; | |
69 | + ` .file \"{emit_string (String.escaped !Location.input_name)}\"\n`; | |
70 | let lbl_begin = Compilenv.make_symbol (Some "data_begin") in | |
71 | ` .data\n`; | |
72 | ` .globl {emit_symbol lbl_begin}\n`; | |
73 | diff --git a/asmcomp/power/emit.mlp b/asmcomp/power/emit.mlp | |
74 | index 4344085..343132b 100644 | |
75 | --- a/asmcomp/power/emit.mlp | |
76 | +++ b/asmcomp/power/emit.mlp | |
77 | @@ -887,6 +887,7 @@ let data l = | |
78 | let begin_assembly() = | |
79 | defined_functions := StringSet.empty; | |
80 | external_functions := StringSet.empty; | |
81 | + ` .file \"{emit_string (String.escaped !Location.input_name)}\"\n`; | |
82 | (* Emit the beginning of the segments *) | |
83 | let lbl_begin = Compilenv.make_symbol (Some "data_begin") in | |
84 | emit_string data_space; | |
85 | diff --git a/asmcomp/sparc/emit.mlp b/asmcomp/sparc/emit.mlp | |
86 | index 877a3d5..7b041e9 100644 | |
87 | --- a/asmcomp/sparc/emit.mlp | |
88 | +++ b/asmcomp/sparc/emit.mlp | |
89 | @@ -727,6 +727,7 @@ let data l = | |
90 | (* Beginning / end of an assembly file *) | |
91 | ||
92 | let begin_assembly() = | |
93 | + ` .file \"{emit_string (String.escaped !Location.input_name)}\"\n`; | |
94 | let lbl_begin = Compilenv.make_symbol (Some "data_begin") in | |
95 | ` .data\n`; | |
96 | ` .global {emit_symbol lbl_begin}\n`; |