Skip to content

Commit 342ae04

Browse files
atanasyanliushuyu
authored andcommitted
[mips] Use pc-relative relocations in .eh_frame
Co-Authored-By: liushuyu <[email protected]>
1 parent 1e60c34 commit 342ae04

File tree

18 files changed

+114
-49
lines changed

18 files changed

+114
-49
lines changed

clang/include/clang/Basic/CodeGenOptions.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ CODEGENOPT(ForceDwarfFrameSection , 1, 0) ///< Set when -fforce-dwarf-frame is
118118
///< Set when -femit-compact-unwind-non-canonical is enabled.
119119
CODEGENOPT(EmitCompactUnwindNonCanonical, 1, 0)
120120

121+
///< Set when -mips-pc64-rel is enabled.
122+
CODEGENOPT(MipsPC64Relocation, 1, 0)
123+
121124
///< Set when -femit-dwarf-unwind is passed.
122125
ENUM_CODEGENOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
123126
llvm::EmitDwarfUnwindType::Default)

clang/include/clang/Driver/Options.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4351,6 +4351,9 @@ def mno_relax_pic_calls : Flag<["-"], "mno-relax-pic-calls">,
43514351
Group<m_mips_Features_Group>,
43524352
HelpText<"Do not produce relaxation hints for linkers to try optimizing PIC "
43534353
"call sequences into direct calls (MIPS only)">, Flags<[HelpHidden]>;
4354+
defm mips_pc64_rel : BoolOption<"", "mips-pc64-rel",
4355+
CodeGenOpts<"MipsPC64Relocation">, DefaultTrue,
4356+
PosFlag<SetTrue, [CC1Option, CC1AsOption], "Use MIPS 64-bit PC-relative relocations">, NegFlag<SetFalse>>;
43544357
def mglibc : Flag<["-"], "mglibc">, Group<m_libc_Group>, Flags<[HelpHidden]>;
43554358
def muclibc : Flag<["-"], "muclibc">, Group<m_libc_Group>, Flags<[HelpHidden]>;
43564359
def module_file_info : Flag<["-"], "module-file-info">, Flags<[NoXarchOption,CC1Option]>, Group<Action_Group>,

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
486486
Options.MCOptions.CommandLineArgs = CodeGenOpts.CommandLineArgs;
487487
Options.MCOptions.AsSecureLogFile = CodeGenOpts.AsSecureLogFile;
488488
Options.MisExpect = CodeGenOpts.MisExpect;
489+
Options.MCOptions.MipsPC64Relocation = CodeGenOpts.MipsPC64Relocation;
489490

490491
return true;
491492
}

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,6 +2013,16 @@ void Clang::AddMIPSTargetArgs(const ArgList &Args,
20132013
CmdArgs.push_back("-mips-jalr-reloc=0");
20142014
}
20152015
}
2016+
2017+
if (Arg *A = Args.getLastArg(options::OPT_mips_pc64_rel,
2018+
options::OPT_no_mips_pc64_rel)) {
2019+
CmdArgs.push_back("-mllvm");
2020+
if (A->getOption().matches(options::OPT_mips_pc64_rel))
2021+
CmdArgs.push_back("-mips-pc64-rel=true");
2022+
else
2023+
CmdArgs.push_back("-mips-pc64-rel=false");
2024+
A->claim();
2025+
}
20162026
}
20172027

