Skip to content

Commit 9adde28

Browse files
authored
[LLD][ELF][RISCV][Zicfilp][Zicfiss] Support -z zicfilp= and -z zicfiss= to force enable/disable features (#143114)
+ If `-z zicfilp=implicit` or option not specified, the output would have the ZICFILP feature enabled/disabled based on input objects + If `-z zicfilp=<never|unlabeled|func-sig>`, the output would have ZICFILP feature forced <off|on to the "unlabeled" scheme|on to the "func-sig" scheme> + If `-z zicfiss=implicit` or option not specified, the output would have the ZICFISS feature enabled/disabled based on input objects + If `-z zicfiss=<never|always>`, the output would have the ZICFISS feature forced <off|on>
1 parent 167223f commit 9adde28

File tree

5 files changed

+191
-9
lines changed

5 files changed

+191
-9
lines changed

lld/ELF/Config.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ enum LtoKind : uint8_t {UnifiedThin, UnifiedRegular, Default};
136136
// For -z gcs=
137137
enum class GcsPolicy { Implicit, Never, Always };
138138

139+
// For -z zicfilp=
140+
enum class ZicfilpPolicy { Implicit, Never, Unlabeled, FuncSig };
141+
142+
// For -z zicfiss=
143+
enum class ZicfissPolicy { Implicit, Never, Always };
144+
139145
// For some options that resemble -z bti-report={none,warning,error}
140146
enum class ReportPolicy { None, Warning, Error };
141147

@@ -411,6 +417,8 @@ struct Config {
411417
bool zText;
412418
bool zRetpolineplt;
413419
bool zWxneeded;
420+
ZicfilpPolicy zZicfilp;
421+
ZicfissPolicy zZicfiss;
414422
DiscardPolicy discard;
415423
GnuStackKind zGnustack;
416424
ICFLevel icf;

lld/ELF/Driver.cpp

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,10 @@ static void checkOptions(Ctx &ctx) {
430430
"RISC-V targets";
431431
if (ctx.arg.zZicfissReport != ReportPolicy::None)
432432
ErrAlways(ctx) << "-z zicfiss-report is only supported on RISC-V targets";
433+
if (ctx.arg.zZicfilp != ZicfilpPolicy::Implicit)
434+
ErrAlways(ctx) << "-z zicfilp is only supported on RISC-V targets";
435+
if (ctx.arg.zZicfiss != ZicfissPolicy::Implicit)
436+
ErrAlways(ctx) << "-z zicfiss is only supported on RISC-V targets";
433437
}
434438

435439
if (ctx.arg.emachine != EM_386 && ctx.arg.emachine != EM_X86_64 &&
@@ -584,6 +588,46 @@ static GcsPolicy getZGcs(Ctx &ctx, opt::InputArgList &args) {
584588
return ret;
585589
}
586590

591+
static ZicfilpPolicy getZZicfilp(Ctx &ctx, opt::InputArgList &args) {
592+
auto ret = ZicfilpPolicy::Implicit;
593+
for (auto *arg : args.filtered(OPT_z)) {
594+
std::pair<StringRef, StringRef> kv = StringRef(arg->getValue()).split('=');
595+
if (kv.first == "zicfilp") {
596+
arg->claim();
597+
if (kv.second == "unlabeled")
598+
ret = ZicfilpPolicy::Unlabeled;
599+
else if (kv.second == "func-sig")
600+
ret = ZicfilpPolicy::FuncSig;
601+
else if (kv.second == "never")
602+
ret = ZicfilpPolicy::Never;
603+
else if (kv.second == "implicit")
604+
ret = ZicfilpPolicy::Implicit;
605+
else
606+
ErrAlways(ctx) << "unknown -z zicfilp= value: " << kv.second;
607+
}
608+
}
609+
return ret;
610+
}
611+
612+
static ZicfissPolicy getZZicfiss(Ctx &ctx, opt::InputArgList &args) {
613+
auto ret = ZicfissPolicy::Implicit;
614+
for (auto *arg : args.filtered(OPT_z)) {
615+
std::pair<StringRef, StringRef> kv = StringRef(arg->getValue()).split('=');
616+
if (kv.first == "zicfiss") {
617+
arg->claim();
618+
if (kv.second == "always")
619+
ret = ZicfissPolicy::Always;
620+
else if (kv.second == "never")
621+
ret = ZicfissPolicy::Never;
622+
else if (kv.second == "implicit")
623+
ret = ZicfissPolicy::Implicit;
624+
else
625+
ErrAlways(ctx) << "unknown -z zicfiss= value: " << kv.second;
626+
}
627+
}
628+
return ret;
629+
}
630+
587631
// Report a warning for an unknown -z option.
588632
static void checkZOptions(Ctx &ctx, opt::InputArgList &args) {
589633
// This function is called before getTarget(), when certain options are not
@@ -1567,6 +1611,8 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
15671611
ctx.arg.zCopyreloc = getZFlag(args, "copyreloc", "nocopyreloc", true);
15681612
ctx.arg.zForceBti = hasZOption(args, "force-bti");
15691613
ctx.arg.zForceIbt = hasZOption(args, "force-ibt");
1614+
ctx.arg.zZicfilp = getZZicfilp(ctx, args);
1615+
ctx.arg.zZicfiss = getZZicfiss(ctx, args);
15701616
ctx.arg.zGcs = getZGcs(ctx, args);
15711617
ctx.arg.zGlobal = hasZOption(args, "global");
15721618
ctx.arg.zGnustack = getZGnuStack(args);
@@ -2926,6 +2972,18 @@ static void readSecurityNotes(Ctx &ctx) {
29262972
<< f
29272973
<< ": -z zicfiss-report: file does not have "
29282974
"GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS property";
2975+
2976+
if (ctx.arg.zZicfilp == ZicfilpPolicy::Unlabeled &&
2977+
(features & GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG))
2978+
Warn(ctx) << f
2979+
<< ": -z zicfilp=unlabeled: file has conflicting property: "
2980+
"GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG";
2981+
2982+
if (ctx.arg.zZicfilp == ZicfilpPolicy::FuncSig &&
2983+
(features & GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED))
2984+
Warn(ctx) << f
2985+
<< ": -z zicfilp=func-sig: file has conflicting property: "
2986+
"GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED";
29292987
}
29302988

29312989
if (ctx.arg.zForceBti && !(features & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)) {
@@ -2989,6 +3047,25 @@ static void readSecurityNotes(Ctx &ctx) {
29893047
else if (ctx.arg.zGcs == GcsPolicy::Never)
29903048
ctx.arg.andFeatures &= ~GNU_PROPERTY_AARCH64_FEATURE_1_GCS;
29913049

3050+
if (ctx.arg.emachine == EM_RISCV) {
3051+
// Force enable/disable Zicfilp.
3052+
if (ctx.arg.zZicfilp == ZicfilpPolicy::Unlabeled) {
3053+
ctx.arg.andFeatures |= GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED;
3054+
ctx.arg.andFeatures &= ~GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG;
3055+
} else if (ctx.arg.zZicfilp == ZicfilpPolicy::FuncSig) {
3056+
ctx.arg.andFeatures |= GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG;
3057+
ctx.arg.andFeatures &= ~GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED;
3058+
} else if (ctx.arg.zZicfilp == ZicfilpPolicy::Never)
3059+
ctx.arg.andFeatures &= ~(GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED |
3060+
GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG);
3061+
3062+
// Force enable/disable Zicfiss.
3063+
if (ctx.arg.zZicfiss == ZicfissPolicy::Always)
3064+
ctx.arg.andFeatures |= GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS;
3065+
else if (ctx.arg.zZicfiss == ZicfissPolicy::Never)
3066+
ctx.arg.andFeatures &= ~GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS;
3067+
}
3068+
29923069
// If we are utilising GCS at any stage, the sharedFiles should be checked to
29933070
// ensure they also support this feature. The gcs-report-dynamic option is
29943071
// used to indicate if the user wants information relating to this, and will

lld/test/ELF/riscv-feature-zicfilp-func-sig.s

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
## Test the ZICFILP func-sig feature.
33
## To lift maintenance burden, most tests are conducted only with 64-bit RISC-V
44
## Naming convention: *-s.s files enables ZICFILP func-sig.
5+
## Naming convention: *-u.s files enables ZICFILP unlabeled.
56
# RUN: rm -rf %t && split-file %s %t && cd %t
67
# RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-f1-s.s -o rv32-f1-s.o
78
# RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-f2-s.s -o rv32-f2-s.o
@@ -12,14 +13,20 @@
1213
# RUN: llvm-mc --filetype=obj --triple=riscv64 f2-s.s -o f2-s.o
1314
# RUN: llvm-mc --filetype=obj --triple=riscv64 f3.s -o f3.o
1415
# RUN: llvm-mc --filetype=obj --triple=riscv64 f3-s.s -o f3-s.o
16+
# RUN: llvm-mc --filetype=obj --triple=riscv64 f3-u.s -o f3-u.o
1517

16-
## ZICFILP-func-sig should be enabled when it's enabled in all inputs
18+
## ZICFILP-func-sig should be enabled when it's enabled in all inputs or when
19+
## it's forced on.
1720
# RUN: ld.lld rv32-f1-s.o rv32-f2-s.o rv32-f3-s.o -o out.rv32 --fatal-warnings
1821
# RUN: llvm-readelf -n out.rv32 | FileCheck --check-prefix=ZICFILP %s
1922
# RUN: ld.lld f1-s.o f2-s.o f3-s.o -o out --fatal-warnings
2023
# RUN: llvm-readelf -n out | FileCheck --check-prefix=ZICFILP %s
2124
# RUN: ld.lld f1-s.o f3-s.o --shared -o out.so --fatal-warnings
2225
# RUN: llvm-readelf -n out.so | FileCheck --check-prefix=ZICFILP %s
26+
# RUN: ld.lld f1-s.o f2.o f3-s.o -o out.force -z zicfilp=func-sig --fatal-warnings
27+
# RUN: llvm-readelf -n out.force | FileCheck --check-prefix=ZICFILP %s
28+
# RUN: ld.lld f2-s.o f3.o --shared -o out.force.so -z zicfilp=never -z zicfilp=func-sig --fatal-warnings
29+
# RUN: llvm-readelf -n out.force.so | FileCheck --check-prefix=ZICFILP %s
2330
# ZICFILP: Properties: RISC-V feature: ZICFILP-func-sig
2431

2532
## ZICFILP-func-sig should not be enabled if it's not enabled in at least one
@@ -29,18 +36,33 @@
2936
# RUN: ld.lld f2-s.o f3.o --shared -o out.no.so --fatal-warnings
3037
# RUN: llvm-readelf -n out.no.so | count 0
3138

39+
## ZICFILP-func-sig should be disabled with zicfilp=never, even if
40+
## ZICFILP-func-sig is present in all inputs.
41+
# RUN: ld.lld f1-s.o f2-s.o f3-s.o -z zicfilp=func-sig -z zicfilp=never -o out.never --fatal-warnings
42+
# RUN: llvm-readelf -n out.never | count 0
43+
3244
## zicfilp-func-sig-report should report any input files that don't have the
3345
## ZICFILP-func-sig property
3446
# RUN: ld.lld f1-s.o f2.o f3-s.o -z zicfilp-func-sig-report=warning 2>&1 | FileCheck --check-prefix=REPORT-WARN %s
47+
# RUN: ld.lld f1-s.o f2.o f3-s.o -z zicfilp-func-sig-report=warning -z zicfilp=func-sig 2>&1 | FileCheck --check-prefix=REPORT-WARN %s
48+
# RUN: ld.lld f1-s.o f2.o f3-s.o -z zicfilp-func-sig-report=warning -z zicfilp=never 2>&1 | FileCheck --check-prefix=REPORT-WARN %s
3549
# RUN: not ld.lld f2-s.o f3.o --shared -z zicfilp-func-sig-report=error 2>&1 | FileCheck --check-prefix=REPORT-ERROR %s
36-
# RUN: ld.lld f1-s.o f2-s.o f3-s.o -z zicfilp-func-sig-report=warning 2>&1 | count 0
50+
# RUN: ld.lld f1-s.o f2-s.o f3-s.o -z zicfilp-func-sig-report=warning -z zicfilp=func-sig 2>&1 | count 0
3751
# REPORT-WARN: warning: f2.o: -z zicfilp-func-sig-report: file does not have GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG property
3852
# REPORT-ERROR: error: f3.o: -z zicfilp-func-sig-report: file does not have GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG property
3953

4054
## An invalid -z zicfilp-func-sig-report option should give an error
4155
# RUN: not ld.lld f2-s.o -z zicfilp-func-sig-report=x 2>&1 | FileCheck --check-prefix=INVALID %s
4256
# INVALID: error: unknown -z zicfilp-func-sig-report= value: x
4357

58+
## ZICFILP-unlabeled and ZICFILP-func-sig should conflict with each other.
59+
# RUN: ld.lld f3-u.o -o out.override -z zicfilp=func-sig 2>&1 | FileCheck --check-prefix=FORCE-CONFLICT %s
60+
# FORCE-CONFLICT: warning: f3-u.o: -z zicfilp=func-sig: file has conflicting property: GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED
61+
62+
## -z zicfilp=func-sig should override and disable ZICFILP-unlabeled.
63+
# RUN: llvm-readelf -n out.override | FileCheck --check-prefixes=ZICFILP,OVERRIDE %s
64+
# OVERRIDE-NOT: ZICFILP-unlabeled
65+
4466
#--- rv32-f1-s.s
4567
.section ".note.gnu.property", "a"
4668
.balign 4
@@ -191,3 +213,24 @@ ndesc_end:
191213
.type f3,@function
192214
f3:
193215
ret
216+
217+
#--- f3-u.s
218+
.section ".note.gnu.property", "a"
219+
.balign 8
220+
.4byte 4
221+
.4byte (ndesc_end - ndesc_begin)
222+
.4byte 0x5 // NT_GNU_PROPERTY_TYPE_0
223+
.asciz "GNU"
224+
ndesc_begin:
225+
.balign 8
226+
.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND
227+
.4byte 4
228+
.4byte 1 // GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED
229+
.balign 8
230+
ndesc_end:
231+
232+
.text
233+
.globl f3
234+
.type f3,@function
235+
f3:
236+
ret

lld/test/ELF/riscv-feature-zicfilp-unlabeled.s

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
## Test the ZICFILP unlabeled feature.
33
## To lift maintenance burden, most tests are conducted only with 64-bit RISC-V
44
## Naming convention: *-s.s files enables ZICFILP unlabeled.
5+
## Naming convention: *-f.s files enables ZICFILP func-sig.
56
## Naming convention: *-c.s files enables both of the conflicting ZICFILP unlabeled and ZICFILP func-sig features.
67
# RUN: rm -rf %t && split-file %s %t && cd %t
78
# RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-f1-s.s -o rv32-f1-s.o
@@ -14,14 +15,20 @@
1415
# RUN: llvm-mc --filetype=obj --triple=riscv64 f2-s.s -o f2-s.o
1516
# RUN: llvm-mc --filetype=obj --triple=riscv64 f3.s -o f3.o
1617
# RUN: llvm-mc --filetype=obj --triple=riscv64 f3-s.s -o f3-s.o
18+
# RUN: llvm-mc --filetype=obj --triple=riscv64 f3-f.s -o f3-f.o
1719

18-
## ZICFILP-unlabeled should be enabled when it's enabled in all inputs
20+
## ZICFILP-unlabeled should be enabled when it's enabled in all inputs or when
21+
## it's forced on.
1922
# RUN: ld.lld rv32-f1-s.o rv32-f2-s.o rv32-f3-s.o -o out.rv32 --fatal-warnings
2023
# RUN: llvm-readelf -n out.rv32 | FileCheck --check-prefix=ZICFILP %s
2124
# RUN: ld.lld f1-s.o f2-s.o f3-s.o -o out --fatal-warnings
2225
# RUN: llvm-readelf -n out | FileCheck --check-prefix=ZICFILP %s
2326
# RUN: ld.lld f1-s.o f3-s.o --shared -o out.so --fatal-warnings
2427
# RUN: llvm-readelf -n out.so | FileCheck --check-prefix=ZICFILP %s
28+
# RUN: ld.lld f1-s.o f2.o f3-s.o -o out.force -z zicfilp=unlabeled --fatal-warnings
29+
# RUN: llvm-readelf -n out.force | FileCheck --check-prefix=ZICFILP %s
30+
# RUN: ld.lld f2-s.o f3.o --shared -o out.force.so -z zicfilp=never -z zicfilp=unlabeled --fatal-warnings
31+
# RUN: llvm-readelf -n out.force.so | FileCheck --check-prefix=ZICFILP %s
2532
# ZICFILP: Properties: RISC-V feature: ZICFILP-unlabeled
2633

2734
## ZICFILP-unlabeled should not be enabled if it's not enabled in at least one
@@ -31,21 +38,35 @@
3138
# RUN: ld.lld f2-s.o f3.o --shared -o out.no.so --fatal-warnings
3239
# RUN: llvm-readelf -n out.no.so | count 0
3340

41+
## ZICFILP-unlabeled should be disabled with zicfilp=never, even if
42+
## ZICFILP-unlabeled is present in all inputs.
43+
# RUN: ld.lld f1-s.o f2-s.o f3-s.o -z zicfilp=unlabeled -z zicfilp=never -o out.never --fatal-warnings
44+
# RUN: llvm-readelf -n out.never | count 0
45+
3446
## zicfilp-unlabeled-report should report any input files that don't have the
3547
## ZICFILP-unlabeled property
3648
# RUN: ld.lld f1-s.o f2.o f3-s.o -z zicfilp-unlabeled-report=warning 2>&1 | FileCheck --check-prefix=REPORT-WARN %s
49+
# RUN: ld.lld f1-s.o f2.o f3-s.o -z zicfilp-unlabeled-report=warning -z zicfilp=unlabeled 2>&1 | FileCheck --check-prefix=REPORT-WARN %s
50+
# RUN: ld.lld f1-s.o f2.o f3-s.o -z zicfilp-unlabeled-report=warning -z zicfilp=never 2>&1 | FileCheck --check-prefix=REPORT-WARN %s
3751
# RUN: not ld.lld f2-s.o f3.o --shared -z zicfilp-unlabeled-report=error 2>&1 | FileCheck --check-prefix=REPORT-ERROR %s
38-
# RUN: ld.lld f1-s.o f2-s.o f3-s.o -z zicfilp-unlabeled-report=warning 2>&1 | count 0
52+
# RUN: ld.lld f1-s.o f2-s.o f3-s.o -z zicfilp-unlabeled-report=warning -z zicfilp=never 2>&1 | count 0
3953
# REPORT-WARN: warning: f2.o: -z zicfilp-unlabeled-report: file does not have GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED property
4054
# REPORT-ERROR: error: f3.o: -z zicfilp-unlabeled-report: file does not have GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED property
4155

4256
## An invalid -z zicfilp-unlabeled-report option should give an error
43-
# RUN: not ld.lld f2-s.o -z zicfilp-unlabeled-report=x 2>&1 | FileCheck --check-prefix=INVALID %s
57+
# RUN: not ld.lld f2-s.o -z zicfilp=x -z zicfilp-unlabeled-report=x 2>&1 | FileCheck --check-prefix=INVALID %s
58+
# INVALID: error: unknown -z zicfilp= value: x
4459
# INVALID: error: unknown -z zicfilp-unlabeled-report= value: x
4560

4661
## ZICFILP-unlabeled and ZICFILP-func-sig should conflict with each other
4762
# RUN: not ld.lld f1-c.o 2>&1 | FileCheck --check-prefix=CONFLICT %s
63+
# RUN: ld.lld f3-f.o -o out.override -z zicfilp=unlabeled 2>&1 | FileCheck --check-prefix=FORCE-CONFLICT %s
4864
# CONFLICT: error: f1-c.o: file has conflicting properties: GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED and GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG
65+
# FORCE-CONFLICT: warning: f3-f.o: -z zicfilp=unlabeled: file has conflicting property: GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG
66+
67+
## -z zicfilp=unlabeled should override and disable ZICFILP-func-sig.
68+
# RUN: llvm-readelf -n out.override | FileCheck --check-prefixes=ZICFILP,OVERRIDE %s
69+
# OVERRIDE-NOT: ZICFILP-func-sig
4970

5071
#--- rv32-f1-s.s
5172
.section ".note.gnu.property", "a"
@@ -219,3 +240,24 @@ ndesc_end:
219240
.type f3,@function
220241
f3:
221242
ret
243+
244+
#--- f3-f.s
245+
.section ".note.gnu.property", "a"
246+
.balign 8
247+
.4byte 4
248+
.4byte (ndesc_end - ndesc_begin)
249+
.4byte 0x5 // NT_GNU_PROPERTY_TYPE_0
250+
.asciz "GNU"
251+
ndesc_begin:
252+
.balign 8
253+
.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND
254+
.4byte 4
255+
.4byte 4 // GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG
256+
.balign 8
257+
ndesc_end:
258+
259+
.text
260+
.globl f3
261+
.type f3,@function
262+
f3:
263+
ret

lld/test/ELF/riscv-feature-zicfiss.s

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@
1313
# RUN: llvm-mc --filetype=obj --triple=riscv64 f3.s -o f3.o
1414
# RUN: llvm-mc --filetype=obj --triple=riscv64 f3-s.s -o f3-s.o
1515

16-
## ZICFISS should be enabled when it's enabled in all inputs
16+
## ZICFISS should be enabled when it's enabled in all inputs or when it's forced on.
1717
# RUN: ld.lld rv32-f1-s.o rv32-f2-s.o rv32-f3-s.o -o out.rv32 --fatal-warnings
1818
# RUN: llvm-readelf -n out.rv32 | FileCheck --check-prefix=ZICFISS %s
1919
# RUN: ld.lld f1-s.o f2-s.o f3-s.o -o out --fatal-warnings
2020
# RUN: llvm-readelf -n out | FileCheck --check-prefix=ZICFISS %s
2121
# RUN: ld.lld f1-s.o f3-s.o --shared -o out.so --fatal-warnings
2222
# RUN: llvm-readelf -n out.so | FileCheck --check-prefix=ZICFISS %s
23+
# RUN: ld.lld f1-s.o f2.o f3-s.o -o out.force -z zicfiss=always --fatal-warnings
24+
# RUN: llvm-readelf -n out.force | FileCheck --check-prefix=ZICFISS %s
25+
# RUN: ld.lld f2-s.o f3.o --shared -o out.force.so -z zicfiss=never -z zicfiss=always --fatal-warnings
26+
# RUN: llvm-readelf -n out.force.so | FileCheck --check-prefix=ZICFISS %s
2327
# ZICFISS: Properties: RISC-V feature: ZICFISS
2428

2529
## ZICFISS should not be enabled if it's not enabled in at least one input
@@ -28,17 +32,25 @@
2832
# RUN: ld.lld f2-s.o f3.o --shared -o out.no.so --fatal-warnings
2933
# RUN: llvm-readelf -n out.no.so | count 0
3034

35+
## ZICFISS should be disabled with zicfiss=never, even if ZICFISS is present in
36+
## all inputs.
37+
# RUN: ld.lld f1-s.o f2-s.o f3-s.o -z zicfiss=always -z zicfiss=never -o out.never --fatal-warnings
38+
# RUN: llvm-readelf -n out.never | count 0
39+
3140
## zicfiss-report should report any input files that don't have the zicfiss
3241
## property
3342
# RUN: ld.lld f1-s.o f2.o f3-s.o -z zicfiss-report=warning 2>&1 | FileCheck --check-prefix=REPORT-WARN %s
43+
# RUN: ld.lld f1-s.o f2.o f3-s.o -z zicfiss-report=warning -z zicfiss=always 2>&1 | FileCheck --check-prefix=REPORT-WARN %s
44+
# RUN: ld.lld f1-s.o f2.o f3-s.o -z zicfiss-report=warning -z zicfiss=never 2>&1 | FileCheck --check-prefix=REPORT-WARN %s
3445
# RUN: not ld.lld f2-s.o f3.o --shared -z zicfiss-report=error 2>&1 | FileCheck --check-prefix=REPORT-ERROR %s
35-
# RUN: ld.lld f1-s.o f2-s.o f3-s.o -z zicfiss-report=warning 2>&1 | count 0
36-
# RUN: ld.lld f1-s.o f2-s.o f3-s.o -z zicfiss-report=error 2>&1 | count 0
46+
# RUN: ld.lld f1-s.o f2-s.o f3-s.o -z zicfiss-report=warning -z zicfiss=always 2>&1 | count 0
47+
# RUN: ld.lld f1-s.o f2-s.o f3-s.o -z zicfiss-report=error -z zicfiss=always 2>&1 | count 0
3748
# REPORT-WARN: warning: f2.o: -z zicfiss-report: file does not have GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS property
3849
# REPORT-ERROR: error: f3.o: -z zicfiss-report: file does not have GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS property
3950

4051
## An invalid -z zicfiss-report option should give an error
41-
# RUN: not ld.lld f2-s.o f3-s.o -z zicfiss-report=x 2>&1 | FileCheck --check-prefix=INVALID %s
52+
# RUN: not ld.lld f2-s.o f3-s.o -z zicfiss=x -z zicfiss-report=x 2>&1 | FileCheck --check-prefix=INVALID %s
53+
# INVALID: error: unknown -z zicfiss= value: x
4254
# INVALID: error: unknown -z zicfiss-report= value: x
4355

4456
#--- rv32-f1-s.s

0 commit comments

Comments
 (0)