[lld] r277532 - Support expressions inside FLAGS.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 2 15:14:57 PDT 2016
Author: rafael
Date: Tue Aug 2 17:14:57 2016
New Revision: 277532
URL: http://llvm.org/viewvc/llvm-project?rev=277532&view=rev
Log:
Support expressions inside FLAGS.
This is an undocumented bfd feature. It is reasonable for making the
scripts a bit more readable.
Modified:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/test/ELF/linkerscript/linkerscript-phdrs-flags.s
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=277532&r1=277531&r2=277532&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Tue Aug 2 17:14:57 2016
@@ -645,7 +645,9 @@ void ScriptParser::readPhdrs() {
PhdrCmd.HasPhdrs = true;
else if (Tok == "FLAGS") {
expect("(");
- next().getAsInteger(0, PhdrCmd.Flags);
+ // Passing 0 for the value of dot is a bit of a hack. It means that
+ // we accept expressions like ".|1".
+ PhdrCmd.Flags = readExpr()(0);
expect(")");
} else
setError("unexpected header attribute: " + Tok);
Modified: lld/trunk/test/ELF/linkerscript/linkerscript-phdrs-flags.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/linkerscript-phdrs-flags.s?rev=277532&r1=277531&r2=277532&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/linkerscript-phdrs-flags.s (original)
+++ lld/trunk/test/ELF/linkerscript/linkerscript-phdrs-flags.s Tue Aug 2 17:14:57 2016
@@ -1,6 +1,6 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
-# RUN: echo "PHDRS {all PT_LOAD FILEHDR PHDRS FLAGS (1);} \
+# RUN: echo "PHDRS {all PT_LOAD FILEHDR PHDRS FLAGS (1 + 0x2);} \
# RUN: SECTIONS { \
# RUN: . = 0x10000200; \
# RUN: .text : {*(.text.*)} :all \
@@ -17,7 +17,8 @@
# CHECK-NEXT: PhysicalAddress: 0x10000000
# CHECK-NEXT: FileSize: 521
# CHECK-NEXT: MemSize: 521
-# CHECK-NEXT: Flags [ (0x1)
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: PF_W (0x2)
# CHECK-NEXT: PF_X (0x1)
# CHECK-NEXT: ]
More information about the llvm-commits
mailing list