|
| 1 | +#---EntryCmdWarn.test-------------------- Executable,LS ----------------------# |
| 2 | +#BEGIN_COMMENT |
| 3 | +# Tests that -Wlinker-script emits a warning when multiple entry points are |
| 4 | +# specified, and that the warning is suppressed without -Wlinker-script. |
| 5 | +# |
| 6 | +# Warning cases: |
| 7 | +# Case 1: Two ENTRY() in one script -- warns once with -Wlinker-script. |
| 8 | +# Case 2: -e combined with a single script ENTRY() -- warns with -Wlinker-script. |
| 9 | +# Case 3: Multiple -e on command line -- warns once with -Wlinker-script. |
| 10 | +# Case 4: Cross-script two ENTRY() -- warns with -Wlinker-script. |
| 11 | +# Case 5: Single ENTRY(), no -e -- no warning even with -Wlinker-script. |
| 12 | +# Case 6: Two ENTRY() without -Wlinker-script -- no warning. |
| 13 | +# Case 7: Three ENTRY() in one script -- warns once per overriding ENTRY(). |
| 14 | +#END_COMMENT |
| 15 | +#START_TEST |
| 16 | +RUN: %clang %clangopts -c %p/Inputs/1.c -o %t1.o -ffunction-sections |
| 17 | + |
| 18 | +# Case 1: Two ENTRY() in one script -- exactly one warning. |
| 19 | +RUN: %link %linkopts %t1.o -T %p/Inputs/two_entries.t -Wlinker-script -o %t.warn1.out 2>&1 | \ |
| 20 | +RUN: %filecheck %s --check-prefix=WARN1 |
| 21 | +#WARN1-COUNT-1: Warning: multiple entry points specified; the last one takes effect |
| 22 | +#WARN1-NOT: Warning: multiple entry points specified; the last one takes effect |
| 23 | + |
| 24 | +# Case 2: -e combined with a single script ENTRY() -- warn. |
| 25 | +RUN: %link %linkopts %t1.o -T %p/Inputs/script.t -e bar -Wlinker-script -o %t.warn2.out 2>&1 | \ |
| 26 | +RUN: %filecheck %s --check-prefix=WARN |
| 27 | +#WARN: Warning: multiple entry points specified; the last one takes effect |
| 28 | + |
| 29 | +# Case 3: Multiple -e on command line -- exactly one warning. |
| 30 | +RUN: %link %linkopts %t1.o -T %p/Inputs/script.t -e foo -e bar -Wlinker-script -o %t.warn3.out 2>&1 | \ |
| 31 | +RUN: %filecheck %s --check-prefix=WARN3 |
| 32 | +#WARN3-COUNT-1: Warning: multiple entry points specified; the last one takes effect |
| 33 | +#WARN3-NOT: Warning: multiple entry points specified; the last one takes effect |
| 34 | + |
| 35 | +# Case 4: Two ENTRY() across two scripts -- warn. |
| 36 | +RUN: %link %linkopts %t1.o -T %p/Inputs/entry_bar.t -T %p/Inputs/entry_foo.t -Wlinker-script -o %t.warn4.out 2>&1 | \ |
| 37 | +RUN: %filecheck %s --check-prefix=WARN |
| 38 | + |
| 39 | +# Case 5: Single ENTRY(), no -e -- no warning even with -Wlinker-script. |
| 40 | +RUN: %link %linkopts %t1.o -T %p/Inputs/script.t -Wlinker-script -o %t.nowarn1.out 2>&1 | \ |
| 41 | +RUN: %filecheck %s --allow-empty --check-prefix=NOWARN |
| 42 | +#NOWARN-NOT: multiple entry points |
| 43 | + |
| 44 | +# Case 6: Two ENTRY() without -Wlinker-script -- no warning. |
| 45 | +RUN: %link %linkopts %t1.o -T %p/Inputs/two_entries.t -o %t.nowarn2.out 2>&1 | \ |
| 46 | +RUN: %filecheck %s --allow-empty --check-prefix=NOWARN |
| 47 | + |
| 48 | +# Case 7: Three ENTRY() in one script -- one warning per overriding ENTRY() (two total). |
| 49 | +RUN: %link %linkopts %t1.o -T %p/Inputs/three_entries.t -Wlinker-script -o %t.warn7.out 2>&1 | \ |
| 50 | +RUN: %filecheck %s --check-prefix=WARN7 |
| 51 | +#WARN7-COUNT-2: Warning: multiple entry points specified; the last one takes effect |
| 52 | +#WARN7-NOT: Warning: multiple entry points specified; the last one takes effect |
| 53 | +#END_TEST |
0 commit comments