forked from OSchip/llvm-project
[ELF] Move addWrappedSymbols before postParseObjectFile
addWrappedSymbols may trigger archive extraction: split stack implementation
uses --wrap=pthread_create, which extracts libgcc.a(generic-morestack-thread.o).
This fixes the regression caused by 09602d3b47
by
making the invariant satisfied: no more non-compileBitcodeFiles object file is
produced at postParseObjectFile.
This commit is contained in:
parent
c01ec30830
commit
f456c3ae3f
|
@ -2452,6 +2452,9 @@ void LinkerDriver::link(opt::InputArgList &args) {
|
|||
for (auto *s : lto::LTO::getRuntimeLibcallSymbols())
|
||||
handleLibcall(s);
|
||||
|
||||
// Archive members defining __wrap symbols may be extracted.
|
||||
std::vector<WrappedSymbol> wrapped = addWrappedSymbols(args);
|
||||
|
||||
// No more lazy bitcode can be extracted at this point. Do post parse work
|
||||
// like checking duplicate symbols.
|
||||
parallelForEach(objectFiles, postParseObjectFile);
|
||||
|
@ -2478,8 +2481,6 @@ void LinkerDriver::link(opt::InputArgList &args) {
|
|||
// addReservedSymbols to mark the created symbols as not absolute.
|
||||
Out::elfHeader = make<OutputSection>("", 0, SHF_ALLOC);
|
||||
|
||||
std::vector<WrappedSymbol> wrapped = addWrappedSymbols(args);
|
||||
|
||||
// We need to create some reserved symbols such as _end. Create them.
|
||||
if (!config->relocatable)
|
||||
addReservedSymbols();
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
# REQUIRES: x86
|
||||
## --wrap may trigger archive extraction. Test that local symbols are initialized.
|
||||
|
||||
# RUN: rm -rf %t && split-file %s %t
|
||||
# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/a.s -o %t/a.o
|
||||
# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/b.s -o %t/b.o
|
||||
# RUN: ld.lld %t/a.o --start-lib %t/b.o --end-lib -o %t/a --wrap pthread_create -o /dev/null
|
||||
|
||||
#--- a.s
|
||||
.globl _start
|
||||
_start:
|
||||
.cfi_startproc
|
||||
call pthread_create
|
||||
.cfi_endproc
|
||||
|
||||
#--- b.s
|
||||
.global __wrap_pthread_create
|
||||
__wrap_pthread_create:
|
||||
.cfi_startproc
|
||||
ret
|
||||
.cfi_endproc
|
Loading…
Reference in New Issue