Skip to content

Commit 4f33d4e

Browse files
committed
[𝘀𝗽𝗿] initial version
Created using spr 1.3.4
2 parents cc2fe7b + edc6254 commit 4f33d4e

File tree

23 files changed

+178
-12
lines changed

23 files changed

+178
-12
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7954,6 +7954,8 @@ def dwarf_debug_producer : Separate<["-"], "dwarf-debug-producer">,
79547954
def defsym : Separate<["-"], "defsym">,
79557955
HelpText<"Define a value for a symbol">;
79567956

7957+
def fdpic : Flag<["--"], "fdpic">, HelpText<"Enable FDPIC ABI (ARM only)">;
7958+
79577959
} // let Visibility = [CC1AsOption]
79587960

79597961
//===----------------------------------------------------------------------===//

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2530,6 +2530,10 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
25302530
case llvm::Triple::thumbeb:
25312531
case llvm::Triple::arm:
25322532
case llvm::Triple::armeb:
2533+
if (Value == "--fdpic") {
2534+
CmdArgs.push_back("--fdpic");
2535+
continue;
2536+
}
25332537
if (Value.starts_with("-mimplicit-it=")) {
25342538
// Only store the value; the last value set takes effect.
25352539
ImplicitIt = Value.split("=").second;

clang/test/Driver/arm-ias-Wa.s

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,5 @@
7979
// RUN: | FileCheck -check-prefix=CHECK-M-PROFILE %s
8080
// CHECK-M-PROFILE: "-triple" "thumbv7m-{{.*}}"
8181

82+
// RUN: %clang --target=arm-unknown-linuxfdpiceabi -Wa,--fdpic -c %s -### 2>&1 | FileCheck --check-prefix=FDPIC %s
83+
// FDPIC: "--fdpic"

clang/test/Misc/cc1as-arm-fdpic.s

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// REQUIRES: arm-registered-target
2+
3+
// RUN: %clang -cc1as -triple armv7-unknown-linuxfdpiceabi -filetype obj --fdpic %s -o %t
4+
// RUN: llvm-readelf -h -r %t | FileCheck %s
5+
6+
// CHECK: OS/ABI: ARM FDPIC
7+
// CHECK: R_ARM_FUNCDESC
8+
9+
.data
10+
.word f(FUNCDESC)

clang/tools/driver/cc1as_main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ struct AssemblerInvocation {
154154
LLVM_PREFERRED_TYPE(bool)
155155
unsigned IncrementalLinkerCompatible : 1;
156156
LLVM_PREFERRED_TYPE(bool)
157+
unsigned FDPIC : 1;
158+
LLVM_PREFERRED_TYPE(bool)
157159
unsigned EmbedBitcode : 1;
158160

159161
/// Whether to emit DWARF unwind info.
@@ -346,6 +348,7 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
346348
Opts.FatalWarnings = Args.hasArg(OPT_massembler_fatal_warnings);
347349
Opts.NoWarn = Args.hasArg(OPT_massembler_no_warn);
348350
Opts.NoTypeCheck = Args.hasArg(OPT_mno_type_check);
351+
Opts.FDPIC = Args.hasArg(OPT_fdpic);
349352
Opts.RelocationModel =
350353
std::string(Args.getLastArgValue(OPT_mrelocation_model, "pic"));
351354
Opts.TargetABI = std::string(Args.getLastArgValue(OPT_target_abi));
@@ -520,6 +523,7 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
520523
MCOptions.MCNoWarn = Opts.NoWarn;
521524
MCOptions.MCFatalWarnings = Opts.FatalWarnings;
522525
MCOptions.MCNoTypeCheck = Opts.NoTypeCheck;
526+
MCOptions.FDPIC = Opts.FDPIC;
523527
MCOptions.ABIName = Opts.TargetABI;
524528

525529
// FIXME: There is a bit of code duplication with addPassesToEmitFile.

llvm/include/llvm/BinaryFormat/ELF.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ enum {
362362
ELFOSABI_AMDGPU_PAL = 65, // AMD PAL runtime
363363
ELFOSABI_AMDGPU_MESA3D = 66, // AMD GCN GPUs (GFX6+) for MESA runtime
364364
ELFOSABI_ARM = 97, // ARM
365+
ELFOSABI_ARM_FDPIC = 65, // ARM FDPIC
365366
ELFOSABI_C6000_ELFABI = 64, // Bare-metal TMS320C6000
366367
ELFOSABI_C6000_LINUX = 65, // Linux TMS320C6000
367368
ELFOSABI_STANDALONE = 255, // Standalone (embedded) application

llvm/include/llvm/BinaryFormat/ELFRelocs/ARM.def

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,10 @@ ELF_RELOC(R_ARM_THM_BF16, 0x88)
143143
ELF_RELOC(R_ARM_THM_BF12, 0x89)
144144
ELF_RELOC(R_ARM_THM_BF18, 0x8a)
145145
ELF_RELOC(R_ARM_IRELATIVE, 0xa0)
146+
ELF_RELOC(R_ARM_GOTFUNCDESC, 0xa1)
147+
ELF_RELOC(R_ARM_GOTOFFFUNCDESC, 0xa2)
148+
ELF_RELOC(R_ARM_FUNCDESC, 0xa3)
149+
ELF_RELOC(R_ARM_FUNCDESC_VALUE, 0xa4)
150+
ELF_RELOC(R_ARM_TLS_GD32_FDPIC, 0xa5)
151+
ELF_RELOC(R_ARM_TLS_LDM32_FDPIC, 0xa6)
152+
ELF_RELOC(R_ARM_TLS_IE32_FDPIC, 0xa7)

llvm/include/llvm/MC/MCExpr.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ class MCSymbolRefExpr : public MCExpr {
223223
VK_SECREL,
224224
VK_SIZE, // symbol@SIZE
225225
VK_WEAKREF, // The link between the symbols in .weakref foo, bar
226+
VK_FUNCDESC,
227+
VK_GOTFUNCDESC,
228+
VK_GOTOFFFUNCDESC,
229+
VK_TLSGD_FDPIC,
230+
VK_TLSLDM_FDPIC,
231+
VK_GOTTPOFF_FDPIC,
226232

227233
VK_X86_ABS8,
228234
VK_X86_PLTOFF,

llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,10 @@ class MCTargetAsmParser : public MCAsmParserExtension {
525525
// Return whether this parser accept star as start of statement
526526
virtual bool starIsStartOfStatement() { return false; };
527527

528+
virtual MCSymbolRefExpr::VariantKind
529+
getVariantKindForName(StringRef Name) const {
530+
return MCSymbolRefExpr::getVariantKindForName(Name);
531+
}
528532
virtual const MCExpr *applyModifierToExpr(const MCExpr *E,
529533
MCSymbolRefExpr::VariantKind,
530534
MCContext &Ctx) {

llvm/include/llvm/MC/MCTargetOptions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class MCTargetOptions {
5151
bool MCNoTypeCheck : 1;
5252
bool MCSaveTempLabels : 1;
5353
bool MCIncrementalLinkerCompatible : 1;
54+
bool FDPIC : 1;
5455
bool ShowMCEncoding : 1;
5556
bool ShowMCInst : 1;
5657
bool AsmVerbose : 1;

0 commit comments

Comments
 (0)