Bug 1885602 - Part 1: Add strings for the sign in header in the menu redesign r=andro...
[gecko.git] / build / build-clang / revert-llvmorg-18-init-6188-gc649f29c24c9.patch
blob290c65f4b5567d5972c731e490c4fcc13927f62c
1 From c3994286d37f4273d6d7a4cb578828d64a25a341 Mon Sep 17 00:00:00 2001
2 From: Mike Hommey <mh@glandium.org>
3 Date: Wed, 20 Sep 2023 10:08:22 +0900
4 Subject: [PATCH 3/3] Revert "[llvm-nm] Add --line-numbers flag"
6 This reverts commit c649f29c24c9fc1502d8d53e0c96c3d24b31de1a because it
7 depends on cead4eceb01b935fae07bf4a7e91911b344d2fec, which we revert.
8 ---
9 llvm/docs/CommandGuide/llvm-nm.rst | 6 -
10 llvm/test/tools/llvm-nm/X86/line-numbers.test | 240 ------------------
11 llvm/tools/llvm-nm/CMakeLists.txt | 1 -
12 llvm/tools/llvm-nm/Opts.td | 2 -
13 llvm/tools/llvm-nm/llvm-nm.cpp | 92 +------
14 6 files changed, 5 insertions(+), 339 deletions(-)
15 delete mode 100644 llvm/test/tools/llvm-nm/X86/line-numbers.test
17 diff --git a/llvm/docs/CommandGuide/llvm-nm.rst b/llvm/docs/CommandGuide/llvm-nm.rst
18 index 7067bb0a29a1..4b1290a15665 100644
19 --- a/llvm/docs/CommandGuide/llvm-nm.rst
20 +++ b/llvm/docs/CommandGuide/llvm-nm.rst
21 @@ -190,12 +190,6 @@ OPTIONS
23 Print just the symbol names. Alias for `--format=just-symbols``.
25 -.. option:: --line-numbers, -l
27 - Use debugging information to print the filenames and line numbers where
28 - symbols are defined. Undefined symbols have the location of their first
29 - relocation printed instead.
31 .. option:: -m
33 Use Darwin format. Alias for ``--format=darwin``.
34 diff --git a/llvm/test/tools/llvm-nm/X86/line-numbers.test b/llvm/test/tools/llvm-nm/X86/line-numbers.test
35 deleted file mode 100644
36 index 4b9817ab5c62..000000000000
37 --- a/llvm/test/tools/llvm-nm/X86/line-numbers.test
38 +++ /dev/null
39 @@ -1,240 +0,0 @@
40 -## Check that printing line numbers isn't attempted for files like bitcode,
41 -## which have symbols but limited/no section or debug info.
42 -# RUN: llvm-nm --line-numbers %p/Inputs/test.IRobj-x86_64 | FileCheck %s --check-prefix=BITCODE --match-full-lines --implicit-check-not={{.}}
43 -# BITCODE: ---------------- S _global_const
44 -# BITCODE-NEXT: ---------------- D _global_data
45 -# BITCODE-NEXT: ---------------- T _global_func
46 -# BITCODE-NEXT: ---------------- S _hidden_const
47 -# BITCODE-NEXT: ---------------- D _hidden_data
48 -# BITCODE-NEXT: ---------------- T _hidden_func
49 -# BITCODE-NEXT: ---------------- s _static_const
50 -# BITCODE-NEXT: ---------------- d _static_data
51 -# BITCODE-NEXT: ---------------- t _static_func
53 -## Check that various symbol types can use debug information if available to
54 -## print line numbers, and if unavailable, don't print anything erroneous. The
55 -## specific cases checked are given by the symbol names below. Other test cases
56 -## place requirements on the contents of the whole file, so they are kept out
57 -## of main.o.
58 -# RUN: rm -rf %t
59 -# RUN: split-file %s %t
60 -# RUN: llvm-mc -g --filetype=obj %t/main.s -o %t/main.o
61 -# RUN: llvm-nm -l %t/main.o | FileCheck %s --match-full-lines --implicit-check-not={{.}}
62 -# RUN: llvm-nm --line-numbers %t/main.o | FileCheck %s --match-full-lines --implicit-check-not={{.}}
64 -# CHECK: 0000000000001234 a absolute_symbol
65 -# CHECK-NEXT: 0000000000000000 d data_no_dwarf
66 -# CHECK-NEXT: 0000000000000000 T defined_global_function [[FILENAME:.*main.s]]:4
67 -# CHECK-NEXT: 0000000000000001 t defined_local_function [[FILENAME]]:7
68 -# CHECK-NEXT: 0000000000000000 t function_no_dwarf
69 -# CHECK-NEXT: U undef1 [[FILENAME]]:12
70 -# CHECK-NEXT: U undef2 [[FILENAME]]:14
71 -# CHECK-NEXT: U undef_no_reloc
72 -# CHECK-NEXT: 0000000000000002 t undefined_references [[FILENAME]]:12
74 -## Check that in the absence of DWARF in the whole object, no line number
75 -## information is printed.
76 -# RUN: llvm-mc --filetype=obj %t/main.s -o %t/no-dwarf.o
77 -# RUN: llvm-nm -l %t/no-dwarf.o | FileCheck %s --check-prefix=NO-DWARF --match-full-lines --implicit-check-not={{.}}
79 -# NO-DWARF: 0000000000001234 a absolute_symbol
80 -# NO-DWARF-NEXT: 0000000000000000 d data_no_dwarf
81 -# NO-DWARF-NEXT: 0000000000000000 T defined_global_function
82 -# NO-DWARF-NEXT: 0000000000000001 t defined_local_function
83 -# NO-DWARF-NEXT: 0000000000000000 t function_no_dwarf
84 -# NO-DWARF-NEXT: U undef1
85 -# NO-DWARF-NEXT: U undef2
86 -# NO-DWARF-NEXT: U undef_no_reloc
87 -# NO-DWARF-NEXT: 0000000000000002 t undefined_references
89 -## Check that printing line numbers for undefined values is not attempted in
90 -## the absence of any relocation section.
91 -# RUN: llvm-mc --filetype=obj %t/undef-no-reloc-sections.s -o %t/undef-no-reloc-sections.o
92 -# RUN: llvm-nm --line-numbers %t/undef-no-reloc-sections.o | FileCheck %s --check-prefix=UNDEF-NO-RELOC-SECTIONS --match-full-lines --implicit-check-not={{.}}
94 -# UNDEF-NO-RELOC-SECTIONS: U undef
96 -## Check that printing line numbers for undefined values does not include
97 -## relocations for non-text sections. This is broken out of main.s to ensure
98 -## that the data relocation for undef comes first.
99 -# RUN: llvm-mc -g --filetype=obj %t/undef-data-reloc.s -o %t/undef-data-reloc.o
100 -# RUN: llvm-nm --line-numbers %t/undef-data-reloc.o | FileCheck %s --check-prefix=UNDEF-DATA-RELOC --match-full-lines --implicit-check-not={{.}}
102 -# UNDEF-DATA-RELOC: 0000000000000000 r data_reloc
103 -# UNDEF-DATA-RELOC-NEXT: U undef
105 -## Check that line numbers can be printed for data definitions. These are broken
106 -## out of main.s since their DWARF cannot be generated with llvm-mc -g.
107 -# RUN: llvm-mc -g --filetype=obj %t/data-dwarf.s -o %t/data-dwarf.o
108 -# RUN: llvm-nm --line-numbers %t/data-dwarf.o | FileCheck %s --check-prefix=DATA-DWARF --match-full-lines --implicit-check-not={{.}}
110 -# DATA-DWARF: 0000000000000000 D defined_data /tmp/tmp.c:1
112 -#--- main.s
113 -.text
114 -.globl defined_global_function
115 -defined_global_function:
116 - ret
118 -defined_local_function:
119 - ret
121 -absolute_symbol = 0x1234
123 -undefined_references:
124 - nop
125 - .long undef1
126 - nop
127 - .long undef2
128 - ret
130 -# Note: llvm-mc -g produces no DWARF for data.
131 -.data
132 -data_no_dwarf:
133 - .byte 0
135 -.globl undef_no_reloc
137 -# Note: llvm-mc -g does not produce DWARF for non-SHF_ALLOC sections.
138 -.section no_alloc_text,"x",@progbits
139 -function_no_dwarf:
140 - ret
142 -#--- undef-no-reloc-sections.s
143 -.globl undef
145 -#--- undef-data-reloc.s
146 -.globl undef
147 -.rodata
148 -data_reloc:
149 - .long undef
151 -#--- data-dwarf.s
152 -# char defined_data = 42
153 - .text
154 - .file "tmp.c"
155 - .file 0 "/tmp" "/tmp/tmp.c" md5 0x39602a53b15a32d6a622ca86936e88d7
156 - .file 1 "tmp.c" md5 0x39602a53b15a32d6a622ca86936e88d7
157 - .type defined_data,@object # @defined_data
158 - .data
159 - .globl defined_data
160 -defined_data:
161 - .byte 42 # 0x2a
162 - .size defined_data, 1
164 - .section .debug_abbrev,"",@progbits
165 - .byte 1 # Abbreviation Code
166 - .byte 17 # DW_TAG_compile_unit
167 - .byte 1 # DW_CHILDREN_yes
168 - .byte 37 # DW_AT_producer
169 - .byte 37 # DW_FORM_strx1
170 - .byte 19 # DW_AT_language
171 - .byte 5 # DW_FORM_data2
172 - .byte 3 # DW_AT_name
173 - .byte 37 # DW_FORM_strx1
174 - .byte 114 # DW_AT_str_offsets_base
175 - .byte 23 # DW_FORM_sec_offset
176 - .byte 16 # DW_AT_stmt_list
177 - .byte 23 # DW_FORM_sec_offset
178 - .byte 27 # DW_AT_comp_dir
179 - .byte 37 # DW_FORM_strx1
180 - .byte 115 # DW_AT_addr_base
181 - .byte 23 # DW_FORM_sec_offset
182 - .byte 0 # EOM(1)
183 - .byte 0 # EOM(2)
184 - .byte 2 # Abbreviation Code
185 - .byte 52 # DW_TAG_variable
186 - .byte 0 # DW_CHILDREN_no
187 - .byte 3 # DW_AT_name
188 - .byte 37 # DW_FORM_strx1
189 - .byte 73 # DW_AT_type
190 - .byte 19 # DW_FORM_ref4
191 - .byte 63 # DW_AT_external
192 - .byte 25 # DW_FORM_flag_present
193 - .byte 58 # DW_AT_decl_file
194 - .byte 11 # DW_FORM_data1
195 - .byte 59 # DW_AT_decl_line
196 - .byte 11 # DW_FORM_data1
197 - .byte 2 # DW_AT_location
198 - .byte 24 # DW_FORM_exprloc
199 - .byte 0 # EOM(1)
200 - .byte 0 # EOM(2)
201 - .byte 3 # Abbreviation Code
202 - .byte 36 # DW_TAG_base_type
203 - .byte 0 # DW_CHILDREN_no
204 - .byte 3 # DW_AT_name
205 - .byte 37 # DW_FORM_strx1
206 - .byte 62 # DW_AT_encoding
207 - .byte 11 # DW_FORM_data1
208 - .byte 11 # DW_AT_byte_size
209 - .byte 11 # DW_FORM_data1
210 - .byte 0 # EOM(1)
211 - .byte 0 # EOM(2)
212 - .byte 0 # EOM(3)
213 - .section .debug_info,"",@progbits
214 -.Lcu_begin0:
215 - .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
216 -.Ldebug_info_start0:
217 - .short 5 # DWARF version number
218 - .byte 1 # DWARF Unit Type
219 - .byte 8 # Address Size (in bytes)
220 - .long .debug_abbrev # Offset Into Abbrev. Section
221 - .byte 1 # Abbrev [1] 0xc:0x22 DW_TAG_compile_unit
222 - .byte 0 # DW_AT_producer
223 - .short 12 # DW_AT_language
224 - .byte 1 # DW_AT_name
225 - .long .Lstr_offsets_base0 # DW_AT_str_offsets_base
226 - .long .Lline_table_start0 # DW_AT_stmt_list
227 - .byte 2 # DW_AT_comp_dir
228 - .long .Laddr_table_base0 # DW_AT_addr_base
229 - .byte 2 # Abbrev [2] 0x1e:0xb DW_TAG_variable
230 - .byte 3 # DW_AT_name
231 - .long 41 # DW_AT_type
232 - # DW_AT_external
233 - .byte 1 # DW_AT_decl_file
234 - .byte 1 # DW_AT_decl_line
235 - .byte 2 # DW_AT_location
236 - .byte 161
237 - .byte 0
238 - .byte 3 # Abbrev [3] 0x29:0x4 DW_TAG_base_type
239 - .byte 4 # DW_AT_name
240 - .byte 6 # DW_AT_encoding
241 - .byte 1 # DW_AT_byte_size
242 - .byte 0 # End Of Children Mark
243 -.Ldebug_info_end0:
244 - .section .debug_str_offsets,"",@progbits
245 - .long 24 # Length of String Offsets Set
246 - .short 5
247 - .short 0
248 -.Lstr_offsets_base0:
249 - .section .debug_str,"MS",@progbits,1
250 -.Linfo_string0:
251 - .asciz "Debian clang version 14.0.6" # string offset=0
252 -.Linfo_string1:
253 - .asciz "/tmp/tmp.c" # string offset=28
254 -.Linfo_string2:
255 - .asciz "/tmp" # string offset=39
256 -.Linfo_string3:
257 - .asciz "defined_data" # string offset=44
258 -.Linfo_string4:
259 - .asciz "char" # string offset=57
260 - .section .debug_str_offsets,"",@progbits
261 - .long .Linfo_string0
262 - .long .Linfo_string1
263 - .long .Linfo_string2
264 - .long .Linfo_string3
265 - .long .Linfo_string4
266 - .section .debug_addr,"",@progbits
267 - .long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution
268 -.Ldebug_addr_start0:
269 - .short 5 # DWARF version number
270 - .byte 8 # Address size
271 - .byte 0 # Segment selector size
272 -.Laddr_table_base0:
273 - .quad defined_data
274 -.Ldebug_addr_end0:
275 - .ident "Debian clang version 14.0.6"
276 - .section ".note.GNU-stack","",@progbits
277 - .addrsig
278 - .section .debug_line,"",@progbits
279 -.Lline_table_start0:
280 diff --git a/llvm/tools/llvm-nm/CMakeLists.txt b/llvm/tools/llvm-nm/CMakeLists.txt
281 index 5191e138d1c0..ec04f1e9d234 100644
282 --- a/llvm/tools/llvm-nm/CMakeLists.txt
283 +++ b/llvm/tools/llvm-nm/CMakeLists.txt
284 @@ -8,7 +8,6 @@ set(LLVM_LINK_COMPONENTS
285 Object
286 Option
287 Support
288 - Symbolize
289 TargetParser
290 TextAPI
292 diff --git a/llvm/tools/llvm-nm/Opts.td b/llvm/tools/llvm-nm/Opts.td
293 index 04d9f5db5cf8..60ac134269b3 100644
294 --- a/llvm/tools/llvm-nm/Opts.td
295 +++ b/llvm/tools/llvm-nm/Opts.td
296 @@ -22,7 +22,6 @@ def export_symbols : FF<"export-symbols", "Export symbol list for all inputs">;
297 def extern_only : FF<"extern-only", "Show only external symbols">;
298 defm format : Eq<"format", "Specify output format: bsd (default), posix, sysv, darwin, just-symbols">, MetaVarName<"<format>">;
299 def help : FF<"help", "Display this help">;
300 -def line_numbers : FF<"line-numbers", "Use debugging information to print symbols' filenames and line numbers">;
301 def no_llvm_bc : FF<"no-llvm-bc", "Disable LLVM bitcode reader">;
302 def no_sort : FF<"no-sort", "Show symbols in order encountered">;
303 def no_weak : FF<"no-weak", "Show only non-weak symbols">;
304 @@ -68,7 +67,6 @@ def : JoinedOrSeparate<["-"], "f">, HelpText<"Alias for --format">, Alias<format
305 def : F<"h", "Alias for --help">, Alias<help>;
306 def : F<"g", "Alias for --extern-only">, Alias<extern_only>;
307 def : F<"j", "Alias for --format=just-symbols">, Alias<format_EQ>, AliasArgs<["just-symbols"]>;
308 -def : F<"l", "Alias for --line-numbers">, Alias<line_numbers>;
309 def : F<"m", "Alias for --format=darwin">, Alias<format_EQ>, AliasArgs<["darwin"]>;
310 def : F<"M", "Deprecated alias for --print-armap">, Alias<print_armap>, Flags<[HelpHidden]>;
311 def : F<"n", "Alias for --numeric-sort">, Alias<numeric_sort>;
312 diff --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp
313 index 051fa3e5bfa5..9a9e8bd146bb 100644
314 --- a/llvm/tools/llvm-nm/llvm-nm.cpp
315 +++ b/llvm/tools/llvm-nm/llvm-nm.cpp
316 @@ -19,7 +19,6 @@
317 #include "llvm/BinaryFormat/COFF.h"
318 #include "llvm/BinaryFormat/MachO.h"
319 #include "llvm/BinaryFormat/XCOFF.h"
320 -#include "llvm/DebugInfo/Symbolize/Symbolize.h"
321 #include "llvm/Demangle/Demangle.h"
322 #include "llvm/IR/Function.h"
323 #include "llvm/IR/LLVMContext.h"
324 @@ -98,7 +97,6 @@ static bool Demangle;
325 static bool DynamicSyms;
326 static bool ExportSymbols;
327 static bool ExternalOnly;
328 -static bool LineNumbers;
329 static OutputFormatTy OutputFormat;
330 static bool NoLLVMBitcode;
331 static bool NoSort;
332 @@ -553,6 +551,8 @@ static void darwinPrintSymbol(SymbolicFile &Obj, const NMSymbol &S,
337 + outs() << "\n";
340 // Table that maps Darwin's Mach-O stab constants to strings to allow printing.
341 @@ -689,88 +689,9 @@ static void printExportSymbolList(const std::vector<NMSymbol> &SymbolList) {
345 -static void printLineNumbers(symbolize::LLVMSymbolizer &Symbolizer,
346 - const NMSymbol &S) {
347 - const auto *Obj = dyn_cast<ObjectFile>(S.Sym.getObject());
348 - if (!Obj)
349 - return;
350 - const SymbolRef Sym(S.Sym);
351 - uint64_t SectionIndex = object::SectionedAddress::UndefSection;
352 - section_iterator Sec = cantFail(Sym.getSection());
353 - if (Sec != Obj->section_end())
354 - SectionIndex = Sec->getIndex();
355 - object::SectionedAddress Address = {cantFail(Sym.getAddress()), SectionIndex};
357 - std::string FileName;
358 - uint32_t Line;
359 - switch (S.TypeChar) {
360 - // For undefined symbols, find the first relocation for that symbol with a
361 - // line number.
362 - case 'U': {
363 - for (const SectionRef RelocsSec : Obj->sections()) {
364 - if (RelocsSec.relocations().empty())
365 - continue;
366 - SectionRef TextSec = *cantFail(RelocsSec.getRelocatedSection());
367 - if (!TextSec.isText())
368 - continue;
369 - for (const RelocationRef R : RelocsSec.relocations()) {
370 - if (R.getSymbol() != Sym)
371 - continue;
372 - Expected<DILineInfo> ResOrErr = Symbolizer.symbolizeCode(
373 - *Obj, {TextSec.getAddress() + R.getOffset(), SectionIndex});
374 - if (!ResOrErr) {
375 - error(ResOrErr.takeError(), Obj->getFileName());
376 - return;
378 - if (ResOrErr->FileName == DILineInfo::BadString)
379 - return;
380 - FileName = std::move(ResOrErr->FileName);
381 - Line = ResOrErr->Line;
382 - break;
384 - if (!FileName.empty())
385 - break;
387 - if (FileName.empty())
388 - return;
389 - break;
391 - case 't':
392 - case 'T': {
393 - Expected<DILineInfo> ResOrErr = Symbolizer.symbolizeCode(*Obj, Address);
394 - if (!ResOrErr) {
395 - error(ResOrErr.takeError(), Obj->getFileName());
396 - return;
398 - if (ResOrErr->FileName == DILineInfo::BadString)
399 - return;
400 - FileName = std::move(ResOrErr->FileName);
401 - Line = ResOrErr->Line;
402 - break;
404 - default: {
405 - Expected<DIGlobal> ResOrErr = Symbolizer.symbolizeData(*Obj, Address);
406 - if (!ResOrErr) {
407 - error(ResOrErr.takeError(), Obj->getFileName());
408 - return;
410 - if (ResOrErr->DeclFile.empty())
411 - return;
412 - FileName = std::move(ResOrErr->DeclFile);
413 - Line = ResOrErr->DeclLine;
414 - break;
417 - outs() << '\t' << FileName << ':' << Line;
420 static void printSymbolList(SymbolicFile &Obj,
421 std::vector<NMSymbol> &SymbolList, bool printName,
422 StringRef ArchiveName, StringRef ArchitectureName) {
423 - std::optional<symbolize::LLVMSymbolizer> Symbolizer;
424 - if (LineNumbers)
425 - Symbolizer.emplace();
427 if (!PrintFileName) {
428 if ((OutputFormat == bsd || OutputFormat == posix ||
429 OutputFormat == just_symbols) &&
430 @@ -877,7 +798,7 @@ static void printSymbolList(SymbolicFile &Obj,
431 printFormat);
432 } else if (OutputFormat == posix) {
433 outs() << Name << " " << S.TypeChar << " " << SymbolAddrStr << " "
434 - << (MachO ? "0" : SymbolSizeStr);
435 + << (MachO ? "0" : SymbolSizeStr) << "\n";
436 } else if (OutputFormat == bsd || (OutputFormat == darwin && !MachO)) {
437 if (PrintAddress)
438 outs() << SymbolAddrStr << ' ';
439 @@ -898,14 +819,12 @@ static void printSymbolList(SymbolicFile &Obj,
440 } else
441 outs() << S.IndirectName << ")";
443 + outs() << "\n";
444 } else if (OutputFormat == sysv) {
445 outs() << left_justify(Name, 20) << "|" << SymbolAddrStr << "| "
446 << S.TypeChar << " |" << right_justify(S.TypeName, 18) << "|"
447 - << SymbolSizeStr << "| |" << S.SectionName;
448 + << SymbolSizeStr << "| |" << S.SectionName << "\n";
450 - if (LineNumbers)
451 - printLineNumbers(*Symbolizer, S);
452 - outs() << '\n';
455 SymbolList.clear();
456 @@ -2496,7 +2415,6 @@ int llvm_nm_main(int argc, char **argv, const llvm::ToolContext &) {
457 else
458 error("--format value should be one of: bsd, posix, sysv, darwin, "
459 "just-symbols");
460 - LineNumbers = Args.hasArg(OPT_line_numbers);
461 NoLLVMBitcode = Args.hasArg(OPT_no_llvm_bc);
462 NoSort = Args.hasArg(OPT_no_sort);
463 NoWeakSymbols = Args.hasArg(OPT_no_weak);
465 2.41.0.3.g1cb8d410ac