20182028
void Clang::AddPPCTargetArgs(const ArgList &Args,

clang/test/Driver/mips-features.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,3 +456,15 @@
456456
// RUN: -mrelax-pic-calls -mno-relax-pic-calls 2>&1 \
457457
// RUN: | FileCheck --check-prefix=CHECK-NO-RELAX-PIC-CALLS %s
458458
// CHECK-NO-RELAX-PIC-CALLS: "-mllvm" "-mips-jalr-reloc=0"
459+
//
460+
// -mips-pc64-rel
461+
// RUN: %clang -target mips-unknown-linux-gnu -### -c %s \
462+
// RUN: -no-mips-pc64-rel -mips-pc64-rel 2>&1 \
463+
// RUN: | FileCheck --check-prefix=CHECK-PC64-REL %s
464+
// CHECK-PC64-REL-NOT: "-mllvm" "-mips-pc64-rel=false"
465+
//
466+
// -no-mips-pc64-rel
467+
// RUN: %clang -target mips-unknown-linux-gnu -### -c %s \
468+
// RUN: -mips-pc64-rel -no-mips-pc64-rel 2>&1 \
469+
// RUN: | FileCheck --check-prefix=CHECK-NO-PC64-REL %s
470+
// CHECK-NO-PC64-REL: "-mllvm" "-mips-pc64-rel=false"

clang/tools/driver/cc1as_main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ struct AssemblerInvocation {
147147
// Note: maybe overriden by other constraints.
148148
unsigned EmitCompactUnwindNonCanonical : 1;
149149

150+
unsigned MipsPC64Relocation : 1;
151+
150152
/// The name of the relocation model to use.
151153
std::string RelocationModel;
152154

@@ -411,6 +413,7 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
411413
MCTargetOptions MCOptions;
412414
MCOptions.EmitDwarfUnwind = Opts.EmitDwarfUnwind;
413415
MCOptions.EmitCompactUnwindNonCanonical = Opts.EmitCompactUnwindNonCanonical;
416+
MCOptions.MipsPC64Relocation = Opts.MipsPC64Relocation;
414417
MCOptions.AsSecureLogFile = Opts.AsSecureLogFile;
415418

416419
std::unique_ptr<MCAsmInfo> MAI(

lld/test/ELF/mips-eh_frame-pic.s

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
## relative addressing.
1313
# NOPIC-ERR: ld.lld: error: relocation R_MIPS_64 cannot be used against local symbol
1414

15-
## For -fPIC, .eh_frame should contain DW_EH_PE_pcrel | DW_EH_PE_sdata4 values:
15+
## For -fPIC, .eh_frame should contain DW_EH_PE_pcrel | DW_EH_PE_sdata8 values:
1616
# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux --position-independent %s -o %t-pic.o
1717
# RUN: llvm-readobj -r %t-pic.o | FileCheck %s --check-prefixes=RELOCS,PIC64-RELOCS
1818
# RUN: ld.lld -shared %t-pic.o -o %t-pic.so
19-
# RUN: llvm-dwarfdump --eh-frame %t-pic.so | FileCheck %s --check-prefix=PIC-EH-FRAME
19+
# RUN: llvm-dwarfdump --eh-frame %t-pic.so | FileCheck %s --check-prefix=PIC64-EH-FRAME
2020

2121
## Also check MIPS32:
2222
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t-nopic32.o
@@ -31,23 +31,23 @@
3131
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux --position-independent %s -o %t-pic32.o
3232
# RUN: llvm-readobj -r %t-pic32.o | FileCheck %s --check-prefixes=RELOCS,PIC32-RELOCS
3333
# RUN: ld.lld -shared %t-pic32.o -o %t-pic32.so
34-
# RUN: llvm-dwarfdump --eh-frame %t-pic32.so | FileCheck %s --check-prefix=PIC-EH-FRAME
34+
# RUN: llvm-dwarfdump --eh-frame %t-pic32.so | FileCheck %s --check-prefix=PIC32-EH-FRAME
3535

3636
# RELOCS: .rel{{a?}}.eh_frame {
3737
# ABS32-RELOCS-NEXT: 0x1C R_MIPS_32 .text
3838
# ABS64-RELOCS-NEXT: 0x1C R_MIPS_64/R_MIPS_NONE/R_MIPS_NONE .text
39-
# PIC64-RELOCS-NEXT: 0x1C R_MIPS_PC32/R_MIPS_NONE/R_MIPS_NONE <null>
39+
# PIC64-RELOCS-NEXT: 0x1C R_MIPS_PC32/R_MIPS_64/R_MIPS_NONE <null>
4040
# PIC32-RELOCS-NEXT: 0x1C R_MIPS_PC32 <null>
4141
# RELOCS-NEXT: }
4242

4343
# ABS64-EH-FRAME: Augmentation data: 0C
4444
## ^^ fde pointer encoding: DW_EH_PE_sdata8
4545
# ABS32-EH-FRAME: Augmentation data: 0B
4646
## ^^ fde pointer encoding: DW_EH_PE_sdata4
47-
# PIC-EH-FRAME: Augmentation data: 1B
48-
## ^^ fde pointer encoding: DW_EH_PE_pcrel | DW_EH_PE_sdata4
49-
## Note: ld.bfd converts the R_MIPS_64 relocs to DW_EH_PE_pcrel | DW_EH_PE_sdata8
50-
## for N64 ABI (and DW_EH_PE_pcrel | DW_EH_PE_sdata4 for MIPS32)
47+
# PIC32-EH-FRAME: Augmentation data: 1B
48+
## ^^ fde pointer encoding: DW_EH_PE_pcrel | DW_EH_PE_sdata4
49+
# PIC64-EH-FRAME: Augmentation data: 1C
50+
## ^^ fde pointer encoding: DW_EH_PE_pcrel | DW_EH_PE_sdata8
5151

5252
.ent func
5353
.global func

llvm/include/llvm/MC/MCContext.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,7 @@ class MCContext {
791791
unsigned getGenDwarfFileNumber() { return GenDwarfFileNumber; }
792792
EmitDwarfUnwindType emitDwarfUnwindInfo() const;
793793
bool emitCompactUnwindNonCanonical() const;
794+
bool getMipsPC64Relocation() const;
794795

795796
void setGenDwarfFileNumber(unsigned FileNumber) {
796797
GenDwarfFileNumber = FileNumber;

llvm/include/llvm/MC/MCTargetOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ class MCTargetOptions {
8989
// functions on Darwins.
9090
bool EmitCompactUnwindNonCanonical : 1;
9191

92+
// Whether to use MIPS 64-bit PC-relative relocations
93+
bool MipsPC64Relocation : 1;
94+
9295
MCTargetOptions();
9396

9497
/// getABIName - If this returns a non-empty string this represents the

llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ std::string getABIName();
5151

5252
std::string getAsSecureLogFile();
5353

54+
bool getMipsPC64Relocation();
55+
5456
/// Create this object with static storage to register mc-related command
5557
/// line options.
5658
struct RegisterMCTargetOptionsFlags {

llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,9 @@ void TargetLoweringObjectFileELF::Initialize(MCContext &Ctx,
212212
// identify N64 from just a triple.
213213
TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
214214
dwarf::DW_EH_PE_sdata4;
215-
// We don't support PC-relative LSDA references in GAS so we use the default
216-
// DW_EH_PE_absptr for those.
217215

218-
// FreeBSD must be explicit about the data size and using pcrel since it's
219-
// assembler/linker won't do the automatic conversion that the Linux tools
220-
// do.
221-
if (TgtM.getTargetTriple().isOSFreeBSD()) {
216+
if (isPositionIndependent() &&
217+
(TgtM.Options.MCOptions.MipsPC64Relocation || TgtM.getTargetTriple().isMIPS32())) {
222218
PersonalityEncoding |= dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
223219
LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
224220
}

llvm/lib/MC/MCContext.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,12 @@ bool MCContext::emitCompactUnwindNonCanonical() const {
932932
return false;
933933
}
934934

935+
bool MCContext::getMipsPC64Relocation() const {
936+
if (TargetOptions)
937+
return TargetOptions->MipsPC64Relocation;
938+
return false;
939+
}
940+
935941
void MCContext::setGenDwarfRootFile(StringRef InputFileName, StringRef Buffer) {
936942
// MCDwarf needs the root file as well as the compilation directory.
937943
// If we find a '.file 0' directive that will supersede these values.

llvm/lib/MC/MCObjectFileInfo.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -337,14 +337,11 @@ void MCObjectFileInfo::initELFMCObjectFileInfo(const Triple &T, bool Large) {
337337
case Triple::mipsel:
338338
case Triple::mips64:
339339
case Triple::mips64el:
340-
// We cannot use DW_EH_PE_sdata8 for the large PositionIndependent case
341-
// since there is no R_MIPS_PC64 relocation (only a 32-bit version).
342-
if (PositionIndependent && !Large)
343-
FDECFIEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
344-
else
345-
FDECFIEncoding = Ctx->getAsmInfo()->getCodePointerSize() == 4
346-
? dwarf::DW_EH_PE_sdata4
347-
: dwarf::DW_EH_PE_sdata8;
340+
FDECFIEncoding = Ctx->getAsmInfo()->getCodePointerSize() == 4
341+
? dwarf::DW_EH_PE_sdata4
342+
: dwarf::DW_EH_PE_sdata8;
343+
if (PositionIndependent && (Ctx->getMipsPC64Relocation() || T.isMIPS32()))
344+
FDECFIEncoding |= dwarf::DW_EH_PE_pcrel;
348345
break;
349346
case Triple::ppc64:
350347
case Triple::ppc64le:

llvm/lib/MC/MCTargetOptions.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ MCTargetOptions::MCTargetOptions()
1919
PreserveAsmComments(true), Dwarf64(false),
2020
EmitDwarfUnwind(EmitDwarfUnwindType::Default),
2121
MCUseDwarfDirectory(DefaultDwarfDirectory),
22-
EmitCompactUnwindNonCanonical(false) {}
22+
EmitCompactUnwindNonCanonical(false),
23+
MipsPC64Relocation(true) {}
2324

2425
StringRef MCTargetOptions::getABIName() const {
2526
return ABIName;

llvm/lib/MC/MCTargetOptionsCommandFlags.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ MCOPT(bool, NoDeprecatedWarn)
4747
MCOPT(bool, NoTypeCheck)
4848
MCOPT(std::string, ABIName)
4949
MCOPT(std::string, AsSecureLogFile)
50+
MCOPT(bool, MipsPC64Relocation)
5051

5152
llvm::mc::RegisterMCTargetOptionsFlags::RegisterMCTargetOptionsFlags() {
5253
#define MCBINDOPT(NAME) \
@@ -128,6 +129,13 @@ llvm::mc::RegisterMCTargetOptionsFlags::RegisterMCTargetOptionsFlags() {
128129
"as-secure-log-file", cl::desc("As secure log file name"), cl::Hidden);
129130
MCBINDOPT(AsSecureLogFile);
130131

132+
static cl::opt<bool> MipsPC64Relocation(
133+
"mips-pc64-rel", cl::Hidden,
134+
cl::desc(
135+
"Whether to MIPS 64-bit PC-relative relocations"),
136+
cl::init(true));
137+
MCBINDOPT(MipsPC64Relocation);
138+
131139
#undef MCBINDOPT
132140
}
133141

@@ -146,6 +154,7 @@ MCTargetOptions llvm::mc::InitMCTargetOptionsFromFlags() {
146154
Options.EmitDwarfUnwind = getEmitDwarfUnwind();
147155
Options.EmitCompactUnwindNonCanonical = getEmitCompactUnwindNonCanonical();
148156
Options.AsSecureLogFile = getAsSecureLogFile();
157+
Options.MipsPC64Relocation = getMipsPC64Relocation();
149158

150159
return Options;
151160
}

llvm/test/CodeGen/Mips/ehframe-indirect.ll

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,40 @@
11
; RUN: llc -mtriple=mipsel-linux-gnu < %s -asm-verbose -relocation-model=pic | \
22
; RUN: FileCheck -check-prefixes=ALL,LINUX,LINUX-O32,O32 %s
3+
; RUN: llc -mtriple=mipsel-linux-android < %s -asm-verbose -relocation-model=pic | \
4+
; RUN: FileCheck -check-prefixes=ALL,LINUX,LINUX-O32,O32 %s
35
; RUN: llc -mtriple=mips64el-linux-gnu -target-abi=n32 < %s -asm-verbose -relocation-model=pic | \
4-
; RUN: FileCheck -check-prefixes=ALL,LINUX,LINUX-NEW,N32 %s
6+
; RUN: FileCheck -check-prefixes=ALL,N32,N32REL %s
57
; RUN: llc -mtriple=mips64el-linux-gnu < %s -asm-verbose -relocation-model=pic | \
6-
; RUN: FileCheck -check-prefixes=ALL,LINUX,LINUX-NEW,N64 %s
8+
; RUN: FileCheck -check-prefixes=ALL,LINUX,LINUX-NEW,N64,N64REL %s
9+
; RUN: llc -mtriple=mips64el-linux-android < %s -asm-verbose -relocation-model=pic | \
10+
; RUN: FileCheck -check-prefixes=ALL,LINUX,LINUX-NEW,N64,N64REL %s
711
; RUN: llc -mtriple=mips64el-linux-gnu < %s -asm-verbose -relocation-model=pic | \
8-
; RUN: FileCheck -check-prefixes=ALL,LINUX,LINUX-NEW,N64 %s
9-
; RUN: llc -mtriple=mips-unknown-freebsd11.0 < %s -asm-verbose -relocation-model=pic | \
10-
; RUN: FileCheck -check-prefixes=ALL,FREEBSD,FREEBSD-O32,O32 %s
12+
; RUN: FileCheck -check-prefixes=ALL,N64,N64REL %s
1113
; RUN: llc -mtriple=mips64-unknown-freebsd11.0 < %s -asm-verbose -relocation-model=pic | \
12-
; RUN: FileCheck -check-prefixes=ALL,FREEBSD,FREEBSD-NEW,N64 %s
14+
; RUN: FileCheck -check-prefixes=ALL,N64,N64REL %s
15+
16+
; RUN: llc -mtriple=mips64-linux-gnu -target-abi=n32 -mips-pc64-rel=false \
17+
; RUN: -asm-verbose -relocation-model=pic < %s | \
18+
; RUN: FileCheck -check-prefixes=ALL,N32,N32ABS %s
19+
; RUN: llc -mtriple=mips64-linux-gnu -mips-pc64-rel=false \
20+
; RUN: -asm-verbose -relocation-model=pic < %s | \
21+
; RUN: FileCheck -check-prefixes=ALL,N64,N64ABS %s
1322

1423
@_ZTISt9exception = external constant ptr
1524

1625
define i32 @main() personality ptr @__gxx_personality_v0 {
1726
; ALL: .cfi_startproc
1827

19-
; Linux must rely on the assembler/linker converting the encodings.
20-
; LINUX: .cfi_personality 128, DW.ref.__gxx_personality_v0
21-
; LINUX-O32: .cfi_lsda 0, $exception0
22-
; LINUX-NEW: .cfi_lsda 0, .Lexception0
23-
24-
; FreeBSD can (and must) be more direct about the encodings it wants.
25-
; FREEBSD: .cfi_personality 155, DW.ref.__gxx_personality_v0
26-
; FREEBSD-O32: .cfi_lsda 27, $exception0
27-
; FREEBSD-NEW: .cfi_lsda 27, .Lexception0
28+
; O32: .cfi_personality 155, DW.ref.__gxx_personality_v0
29+
; O32: .cfi_lsda 27, $exception0
30+
; N32REL: .cfi_personality 155, DW.ref.__gxx_personality_v0
31+
; N32REL: .cfi_lsda 27, .Lexception0
32+
; N32ABS: .cfi_personality 128, DW.ref.__gxx_personality_v0
33+
; N32ABS: .cfi_lsda 0, .Lexception0
34+
; N64REL: .cfi_personality 155, DW.ref.__gxx_personality_v0
35+
; N64REL: .cfi_lsda 27, .Lexception0
36+
; N64ABS: .cfi_personality 128, DW.ref.__gxx_personality_v0
37+
; N64ABS: .cfi_lsda 0, .Lexception0
2838

2939
entry:
3040
invoke void @foo() to label %cont unwind label %lpad

llvm/test/DebugInfo/Mips/eh_frame.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
; STATIC-DAG: R_MIPS_32 00000000 .gcc_except_table
1818

1919
; PIC-LABEL: Relocation section '.rel.eh_frame'
20-
; PIC-DAG: R_MIPS_32 00000000 DW.ref.__gxx_personality_v0
20+
; PIC-DAG: R_MIPS_PC32 00000000 DW.ref.__gxx_personality_v0
21+
; PIC-DAG: R_MIPS_PC32
2122
; PIC-DAG: R_MIPS_PC32
22-
; PIC-DAG: R_MIPS_32 00000000 .gcc_except_table
2323

2424
; CHECK-READELF: DW.ref.__gxx_personality_v0
2525
; CHECK-READELF-STATIC-NEXT: R_MIPS_32 00000000 .text

llvm/test/MC/Mips/eh-frame.s

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,18 @@
3333
// RUN: llvm-readobj -r %t.o | FileCheck --check-prefixes=RELOCS,PIC64 %s
3434
// RUN: llvm-dwarfdump -eh-frame %t.o | FileCheck --check-prefixes=DWARF64,DWARF64_PIC %s
3535

36-
/// However using the large code model forces R_MIPS_64 since there is no R_MIPS_PC64 relocation:
3736
// RUN: llvm-mc -filetype=obj %s -o %t.o -triple mips64-unknown-linux-gnu --position-independent --large-code-model
38-
// RUN: llvm-readobj -r %t.o | FileCheck --check-prefixes=RELOCS,ABS64 %s
39-
// RUN: llvm-dwarfdump -eh-frame %t.o | FileCheck --check-prefixes=DWARF64,DWARF64_ABS %s
37+
// RUN: llvm-readobj -r %t.o | FileCheck --check-prefixes=RELOCS,PIC64 %s
38+
// RUN: llvm-dwarfdump -eh-frame %t.o | FileCheck --check-prefixes=DWARF64,DWARF64_PIC %s
4039

4140
// RUN: llvm-mc -filetype=obj %s -o %t.o -triple mips64el-unknown-linux-gnu --position-independent --large-code-model
42-
// RUN: llvm-readobj -r %t.o | FileCheck --check-prefixes=RELOCS,ABS64 %s
43-
// RUN: llvm-dwarfdump -eh-frame %t.o | FileCheck --check-prefixes=DWARF64,DWARF64_ABS %s
41+
// RUN: llvm-readobj -r %t.o | FileCheck --check-prefixes=RELOCS,PIC64 %s
42+
// RUN: llvm-dwarfdump -eh-frame %t.o | FileCheck --check-prefixes=DWARF64,DWARF64_PIC %s
43+
44+
// RUN: llvm-mc -filetype=obj %s -o %t.o -triple mips64-unknown-linux-gnu \
45+
// RUN: --position-independent --large-code-model -mips-pc64-rel=false
46+
// RUN: llvm-readobj -r %t.o | FileCheck --check-prefixes=RELOCS,OLD64 %s
47+
// RUN: llvm-dwarfdump -eh-frame %t.o | FileCheck --check-prefixes=DWARF64,DWARF64_OLD %s
4448

4549
func:
4650
.cfi_startproc
@@ -51,7 +55,8 @@ func:
5155
// ABS32-NEXT: R_MIPS_32
5256
// ABS64-NEXT: R_MIPS_64/R_MIPS_NONE/R_MIPS_NONE
5357
// PIC32-NEXT: R_MIPS_PC32
54-
// PIC64-NEXT: R_MIPS_PC32/R_MIPS_NONE/R_MIPS_NONE
58+
// PIC64-NEXT: R_MIPS_PC32/R_MIPS_64/R_MIPS_NONE
59+
// OLD64-NEXT: R_MIPS_64/R_MIPS_NONE/R_MIPS_NONE
5560
// RELOCS-NEXT: }
5661

5762
// DWARF32: 00000000 00000010 00000000 CIE
@@ -87,14 +92,17 @@ func:
8792
// DWARF64-NEXT: Return address column: 31
8893
// DWARF64_ABS-NEXT: Augmentation data: 0C
8994
// ^^ fde pointer encoding: DW_EH_PE_sdata8
90-
// DWARF64_PIC: Augmentation data: 1B
91-
// ^^ fde pointer encoding: DW_EH_PE_pcrel | DW_EH_PE_sdata4
95+
// DWARF64_PIC: Augmentation data: 1C
96+
// ^^ fde pointer encoding: DW_EH_PE_pcrel | DW_EH_PE_sdata8
97+
// DWARF64_OLD: Augmentation data: 0C
98+
// ^^ fde pointer encoding: DW_EH_PE_sdata8
9299
// DWARF64-EMPTY:
93100
// DWARF64-NEXT: DW_CFA_def_cfa_register: SP_64
94101
// DWARF64_PIC-NEXT: DW_CFA_nop:
95102
//
96103
// DWARF64_ABS: 00000014 00000018 00000018 FDE cie=00000000 pc=00000000...00000000
97-
// DWARF64_PIC: 00000014 00000010 00000018 FDE cie=00000000 pc=00000000...00000000
104+
// DWARF64_PIC: 00000014 00000018 00000018 FDE cie=00000000 pc=0000001c...0000001c
105+
// DWARF64_OLD: 00000014 00000018 00000018 FDE cie=00000000 pc=00000000...00000000
98106
// DWARF64-NEXT: Format: DWARF32
99107
// DWARF64-NEXT: DW_CFA_nop:
100108
// DWARF64-NEXT: DW_CFA_nop:

0 commit comments

Comments
 (0)