Skip to content

Commit 789d8f2

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 9c67ffb commit 789d8f2

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

clang/lib/Driver/ToolChains/BareMetal.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,9 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA,
570570
}
571571
}
572572

573-
Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
574-
options::OPT_s, options::OPT_t, options::OPT_r});
573+
Args.addAllArgs(CmdArgs,
574+
{options::OPT_L, options::OPT_u, options::OPT_T_Group,
575+
options::OPT_s, options::OPT_t, options::OPT_r});
575576

576577
TC.AddFilePathLibArgs(Args, CmdArgs);
577578

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+

clang/test/Driver/riscv-args.c

-6
This file was deleted.

0 commit comments

Comments
 (0)