-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lld][ELF] Error when deplibs adds new input file after LTO (#98565)
Parsing the new input file's symbols might invalidate LTO codegen, but the semantics of deplibs require them to be parsed. Accordingly, report an error unless the file had already been added to the link. Fixes #56070
- Loading branch information
1 parent
7f06560
commit 5b82741
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# REQUIRES: aarch64 | ||
|
||
# RUN: rm -rf %t && split-file %s %t && cd %t | ||
# RUN: llvm-mc -filetype=obj -triple=aarch64 -o deplibs.o deplibs.s | ||
# RUN: llvm-mc -filetype=obj -triple=aarch64 -o foo.o foo.s | ||
# RUN: llvm-as -o lto.o lto.ll | ||
# RUN: llvm-ar rc libdeplibs.a deplibs.o | ||
# RUN: llvm-ar rc libfoo.a foo.o | ||
|
||
## LTO emits a libcall (__aarch64_ldadd4_relax) that is resolved using a | ||
## library (libdeplibs.a) that contains a .deplibs section pointing to a file | ||
## (libfoo.a) not yet added to the link. | ||
# RUN: not ld.lld lto.o -u a -L. -ldeplibs 2>&1 | FileCheck %s | ||
# CHECK: error: input file 'foo.o' added after LTO | ||
|
||
## Including the file before LTO prevents the issue. | ||
# RUN: ld.lld lto.o -u a -L. -ldeplibs -lfoo | ||
|
||
#--- foo.s | ||
.global foo | ||
foo: | ||
#--- deplibs.s | ||
.global __aarch64_ldadd4_relax | ||
__aarch64_ldadd4_relax: | ||
b foo | ||
.section ".deplibs","MS",@llvm_dependent_libraries,1 | ||
.asciz "foo" | ||
#--- lto.ll | ||
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" | ||
target triple = "aarch64" | ||
|
||
define void @a(i32* nocapture %0) #0 { | ||
%2 = atomicrmw add i32* %0, i32 1 monotonic, align 4 | ||
ret void | ||
} | ||
|
||
attributes #0 = { "target-features"="+outline-atomics" } |