diff options
| -rw-r--r-- | lld/ELF/LinkerScript.cpp | 4 | ||||
| -rw-r--r-- | lld/test/ELF/linkerscript/linkerscript-phdrs-flags.s | 5 |
2 files changed, 6 insertions, 3 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 8bb704c5247..c5b198456cc 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -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); diff --git a/lld/test/ELF/linkerscript/linkerscript-phdrs-flags.s b/lld/test/ELF/linkerscript/linkerscript-phdrs-flags.s index f198d85a3c3..d4a08f60466 100644 --- a/lld/test/ELF/linkerscript/linkerscript-phdrs-flags.s +++ b/lld/test/ELF/linkerscript/linkerscript-phdrs-flags.s @@ -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: ] |

