Backed out changeset 106a8fb08a87 (bug 1641389) for causing bc failures on browser_pe...
[gecko.git] / build / build-clang / llvmorg-17-init-13415-g57dc16fbe307.patch
blob2e57db2a27544a3e729668a7d6957edfa5b02684
1 From 57dc16fbe3078b4f27e804a2a3a6594e46897c3c Mon Sep 17 00:00:00 2001
2 From: Mike Hommey <mh@glandium.org>
3 Date: Sat, 3 Jun 2023 09:31:42 +0200
4 Subject: [PATCH] [llvm] Strip stabs symbols in Mach-O when stripping debug
5 info
7 ---
8 llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp | 3 +
9 .../MachO/Inputs/strip-stabs.yaml | 248 ++++++++++++++++++
10 .../tools/llvm-objcopy/MachO/strip-stabs.test | 17 ++
11 3 files changed, 268 insertions(+)
12 create mode 100644 llvm/test/tools/llvm-objcopy/MachO/Inputs/strip-stabs.yaml
13 create mode 100644 llvm/test/tools/llvm-objcopy/MachO/strip-stabs.test
15 diff --git a/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp b/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp
16 index d37241682efe..e26b363df21c 100644
17 --- a/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp
18 +++ b/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp
19 @@ -112,6 +112,9 @@ static void updateAndRemoveSymbols(const CommonConfig &Config,
20 if (Config.DiscardMode == DiscardType::All && !(N->n_type & MachO::N_EXT))
21 return true;
22 // This behavior is consistent with cctools' strip.
23 + if (Config.StripDebug && (N->n_type & MachO::N_STAB))
24 + return true;
25 + // This behavior is consistent with cctools' strip.
26 if (MachOConfig.StripSwiftSymbols &&
27 (Obj.Header.Flags & MachO::MH_DYLDLINK) && Obj.SwiftVersion &&
28 *Obj.SwiftVersion && N->isSwiftSymbol())
29 diff --git a/llvm/test/tools/llvm-objcopy/MachO/Inputs/strip-stabs.yaml b/llvm/test/tools/llvm-objcopy/MachO/Inputs/strip-stabs.yaml
30 new file mode 100644
31 index 000000000000..3259aa228fed
32 --- /dev/null
33 +++ b/llvm/test/tools/llvm-objcopy/MachO/Inputs/strip-stabs.yaml
34 @@ -0,0 +1,248 @@
35 +--- !mach-o
36 +FileHeader:
37 + magic: 0xFEEDFACF
38 + cputype: 0x1000007
39 + cpusubtype: 0x80000003
40 + filetype: 0x2
41 + ncmds: 13
42 + sizeofcmds: 808
43 + flags: 0x200085
44 + reserved: 0x0
45 +LoadCommands:
46 + - cmd: LC_SEGMENT_64
47 + cmdsize: 72
48 + segname: __PAGEZERO
49 + vmaddr: 0
50 + vmsize: 4294967296
51 + fileoff: 0
52 + filesize: 0
53 + maxprot: 0
54 + initprot: 0
55 + nsects: 0
56 + flags: 0
57 + - cmd: LC_SEGMENT_64
58 + cmdsize: 312
59 + segname: __TEXT
60 + vmaddr: 4294967296
61 + vmsize: 8192
62 + fileoff: 0
63 + filesize: 8192
64 + maxprot: 5
65 + initprot: 5
66 + nsects: 3
67 + flags: 0
68 + Sections:
69 + - sectname: __text
70 + segname: __TEXT
71 + addr: 0x100000370
72 + size: 8
73 + offset: 0x370
74 + align: 4
75 + reloff: 0x0
76 + nreloc: 0
77 + flags: 0x80000400
78 + reserved1: 0x0
79 + reserved2: 0x0
80 + reserved3: 0x0
81 + content: 554889E531C05DC3
82 + - sectname: __unwind_info
83 + segname: __TEXT
84 + addr: 0x100000378
85 + size: 4152
86 + offset: 0x378
87 + align: 2
88 + reloff: 0x0
89 + nreloc: 0
90 + flags: 0x0
91 + reserved1: 0x0
92 + reserved2: 0x0
93 + reserved3: 0x0
94 + - sectname: __eh_frame
95 + segname: __TEXT
96 + addr: 0x1000013B0
97 + size: 24
98 + offset: 0x13B0
99 + align: 3
100 + reloff: 0x0
101 + nreloc: 0
102 + flags: 0x6000000B
103 + reserved1: 0x0
104 + reserved2: 0x0
105 + reserved3: 0x0
106 + content: 1400000000000000017A520001781001100C070890010000
107 + - cmd: LC_SEGMENT_64
108 + cmdsize: 72
109 + segname: __LINKEDIT
110 + vmaddr: 4294975488
111 + vmsize: 272
112 + fileoff: 8192
113 + filesize: 272
114 + maxprot: 1
115 + initprot: 1
116 + nsects: 0
117 + flags: 0
118 + - cmd: LC_DYLD_INFO_ONLY
119 + cmdsize: 48
120 + rebase_off: 0
121 + rebase_size: 0
122 + bind_off: 0
123 + bind_size: 0
124 + weak_bind_off: 0
125 + weak_bind_size: 0
126 + lazy_bind_off: 0
127 + lazy_bind_size: 0
128 + export_off: 8192
129 + export_size: 48
130 + - cmd: LC_SYMTAB
131 + cmdsize: 24
132 + symoff: 8248
133 + nsyms: 8
134 + stroff: 8376
135 + strsize: 88
136 + - cmd: LC_DYSYMTAB
137 + cmdsize: 80
138 + ilocalsym: 0
139 + nlocalsym: 5
140 + iextdefsym: 5
141 + nextdefsym: 2
142 + iundefsym: 7
143 + nundefsym: 1
144 + tocoff: 0
145 + ntoc: 0
146 + modtaboff: 0
147 + nmodtab: 0
148 + extrefsymoff: 0
149 + nextrefsyms: 0
150 + indirectsymoff: 0
151 + nindirectsyms: 0
152 + extreloff: 0
153 + nextrel: 0
154 + locreloff: 0
155 + nlocrel: 0
156 + - cmd: LC_LOAD_DYLINKER
157 + cmdsize: 32
158 + name: 12
159 + Content: '/usr/lib/dyld'
160 + ZeroPadBytes: 7
161 + - cmd: LC_UUID
162 + cmdsize: 24
163 + uuid: 4C4C44DE-5555-3144-A19D-79B149A02D5F
164 + - cmd: LC_BUILD_VERSION
165 + cmdsize: 32
166 + platform: 1
167 + minos: 852736
168 + sdk: 852736
169 + ntools: 1
170 + Tools:
171 + - tool: 3
172 + version: 1048580
173 + - cmd: LC_MAIN
174 + cmdsize: 24
175 + entryoff: 880
176 + stacksize: 0
177 + - cmd: LC_LOAD_DYLIB
178 + cmdsize: 56
179 + dylib:
180 + name: 24
181 + timestamp: 0
182 + current_version: 86467587
183 + compatibility_version: 65536
184 + Content: '/usr/lib/libSystem.B.dylib'
185 + ZeroPadBytes: 6
186 + - cmd: LC_FUNCTION_STARTS
187 + cmdsize: 16
188 + dataoff: 8240
189 + datasize: 8
190 + - cmd: LC_DATA_IN_CODE
191 + cmdsize: 16
192 + dataoff: 8248
193 + datasize: 0
194 +LinkEditData:
195 + ExportTrie:
196 + TerminalSize: 0
197 + NodeOffset: 0
198 + Name: ''
199 + Flags: 0x0
200 + Address: 0x0
201 + Other: 0x0
202 + ImportName: ''
203 + Children:
204 + - TerminalSize: 0
205 + NodeOffset: 5
206 + Name: _
207 + Flags: 0x0
208 + Address: 0x0
209 + Other: 0x0
210 + ImportName: ''
211 + Children:
212 + - TerminalSize: 3
213 + NodeOffset: 33
214 + Name: main
215 + Flags: 0x0
216 + Address: 0x370
217 + Other: 0x0
218 + ImportName: ''
219 + - TerminalSize: 2
220 + NodeOffset: 38
221 + Name: _mh_execute_header
222 + Flags: 0x0
223 + Address: 0x0
224 + Other: 0x0
225 + ImportName: ''
226 + NameList:
227 + - n_strx: 45
228 + n_type: 0x64
229 + n_sect: 0
230 + n_desc: 0
231 + n_value: 0
232 + - n_strx: 57
233 + n_type: 0x66
234 + n_sect: 3
235 + n_desc: 1
236 + n_value: 0
237 + - n_strx: 76
238 + n_type: 0x24
239 + n_sect: 1
240 + n_desc: 0
241 + n_value: 4294968176
242 + - n_strx: 1
243 + n_type: 0x24
244 + n_sect: 0
245 + n_desc: 0
246 + n_value: 8
247 + - n_strx: 1
248 + n_type: 0x64
249 + n_sect: 1
250 + n_desc: 0
251 + n_value: 0
252 + - n_strx: 2
253 + n_type: 0xF
254 + n_sect: 1
255 + n_desc: 0
256 + n_value: 4294968176
257 + - n_strx: 25
258 + n_type: 0xF
259 + n_sect: 1
260 + n_desc: 16
261 + n_value: 4294967296
262 + - n_strx: 8
263 + n_type: 0x1
264 + n_sect: 0
265 + n_desc: 256
266 + n_value: 0
267 + StringTable:
268 + - ' '
269 + - _main
270 + - dyld_stub_binder
271 + - __mh_execute_header
272 + - '/tmp/test.c'
273 + - '/tmp/test-6aa924.o'
274 + - _main
275 + - ''
276 + - ''
277 + - ''
278 + - ''
279 + - ''
280 + - ''
281 + FunctionStarts: [ 0x370 ]
282 +...
283 diff --git a/llvm/test/tools/llvm-objcopy/MachO/strip-stabs.test b/llvm/test/tools/llvm-objcopy/MachO/strip-stabs.test
284 new file mode 100644
285 index 000000000000..90c00f60a152
286 --- /dev/null
287 +++ b/llvm/test/tools/llvm-objcopy/MachO/strip-stabs.test
288 @@ -0,0 +1,17 @@
289 +## Show that llvm-objcopy/llvm-strip stabs symbols and debug sections.
291 +# RUN: yaml2obj %p/Inputs/strip-stabs.yaml -o %t
293 +# RUN: llvm-objcopy --strip-debug %t %t.stripped
295 +## Make sure that stabs symbols are stripped.
296 +# RUN: llvm-readobj --symbols %t | FileCheck %s --check-prefix=SYM
297 +# RUN: llvm-readobj --symbols %t.stripped | FileCheck %s --check-prefix=SYM_STRIP
299 +# SYM: Symbols [
300 +# SYM-COUNT-5: Type: SymDebugTable ({{.*}})
301 +# SYM: ]
303 +# SYM_STRIP: Symbols [
304 +# SYM_STRIP-NOT: Type: SymDebugTable ({{.*}})
305 +# SYM_STRIP: ]
307 2.41.0.6.ge371d37104