Skip to content

Commit 09f0151

Browse files
committed
[Driver] Add option to force udnefined symbols during linking in BareMetal
toolchain object. Add support for `-u` option to force defined symbols. This option is supported by both lld and gnuld. This is done as a part of the effort to merge RISCVToolchain object into BareMetal toolchain object. This is the 4th patch in the series of patches for merging RISCVToolchain object into BareMetal toolchain object. RFC: https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524 Change-Id: Ia6597c756923a77fd9c7cb9a6ae8e52a56f5457d
1 parent 2d1b254 commit 09f0151

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

Diff for: clang/lib/Driver/ToolChains/BareMetal.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,9 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA,
566566
}
567567
}
568568

569-
Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
570-
options::OPT_s, options::OPT_t, options::OPT_r});
569+
Args.addAllArgs(CmdArgs,
570+
{options::OPT_L, options::OPT_u, options::OPT_T_Group,
571+
options::OPT_s, options::OPT_t, options::OPT_r});
571572

572573
TC.AddFilePathLibArgs(Args, CmdArgs);
573574

Diff for: clang/test/Driver/riscv-args.c

-6
This file was deleted.

Diff for: clang/test/Driver/undefined-symbols.c

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Check the arguments are correctly passed
2+
3+
// Make sure -T is the last with gcc-toolchain option
4+
// RUN: %clang -### --target=riscv32 --gcc-toolchain= -Xlinker --defsym=FOO=10 -T a.lds -u foo %s 2>&1 \
5+
// RUN: | FileCheck -check-prefix=CHECK-LD %s
6+
// CHECK-LD: {{.*}} "--defsym=FOO=10" {{.*}} "-u" "foo" {{.*}} "-T" "a.lds"
7+
8+
// TODO: Merge this test with the above in the last patch when finally integrating riscv
9+
// Make sure -T is the last with gcc-toolchain option
10+
// RUN: %clang -### --target=aarch64-none-elf --gcc-toolchain= -Xlinker --defsym=FOO=10 -T a.lds -u foo %s 2>&1 \
11+
// RUN: | FileCheck -check-prefix=CHECK-ARM-LD %s
12+
// RUN: %clang -### --target=armv6m-none-eabi --gcc-toolchain= -Xlinker --defsym=FOO=10 -T a.lds -u foo %s 2>&1 \
13+
// RUN: | FileCheck -check-prefix=CHECK-ARM-LD %s
14+
// CHECK-ARM-LD: {{.*}} "-T" "a.lds" "-u" "foo" {{.*}} "--defsym=FOO=10"
15+

0 commit comments

Comments
 (0)