mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-28 06:24:57 +00:00
ELF: Add support for the asm .version directive.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156712 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -64,6 +64,7 @@ public:
|
|||||||
AddDirectiveHandler<&ELFAsmParser::ParseDirectiveType>(".type");
|
AddDirectiveHandler<&ELFAsmParser::ParseDirectiveType>(".type");
|
||||||
AddDirectiveHandler<&ELFAsmParser::ParseDirectiveIdent>(".ident");
|
AddDirectiveHandler<&ELFAsmParser::ParseDirectiveIdent>(".ident");
|
||||||
AddDirectiveHandler<&ELFAsmParser::ParseDirectiveSymver>(".symver");
|
AddDirectiveHandler<&ELFAsmParser::ParseDirectiveSymver>(".symver");
|
||||||
|
AddDirectiveHandler<&ELFAsmParser::ParseDirectiveVersion>(".version");
|
||||||
AddDirectiveHandler<&ELFAsmParser::ParseDirectiveWeakref>(".weakref");
|
AddDirectiveHandler<&ELFAsmParser::ParseDirectiveWeakref>(".weakref");
|
||||||
AddDirectiveHandler<&ELFAsmParser::ParseDirectiveSymbolAttribute>(".weak");
|
AddDirectiveHandler<&ELFAsmParser::ParseDirectiveSymbolAttribute>(".weak");
|
||||||
AddDirectiveHandler<&ELFAsmParser::ParseDirectiveSymbolAttribute>(".local");
|
AddDirectiveHandler<&ELFAsmParser::ParseDirectiveSymbolAttribute>(".local");
|
||||||
@ -141,6 +142,7 @@ public:
|
|||||||
bool ParseDirectiveType(StringRef, SMLoc);
|
bool ParseDirectiveType(StringRef, SMLoc);
|
||||||
bool ParseDirectiveIdent(StringRef, SMLoc);
|
bool ParseDirectiveIdent(StringRef, SMLoc);
|
||||||
bool ParseDirectiveSymver(StringRef, SMLoc);
|
bool ParseDirectiveSymver(StringRef, SMLoc);
|
||||||
|
bool ParseDirectiveVersion(StringRef, SMLoc);
|
||||||
bool ParseDirectiveWeakref(StringRef, SMLoc);
|
bool ParseDirectiveWeakref(StringRef, SMLoc);
|
||||||
bool ParseDirectiveSymbolAttribute(StringRef, SMLoc);
|
bool ParseDirectiveSymbolAttribute(StringRef, SMLoc);
|
||||||
|
|
||||||
@ -548,6 +550,32 @@ bool ELFAsmParser::ParseDirectiveSymver(StringRef, SMLoc) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ParseDirectiveVersion
|
||||||
|
/// ::= .version string
|
||||||
|
bool ELFAsmParser::ParseDirectiveVersion(StringRef, SMLoc) {
|
||||||
|
if (getLexer().isNot(AsmToken::String))
|
||||||
|
return TokError("unexpected token in '.version' directive");
|
||||||
|
|
||||||
|
StringRef Data = getTok().getIdentifier();
|
||||||
|
|
||||||
|
Lex();
|
||||||
|
|
||||||
|
const MCSection *Note =
|
||||||
|
getContext().getELFSection(".note", ELF::SHT_NOTE, 0,
|
||||||
|
SectionKind::getReadOnly());
|
||||||
|
|
||||||
|
getStreamer().PushSection();
|
||||||
|
getStreamer().SwitchSection(Note);
|
||||||
|
getStreamer().EmitIntValue(Data.size()+1, 4); // namesz.
|
||||||
|
getStreamer().EmitIntValue(0, 4); // descsz = 0 (no description).
|
||||||
|
getStreamer().EmitIntValue(1, 4); // type = NT_VERSION.
|
||||||
|
getStreamer().EmitBytes(Data, 0); // name.
|
||||||
|
getStreamer().EmitIntValue(0, 1); // terminate the string.
|
||||||
|
getStreamer().EmitValueToAlignment(4); // ensure 4 byte alignment.
|
||||||
|
getStreamer().PopSection();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// ParseDirectiveWeakref
|
/// ParseDirectiveWeakref
|
||||||
/// ::= .weakref foo, bar
|
/// ::= .weakref foo, bar
|
||||||
bool ELFAsmParser::ParseDirectiveWeakref(StringRef, SMLoc) {
|
bool ELFAsmParser::ParseDirectiveWeakref(StringRef, SMLoc) {
|
||||||
|
17
test/MC/ELF/version.s
Normal file
17
test/MC/ELF/version.s
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// RUN: llvm-mc -filetype=obj -triple i386-pc-linux-gnu %s -o - | elf-dump --dump-section-data | FileCheck %s
|
||||||
|
|
||||||
|
.version "1234"
|
||||||
|
.version "123"
|
||||||
|
|
||||||
|
// CHECK: (('sh_name', 0x0000000c) # '.note'
|
||||||
|
// CHECK-NEXT: ('sh_type', 0x00000007)
|
||||||
|
// CHECK-NEXT: ('sh_flags', 0x00000000)
|
||||||
|
// CHECK-NEXT: ('sh_addr', 0x00000000)
|
||||||
|
// CHECK-NEXT: ('sh_offset', 0x00000034)
|
||||||
|
// CHECK-NEXT: ('sh_size', 0x00000024)
|
||||||
|
// CHECK-NEXT: ('sh_link', 0x00000000)
|
||||||
|
// CHECK-NEXT: ('sh_info', 0x00000000)
|
||||||
|
// CHECK-NEXT: ('sh_addralign', 0x00000004)
|
||||||
|
// CHECK-NEXT: ('sh_entsize', 0x00000000)
|
||||||
|
// CHECK-NEXT: ('_section_data', '05000000 00000000 01000000 31323334 00000000 04000000 00000000 01000000 31323300')
|
||||||
|
// CHECK-NEXT: ),
|
Reference in New Issue
Block a user