Skip to content

Commit c1ddc79

Browse files
cjacektru
authored andcommitted
[LLD][COFF] Set isUsedInRegularObj for target symbols in resolveAlternateNames (llvm#154837)
Fixes: llvm#154595 Prior to commit bbc8346, this flag was set by `insert()` from `addUndefined()`. Set it explicitly now. (cherry picked from commit a6fcd1a)
1 parent b95cfa4 commit c1ddc79

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

lld/COFF/SymbolTable.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,6 +1374,7 @@ void SymbolTable::resolveAlternateNames() {
13741374
auto toUndef = dyn_cast<Undefined>(toSym);
13751375
if (toUndef && (!toUndef->weakAlias || toUndef->isAntiDep))
13761376
continue;
1377+
toSym->isUsedInRegularObj = true;
13771378
if (toSym->isLazy())
13781379
forceLazy(toSym);
13791380
u->setWeakAlias(toSym);

lld/test/COFF/alternatename-lto.ll

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
; REQUIRES: x86
2+
; RUN: mkdir -p %t.dir
3+
; RUN: llvm-as -o %t.obj %s
4+
; RUN: lld-link -out:%t.dll -dll -noentry %t.obj -export:test
5+
6+
target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
7+
target triple = "x86_64-unknown-windows-msvc19.33.0"
8+
9+
$alt = comdat any
10+
11+
@alt = weak_odr dso_local global i32 0, comdat, align 4
12+
@ext = external dso_local global i32, align 4
13+
14+
; Function Attrs: noinline nounwind optnone uwtable
15+
define dso_local i32 @test() #0 {
16+
entry:
17+
%0 = load i32, ptr @ext, align 4
18+
ret i32 %0
19+
}
20+
21+
attributes #0 = { noinline nounwind optnone uwtable }
22+
23+
!llvm.linker.options = !{!0}
24+
25+
!0 = !{!"/alternatename:ext=alt"}

0 commit comments

Comments
 (0)