[ELF] ICF: replace includeInDynsym with isExported · llvm/llvm-project@a2b5020 (original) (raw)

2 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -2434,7 +2434,7 @@ static void findKeepUniqueSections(Ctx &ctx, opt::InputArgList &args) {
2434 2434 // or DSOs, so we conservatively mark them as address-significant.
2435 2435 bool icfSafe = ctx.arg.icf == ICFLevel::Safe;
2436 2436 for (Symbol *sym : ctx.symtab->getSymbols())
2437 -if (sym->includeInDynsym(ctx))
2437 +if (sym->isExported)
2438 2438 markAddrsig(icfSafe, sym);
2439 2439
2440 2440 // Visit the address-significance table in each object file and mark each
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
1 1 # REQUIRES: x86
2 +# RUN: llvm-mc -filetype=obj -triple=x86_64 %S/Inputs/shared.s -o %ta.o
3 +# RUN: ld.lld -shared -soname=ta %ta.o -o %ta.so
2 4
3 5 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
4 6 # RUN: llvm-objcopy %t1.o %t1copy.o
5 7 # RUN: llvm-objcopy --localize-symbol=h1 %t1.o %t1changed.o
6 8 # RUN: ld.lld -r %t1.o -o %t1reloc.o
7 9 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/icf-safe.s -o %t2.o
8 -# RUN: ld.lld %t1.o %t2.o -o %t2 --icf=safe --print-icf-sections | FileCheck %s
10 +# RUN: ld.lld %t1.o %t2.o -o %t2 --icf=safe --print-icf-sections --export-dynamic | FileCheck %s
9 11 # RUN: ld.lld %t1copy.o %t2.o -o %t2 --icf=safe --print-icf-sections | FileCheck %s
10 12 # RUN: ld.lld %t1.o %t2.o -o %t3 --icf=safe --print-icf-sections -shared | FileCheck --check-prefix=EXPORT %s
11 -# RUN: ld.lld %t1.o %t2.o -o %t3 --icf=safe --print-icf-sections --export-dynamic | FileCheck --check-prefix=EXPORT %s
13 +## Exported symbols are suppressed for ICF when dynamic linking is enabled.
14 +# RUN: ld.lld %t1.o %t2.o %ta.so -o %t3 --icf=safe --print-icf-sections --export-dynamic | FileCheck --check-prefix=EXPORT %s
12 15 # RUN: ld.lld %t1.o %t2.o -o %t2 --icf=all --print-icf-sections | FileCheck --check-prefix=ALL %s
13 -# RUN: ld.lld %t1.o %t2.o -o %t2 --icf=all --print-icf-sections --export-dynamic | FileCheck --check-prefix=ALL-EXPORT %s
16 +# RUN: ld.lld %t1.o %t2.o %ta.so -o %t2 --icf=all --print-icf-sections --export-dynamic | FileCheck --check-prefix=ALL-EXPORT %s
14 17 # RUN: ld.lld %t1changed.o -o %t4 --icf=safe 2>&1 | FileCheck --check-prefix=SH_LINK_0 %s
15 18 # RUN: ld.lld %t1reloc.o -o %t4 --icf=safe 2>&1 | FileCheck --check-prefix=SH_LINK_0 %s
16 19