[lld] r285611 - Mark a few more expressions as absolute.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 31 11:20:34 PDT 2016


Author: rafael
Date: Mon Oct 31 13:20:34 2016
New Revision: 285611

URL: http://llvm.org/viewvc/llvm-project?rev=285611&view=rev
Log:
Mark a few more expressions as absolute.

Modified:
    lld/trunk/ELF/LinkerScript.cpp
    lld/trunk/test/ELF/linkerscript/absolute-expr.s
    lld/trunk/test/ELF/linkerscript/symbols-synthetic.s

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=285611&r1=285610&r2=285611&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Mon Oct 31 13:20:34 2016
@@ -1623,7 +1623,7 @@ Expr ScriptParser::readPrimary() {
   }
   if (Tok == "CONSTANT") {
     StringRef Name = readParenLiteral();
-    return [=](uint64_t Dot) { return getConstant(Name); };
+    return {[=](uint64_t Dot) { return getConstant(Name); }, true};
   }
   if (Tok == "DEFINED") {
     expect("(");
@@ -1666,7 +1666,9 @@ Expr ScriptParser::readPrimary() {
   }
   if (Tok == "SIZEOF") {
     StringRef Name = readParenLiteral();
-    return [=](uint64_t Dot) { return ScriptBase->getOutputSectionSize(Name); };
+    return {
+        [=](uint64_t Dot) { return ScriptBase->getOutputSectionSize(Name); },
+        true};
   }
   if (Tok == "ALIGNOF") {
     StringRef Name = readParenLiteral();
@@ -1675,7 +1677,7 @@ Expr ScriptParser::readPrimary() {
         true};
   }
   if (Tok == "SIZEOF_HEADERS")
-    return [=](uint64_t Dot) { return ScriptBase->getHeaderSize(); };
+    return {[=](uint64_t Dot) { return ScriptBase->getHeaderSize(); }, true};
 
   // Tok is a literal number.
   uint64_t V;

Modified: lld/trunk/test/ELF/linkerscript/absolute-expr.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/absolute-expr.s?rev=285611&r1=285610&r2=285611&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/absolute-expr.s (original)
+++ lld/trunk/test/ELF/linkerscript/absolute-expr.s Mon Oct 31 13:20:34 2016
@@ -1,17 +1,50 @@
 # REQUIRES: x86
 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
 # RUN: echo "SECTIONS { \
-# RUN:                  .text : { bar = ALIGNOF(.text); *(.text) } \
+# RUN:                  .text : { \
+# RUN:                    bar1 = ALIGNOF(.text); \
+# RUN:                    bar2 = CONSTANT (MAXPAGESIZE); \
+# RUN:                    bar3 = SIZEOF (.text); \
+# RUN:                    bar4 = SIZEOF_HEADERS; \
+# RUN:                    *(.text) \
+# RUN:                  } \
 # RUN:                };" > %t.script
 # RUN: ld.lld -o %t.so --script %t.script %t.o -shared
 # RUN: llvm-readobj -t %t.so | FileCheck %s
 
 # CHECK:      Symbol {
-# CHECK:        Name: bar
+# CHECK:        Name: bar1
 # CHECK-NEXT:   Value: 0x4
 # CHECK-NEXT:   Size: 0
 # CHECK-NEXT:   Binding: Global
 # CHECK-NEXT:   Type: None
+# CHECK-NEXT:   Other: 0
+# CHECK-NEXT:   Section: Absolute
+# CHECK-NEXT: }
+# CHECK-NEXT: Symbol {
+# CHECK-NEXT:   Name: bar2
+# CHECK-NEXT:   Value: 0x1000
+# CHECK-NEXT:   Size: 0
+# CHECK-NEXT:   Binding: Global
+# CHECK-NEXT:   Type: None
+# CHECK-NEXT:   Other: 0
+# CHECK-NEXT:   Section: Absolute
+# CHECK-NEXT: }
+# CHECK-NEXT: Symbol {
+# CHECK-NEXT:   Name: bar3
+# CHECK-NEXT:   Value: 0x0
+# CHECK-NEXT:   Size: 0
+# CHECK-NEXT:   Binding: Global
+# CHECK-NEXT:   Type: None
+# CHECK-NEXT:   Other: 0
+# CHECK-NEXT:   Section: Absolute
+# CHECK-NEXT: }
+# CHECK-NEXT: Symbol {
+# CHECK-NEXT:   Name: bar4
+# CHECK-NEXT:   Value: 0x190
+# CHECK-NEXT:   Size: 0
+# CHECK-NEXT:   Binding: Global
+# CHECK-NEXT:   Type: None
 # CHECK-NEXT:   Other: 0
 # CHECK-NEXT:   Section: Absolute
 # CHECK-NEXT: }

Modified: lld/trunk/test/ELF/linkerscript/symbols-synthetic.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/symbols-synthetic.s?rev=285611&r1=285610&r2=285611&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/symbols-synthetic.s (original)
+++ lld/trunk/test/ELF/linkerscript/symbols-synthetic.s Mon Oct 31 13:20:34 2016
@@ -48,11 +48,11 @@
 # SIMPLE-NEXT: 0000000000001048         .text   00000000 _start
 # SIMPLE-NEXT: 0000000000000120         .foo    00000000 begin_foo
 # SIMPLE-NEXT: 0000000000000128         .foo    00000000 end_foo
-# SIMPLE-NEXT: 0000000000000008         .foo    00000000 size_foo_1
+# SIMPLE-NEXT: 0000000000000008         *ABS*   00000000 size_foo_1
 # SIMPLE-NEXT: 0000000000000008         *ABS*   00000000 size_foo_1_abs
 # SIMPLE-NEXT: 0000000000001000         .foo    00000000 begin_bar
 # SIMPLE-NEXT: 0000000000001004         .foo    00000000 end_bar
-# SIMPLE-NEXT: 0000000000000ee4         .foo    00000000 size_foo_2
+# SIMPLE-NEXT: 0000000000000ee4         *ABS*   00000000 size_foo_2
 # SIMPLE-NEXT: 0000000000000ee4         *ABS*   00000000 size_foo_3
 # SIMPLE-NEXT: 0000000000001004         .eh_frame_hdr     00000000 __eh_frame_hdr_start
 # SIMPLE-NEXT: 0000000000001010         *ABS*             00000000 __eh_frame_hdr_start2




More information about the llvm-commits mailing list