Index: ELF/LinkerScript.cpp =================================================================== --- ELF/LinkerScript.cpp +++ ELF/LinkerScript.cpp @@ -799,13 +799,21 @@ StringRef Tok = peek(); if (!Tok.startswith("=")) return {}; - if (!Tok.startswith("=0x")) { - setError("filler should be a hexadecimal value"); + if (Tok.startswith("=0x")) { + next(); + return parseHex(Tok.substr(3)); + } + // This must be a decimal. + Tok = Tok.substr(1); + unsigned char Value; + if (Tok.getAsInteger(10, Value)) { + setError("filler should be a decimal/hexadecimal value"); return {}; } - Tok = Tok.substr(3); + if (Value > 255) + setError("only single bytes decimal are supported for the filler now"); next(); - return parseHex(Tok); + return {Value}; } void ScriptParser::readProvide(bool Hidden) { Index: test/ELF/linkerscript/linkerscript-sections-padding.s =================================================================== --- test/ELF/linkerscript/linkerscript-sections-padding.s +++ test/ELF/linkerscript/linkerscript-sections-padding.s @@ -19,13 +19,13 @@ # RUN: hexdump -C %t.out | FileCheck -check-prefix=NO %s # NO: 00000120 66 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -## Filler should be a hex value (1): +## Decimal value. # RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =99 }" > %t.script -# RUN: not ld.lld -o %t.out --script %t.script %t 2>&1 \ -# RUN: | FileCheck --check-prefix=ERR %s -# ERR: filler should be a hexadecimal value +# RUN: ld.lld -o %t.out --script %t.script %t +# RUN: hexdump -C %t.out | FileCheck -check-prefix=DEC %s +# DEC: 00000120 66 63 63 63 63 63 63 63 63 63 63 63 63 63 63 63 -## Filler should be a hex value (2): +## Invalid hex value: # RUN: echo "SECTIONS { .mysec : { *(.mysec*) } =0x99XX }" > %t.script # RUN: not ld.lld -o %t.out --script %t.script %t 2>&1 \ # RUN: | FileCheck --check-prefix=ERR2 %s