Index: ELF/LinkerScript.cpp =================================================================== --- ELF/LinkerScript.cpp +++ ELF/LinkerScript.cpp @@ -644,8 +644,14 @@ else if (Tok == "PHDRS") PhdrCmd.HasPhdrs = true; else if (Tok == "FLAGS") { + // This can contain a bitwise-OR of flags. expect("("); - next().getAsInteger(0, PhdrCmd.Flags); + uint8_t Flags; + PhdrCmd.Flags = 0; + do { + next().getAsInteger(0, Flags); + PhdrCmd.Flags |= Flags; + } while (skip("|")); expect(")"); } else setError("unexpected header attribute: " + Tok); Index: test/ELF/linkerscript/linkerscript-phdrs-flags.s =================================================================== --- test/ELF/linkerscript/linkerscript-phdrs-flags.s +++ 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 (0x1 | 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 [ (0x3) +# CHECK-NEXT: PF_W (0x2) # CHECK-NEXT: PF_X (0x1) # CHECK-NEXT: ]