mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-11 07:15:26 +00:00
Implement cfi_rel_offset
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129306 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3f5bedf5cb
commit
a61842bf6e
@ -80,6 +80,10 @@ private:
|
||||
SourceMgr &SrcMgr;
|
||||
MCAsmParserExtension *GenericParser;
|
||||
MCAsmParserExtension *PlatformParser;
|
||||
|
||||
// FIXME: This is not the best place to store this. To handle a (for example)
|
||||
// .cfi_rel_offset before a .cfi_def_cfa_offset we need to know the initial
|
||||
// frame state.
|
||||
int64_t LastOffset;
|
||||
|
||||
/// This is the current buffer index we're lexing from as managed by the
|
||||
@ -145,6 +149,9 @@ public:
|
||||
LastOffset += Adjustment;
|
||||
return LastOffset;
|
||||
}
|
||||
int64_t getLastOffset() {
|
||||
return LastOffset;
|
||||
}
|
||||
void setLastOffset(int64_t Offset) {
|
||||
LastOffset = Offset;
|
||||
}
|
||||
@ -266,6 +273,8 @@ public:
|
||||
".cfi_def_cfa_register");
|
||||
AddDirectiveHandler<&GenericAsmParser::ParseDirectiveCFIOffset>(
|
||||
".cfi_offset");
|
||||
AddDirectiveHandler<&GenericAsmParser::ParseDirectiveCFIRelOffset>(
|
||||
".cfi_rel_offset");
|
||||
AddDirectiveHandler<
|
||||
&GenericAsmParser::ParseDirectiveCFIPersonalityOrLsda>(".cfi_personality");
|
||||
AddDirectiveHandler<
|
||||
@ -301,6 +310,7 @@ public:
|
||||
bool ParseDirectiveCFIAdjustCfaOffset(StringRef, SMLoc DirectiveLoc);
|
||||
bool ParseDirectiveCFIDefCfaRegister(StringRef, SMLoc DirectiveLoc);
|
||||
bool ParseDirectiveCFIOffset(StringRef, SMLoc DirectiveLoc);
|
||||
bool ParseDirectiveCFIRelOffset(StringRef, SMLoc DirectiveLoc);
|
||||
bool ParseDirectiveCFIPersonalityOrLsda(StringRef, SMLoc DirectiveLoc);
|
||||
bool ParseDirectiveCFIRememberState(StringRef, SMLoc DirectiveLoc);
|
||||
bool ParseDirectiveCFIRestoreState(StringRef, SMLoc DirectiveLoc);
|
||||
@ -2351,7 +2361,7 @@ bool GenericAsmParser::ParseDirectiveCFIDefCfaRegister(StringRef,
|
||||
}
|
||||
|
||||
/// ParseDirectiveCFIOffset
|
||||
/// ::= .cfi_off register, offset
|
||||
/// ::= .cfi_offset register, offset
|
||||
bool GenericAsmParser::ParseDirectiveCFIOffset(StringRef, SMLoc DirectiveLoc) {
|
||||
int64_t Register = 0;
|
||||
int64_t Offset = 0;
|
||||
@ -2369,6 +2379,28 @@ bool GenericAsmParser::ParseDirectiveCFIOffset(StringRef, SMLoc DirectiveLoc) {
|
||||
return getStreamer().EmitCFIOffset(Register, Offset);
|
||||
}
|
||||
|
||||
/// ParseDirectiveCFIRelOffset
|
||||
/// ::= .cfi_rel_offset register, offset
|
||||
bool GenericAsmParser::ParseDirectiveCFIRelOffset(StringRef,
|
||||
SMLoc DirectiveLoc) {
|
||||
int64_t Register = 0;
|
||||
|
||||
if (ParseRegisterOrRegisterNumber(Register, DirectiveLoc))
|
||||
return true;
|
||||
|
||||
if (getLexer().isNot(AsmToken::Comma))
|
||||
return TokError("unexpected token in directive");
|
||||
Lex();
|
||||
|
||||
int64_t Offset = 0;
|
||||
if (getParser().ParseAbsoluteExpression(Offset))
|
||||
return true;
|
||||
|
||||
Offset -= getParser().getLastOffset();
|
||||
|
||||
return getStreamer().EmitCFIOffset(Register, Offset);
|
||||
}
|
||||
|
||||
static bool isValidEncoding(int64_t Encoding) {
|
||||
if (Encoding & ~0xff)
|
||||
return false;
|
||||
|
49
test/MC/ELF/cfi-rel-offset.s
Normal file
49
test/MC/ELF/cfi-rel-offset.s
Normal file
@ -0,0 +1,49 @@
|
||||
// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump --dump-section-data | FileCheck %s
|
||||
|
||||
f:
|
||||
.cfi_startproc
|
||||
nop
|
||||
.cfi_def_cfa_offset 8
|
||||
nop
|
||||
.cfi_def_cfa_register 6
|
||||
nop
|
||||
.cfi_rel_offset 6,16
|
||||
nop
|
||||
.cfi_def_cfa_offset 16
|
||||
nop
|
||||
.cfi_rel_offset 6,0
|
||||
.cfi_endproc
|
||||
|
||||
// CHECK: # Section 0x00000004
|
||||
// CHECK-NEXT: (('sh_name', 0x00000011) # '.eh_frame'
|
||||
// CHECK-NEXT: ('sh_type', 0x00000001)
|
||||
// CHECK-NEXT: ('sh_flags', 0x00000002)
|
||||
// CHECK-NEXT: ('sh_addr', 0x00000000)
|
||||
// CHECK-NEXT: ('sh_offset', 0x00000048)
|
||||
// CHECK-NEXT: ('sh_size', 0x00000040)
|
||||
// CHECK-NEXT: ('sh_link', 0x00000000)
|
||||
// CHECK-NEXT: ('sh_info', 0x00000000)
|
||||
// CHECK-NEXT: ('sh_addralign', 0x00000008)
|
||||
// CHECK-NEXT: ('sh_entsize', 0x00000000)
|
||||
// CHECK-NEXT: ('_section_data', '14000000 00000000 017a5200 01781001 1b0c0708 90010000 24000000 1c000000 00000000 05000000 00410e08 410d0641 11067f41 0e104186 02000000 00000000')
|
||||
// CHECK-NEXT: ),
|
||||
// CHECK-NEXT: # Section 0x00000005
|
||||
// CHECK-NEXT: (('sh_name', 0x0000000c) # '.rela.eh_frame'
|
||||
// CHECK-NEXT: ('sh_type', 0x00000004)
|
||||
// CHECK-NEXT: ('sh_flags', 0x00000000)
|
||||
// CHECK-NEXT: ('sh_addr', 0x00000000)
|
||||
// CHECK-NEXT: ('sh_offset', 0x000003a0)
|
||||
// CHECK-NEXT: ('sh_size', 0x00000018)
|
||||
// CHECK-NEXT: ('sh_link', 0x00000007)
|
||||
// CHECK-NEXT: ('sh_info', 0x00000004)
|
||||
// CHECK-NEXT: ('sh_addralign', 0x00000008)
|
||||
// CHECK-NEXT: ('sh_entsize', 0x00000018)
|
||||
// CHECK-NEXT: ('_relocations', [
|
||||
// CHECK-NEXT: # Relocation 0x00000000
|
||||
// CHECK-NEXT: (('r_offset', 0x00000020)
|
||||
// CHECK-NEXT: ('r_sym', 0x00000002)
|
||||
// CHECK-NEXT: ('r_type', 0x00000002)
|
||||
// CHECK-NEXT: ('r_addend', 0x00000000)
|
||||
// CHECK-NEXT: ),
|
||||
// CHECK-NEXT: ])
|
||||
// CHECK-NEXT: ),
|
Loading…
x
Reference in New Issue
Block a user