Skip to content

Commit 676fd91

Browse files
committed
Revert "[ELF] PROVIDE: fix spurious "symbol not found""
This reverts commit dcc45fa.
1 parent dd46457 commit 676fd91

File tree

2 files changed

+7
-35
lines changed

2 files changed

+7
-35
lines changed

lld/ELF/Driver.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2852,6 +2852,13 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
28522852
// Create dynamic sections for dynamic linking and static PIE.
28532853
config->hasDynSymTab = !ctx.sharedFiles.empty() || config->isPic;
28542854

2855+
script->addScriptReferencedSymbolsToSymTable();
2856+
2857+
// Prevent LTO from removing any definition referenced by -u.
2858+
for (StringRef name : config->undefined)
2859+
if (Defined *sym = dyn_cast_or_null<Defined>(symtab.find(name)))
2860+
sym->isUsedInRegularObj = true;
2861+
28552862
// If an entry symbol is in a static archive, pull out that file now.
28562863
if (Symbol *sym = symtab.find(config->entry))
28572864
handleUndefined(sym, "--entry");
@@ -2860,16 +2867,6 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
28602867
for (StringRef pat : args::getStrings(args, OPT_undefined_glob))
28612868
handleUndefinedGlob(pat);
28622869

2863-
// After potential archive member extraction involving ENTRY and
2864-
// -u/--undefined-glob, check whether PROVIDE symbols should be defined (the
2865-
// RHS may refer to definitions in just extracted object files).
2866-
script->addScriptReferencedSymbolsToSymTable();
2867-
2868-
// Prevent LTO from removing any definition referenced by -u.
2869-
for (StringRef name : config->undefined)
2870-
if (Defined *sym = dyn_cast_or_null<Defined>(symtab.find(name)))
2871-
sym->isUsedInRegularObj = true;
2872-
28732870
// Mark -init and -fini symbols so that the LTO doesn't eliminate them.
28742871
if (Symbol *sym = dyn_cast_or_null<Defined>(symtab.find(config->init)))
28752872
sym->isUsedInRegularObj = true;

lld/test/ELF/linkerscript/symbolreferenced.s

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,6 @@
5050
# RUN: not ld.lld -T chain2.t a.o 2>&1 | FileCheck %s --check-prefix=ERR --implicit-check-not=error:
5151
# ERR-COUNT-3: error: chain2.t:1: symbol not found: undef
5252

53-
## _start in a lazy object file references PROVIDE symbols. We extract _start
54-
## earlier to avoid spurious "symbol not found" errors.
55-
# RUN: llvm-mc -filetype=obj -triple=x86_64 undef.s -o undef.o
56-
# RUN: llvm-mc -filetype=obj -triple=x86_64 start.s -o start.o
57-
# RUN: ld.lld -T chain2.t undef.o --start-lib start.o --end-lib -o lazy
58-
# RUN: llvm-nm lazy | FileCheck %s --check-prefix=LAZY
59-
# RUN: ld.lld -e 0 -T chain2.t --undefined-glob '_start*' undef.o --start-lib start.o --end-lib -o lazy
60-
# RUN: llvm-nm lazy | FileCheck %s --check-prefix=LAZY
61-
62-
# LAZY: T _start
63-
# LAZY-NEXT: t f1
64-
# LAZY-NEXT: T f2
65-
# LAZY-NEXT: T newsym
66-
# LAZY-NEXT: T unde
67-
6853
#--- a.s
6954
.global _start
7055
_start:
@@ -104,13 +89,3 @@ PROVIDE(newsym = f1);
10489
PROVIDE(f2 = undef);
10590
PROVIDE_HIDDEN(f1 = f2);
10691
PROVIDE(newsym = f1);
107-
108-
#--- undef.s
109-
.globl undef
110-
undef: ret
111-
112-
#--- start.s
113-
.globl _start
114-
_start: ret
115-
.data
116-
.quad newsym

0 commit comments

Comments
 (0)