[llvm-bugs] [Bug 50282] New: lld mis-links lld, crashes in _tlv_bootstrap
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun May 9 06:45:31 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=50282
Bug ID: 50282
Summary: lld mis-links lld, crashes in _tlv_bootstrap
Product: lld
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: MachO
Assignee: unassignedbugs at nondot.org
Reporter: nicolasweber at gmx.de
CC: gkm at fb.com, jezreel at gmail.com,
llvm-bugs at lists.llvm.org, smeenai at fb.com
While debugging bug 50274 I ran into an issue where lld crashes on startup when
linked with lld.
% git diff
diff --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index d33c3d50fbbc..05e87b81f7ef 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -580,6 +580,7 @@ void ObjFile::parseSymbols(ArrayRef<typename LP::section>
sectionHeaders,
return nList[lhs].n_value < nList[rhs].n_value;
});
uint64_t sectionAddr = sectionHeaders[i].addr;
+ uint64_t sectionAlign = sectionHeaders[i].align;
// We populate subsecMap by repeatedly splitting the last (highest
address)
// subsection.
@@ -604,6 +605,11 @@ void ObjFile::parseSymbols(ArrayRef<typename LP::section>
sectionHeaders,
// 3. Alternative entry points do not induce new subsections.
if (!subsectionsViaSymbols || symbolOffset == 0 ||
sym.n_desc & N_ALT_ENTRY) {
+
+if (name ==
"l___const._ZN12_GLOBAL__N_116addValueProfDataERN4llvm15InstrProfRecordE.VD0")
{
+fprintf(stderr, "reuse\n");
+}
+
symbols[symIndex] =
createDefined(sym, name, isec, symbolOffset, symbolSize);
continue;
@@ -622,7 +628,10 @@ void ObjFile::parseSymbols(ArrayRef<typename LP::section>
sectionHeaders,
// TODO: ld64 appears to preserve the original alignment as well as each
// subsection's offset from the last aligned address. We should consider
// emulating that behavior.
- nextIsec->align = MinAlign(isec->align, sym.n_value);
+ nextIsec->align = MinAlign(sectionAlign, sym.n_value);
+if (name ==
"l___const._ZN12_GLOBAL__N_116addValueProfDataERN4llvm15InstrProfRecordE.VD0")
{
+fprintf(stderr, "new, %u\n", nextIsec->align);
+}
subsecMap.push_back({sym.n_value - sectionAddr, nextIsec});
subsecEntry = subsecMap.back();
}
Repro file:
https://drive.google.com/file/d/1xbr2NY2SJbKrT9n1XwMyoLy-M_X2GA-p/view?usp=sharing
thakis at MBP repro_lld %
~/src/chrome/src/third_party/llvm-build/Release+Asserts/bin/ld64.lld
@response.txt
thakis at MBP repro_lld % ./lld
zsh: abort ./lld
thakis at MBP repro_lld % lldb ./lld
(lldb) target create "./lld"
Current executable set to '/Users/thakis/src/llvm-project/out/gn/repro_lld/lld'
(x86_64).
(lldb) r
Process 39549 launched: '/Users/thakis/src/llvm-project/out/gn/repro_lld/lld'
(x86_64)
Process 39549 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
frame #0: 0x00007fff715c933a libsystem_kernel.dylib`__pthread_kill + 10
libsystem_kernel.dylib`__pthread_kill:
-> 0x7fff715c933a <+10>: jae 0x7fff715c9344 ; <+20>
0x7fff715c933c <+12>: movq %rax, %rdi
0x7fff715c933f <+15>: jmp 0x7fff715c3629 ; cerror_nocancel
0x7fff715c9344 <+20>: retq
Target 0: (lld) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
* frame #0: 0x00007fff715c933a libsystem_kernel.dylib`__pthread_kill + 10
frame #1: 0x00007fff71685e60 libsystem_pthread.dylib`pthread_kill + 430
frame #2: 0x00007fff71550808 libsystem_c.dylib`abort + 120
frame #3: 0x00007fff71483c33 libdyld.dylib`_tlv_bootstrap + 9
frame #4: 0x00000001003b3904 lld`::PrettyStackTraceEntry() [inlined]
printForSigInfoIfNeeded at PrettyStackTrace.cpp:195:7 [opt]
frame #5: 0x00000001003b38f4 lld`::PrettyStackTraceEntry() at
PrettyStackTrace.cpp:217 [opt]
frame #6: 0x00000001003abc48 lld`::InitLLVM() [inlined]
PrettyStackTraceProgram at PrettyStackTrace.h:95:5 [opt]
frame #7: 0x00000001003abc40 lld`::InitLLVM() [inlined]
PrettyStackTraceProgram at PrettyStackTrace.h:96 [opt]
frame #8: 0x00000001003abc40 lld`::InitLLVM() [inlined] emplace<int &,
const char **&> at Optional.h:113 [opt]
frame #9: 0x00000001003abc22 lld`::InitLLVM() [inlined] emplace<int &,
const char **&> at Optional.h:263 [opt]
frame #10: 0x00000001003abc22 lld`::InitLLVM() at InitLLVM.cpp:35 [opt]
frame #11: 0x0000000100000c8e lld`main at lld.cpp:201:12 [opt]
frame #12: 0x00007fff71481cc9 libdyld.dylib`start + 1
frame #13: 0x00007fff71481cc9 libdyld.dylib`start + 1
Works fine without that local diff. Not sure if this is a regression or not.
(Maybe it's a dupe of bug 50274 in the end.)
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210509/b0e6f146/attachment.html>
More information about the llvm-bugs
mailing list