diff options
| author | Davide Italiano <davide@freebsd.org> | 2016-07-29 22:21:28 +0000 |
|---|---|---|
| committer | Davide Italiano <davide@freebsd.org> | 2016-07-29 22:21:28 +0000 |
| commit | 5ac0d7c5adb3a650b1b7635b75b13a4cc3b8532d (patch) | |
| tree | 334534868d64964f3047c31670ae44ea2a3eef8e | |
| parent | b638558e12d4e387aa57606cf808445e090533d1 (diff) | |
| download | bcm5719-llvm-5ac0d7c5adb3a650b1b7635b75b13a4cc3b8532d.tar.gz bcm5719-llvm-5ac0d7c5adb3a650b1b7635b75b13a4cc3b8532d.zip | |
[LinkerScript] Filler can have a decimal value.
llvm-svn: 277222
| -rw-r--r-- | lld/ELF/LinkerScript.cpp | 16 | ||||
| -rw-r--r-- | lld/test/ELF/linkerscript/linkerscript-sections-padding.s | 10 |
2 files changed, 16 insertions, 10 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 17a5edeff8d..8bb704c5247 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -799,13 +799,19 @@ std::vector<uint8_t> ScriptParser::readOutputSectionFiller() { StringRef Tok = peek(); if (!Tok.startswith("=")) return {}; - if (!Tok.startswith("=0x")) { - setError("filler should be a hexadecimal value"); + next(); + if (Tok.startswith("=0x")) + return parseHex(Tok.substr(3)); + + // This must be a decimal. + unsigned int Value; + if (Tok.substr(1).getAsInteger(10, Value)) { + setError("filler should be a decimal/hexadecimal value"); return {}; } - Tok = Tok.substr(3); - next(); - return parseHex(Tok); + if (Value > 255) + setError("only single bytes decimal are supported for the filler now"); + return {static_cast<unsigned char>(Value)}; } void ScriptParser::readProvide(bool Hidden) { diff --git a/lld/test/ELF/linkerscript/linkerscript-sections-padding.s b/lld/test/ELF/linkerscript/linkerscript-sections-padding.s index 545739efe5a..eca4c50cca0 100644 --- a/lld/test/ELF/linkerscript/linkerscript-sections-padding.s +++ b/lld/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 |

