From e452b171306ac255dedc46a49defc866a65184c6 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 5 Oct 2010 19:42:57 +0000 Subject: [PATCH] Add support for a fill value in the .zero directive. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115655 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/MCParser/AsmParser.cpp | 9 ++++++++- test/MC/ELF/zero.s | 5 +++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp index 974e4ab0a64..e627ebb96fa 100644 --- a/lib/MC/MCParser/AsmParser.cpp +++ b/lib/MC/MCParser/AsmParser.cpp @@ -1498,12 +1498,19 @@ bool AsmParser::ParseDirectiveZero() { if (ParseAbsoluteExpression(NumBytes)) return true; + int64_t Val = 0; + if (getLexer().is(AsmToken::Comma)) { + Lex(); + if (ParseAbsoluteExpression(Val)) + return true; + } + if (getLexer().isNot(AsmToken::EndOfStatement)) return TokError("unexpected token in '.zero' directive"); Lex(); - getStreamer().EmitFill(NumBytes, 0, DEFAULT_ADDRSPACE); + getStreamer().EmitFill(NumBytes, Val, DEFAULT_ADDRSPACE); return false; } diff --git a/test/MC/ELF/zero.s b/test/MC/ELF/zero.s index 2ad21e60815..a7518e1e4fd 100644 --- a/test/MC/ELF/zero.s +++ b/test/MC/ELF/zero.s @@ -1,15 +1,16 @@ // RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump --dump-section-data | FileCheck %s .zero 4 +.zero 1,42 // CHECK: ('sh_name', 1) # '.text' // CHECK: ('sh_type', 1) // CHECK: ('sh_flags', 6) // CHECK: ('sh_addr', 0) // CHECK: ('sh_offset', 64) -// CHECK: ('sh_size', 4) +// CHECK: ('sh_size', 5) // CHECK: ('sh_link', 0) // CHECK: ('sh_info', 0) // CHECK: ('sh_addralign', 4) // CHECK: ('sh_entsize', 0) -// CHECK: ('_section_data', '00000000') +// CHECK: ('_section_data', '00000000 2a')