[lld] r277222 - [LinkerScript] Filler can have a decimal value.

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 29 15:21:28 PDT 2016


Author: davide
Date: Fri Jul 29 17:21:28 2016
New Revision: 277222

URL: http://llvm.org/viewvc/llvm-project?rev=277222&view=rev
Log:
[LinkerScript] Filler can have a decimal value.

Modified:
    lld/trunk/ELF/LinkerScript.cpp
    lld/trunk/test/ELF/linkerscript/linkerscript-sections-padding.s

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=277222&r1=277221&r2=277222&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Fri Jul 29 17:21:28 2016
@@ -799,13 +799,19 @@ std::vector<uint8_t> ScriptParser::readO
   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) {

Modified: lld/trunk/test/ELF/linkerscript/linkerscript-sections-padding.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/linkerscript-sections-padding.s?rev=277222&r1=277221&r2=277222&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/linkerscript-sections-padding.s (original)
+++ lld/trunk/test/ELF/linkerscript/linkerscript-sections-padding.s Fri Jul 29 17:21:28 2016
@@ -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




More information about the llvm-commits mailing list