Support expressions inside FLAGS.

This is an undocumented bfd feature. It is reasonable for making the
scripts a bit more readable.

llvm-svn: 277532
This commit is contained in:
Rafael Espindola 2016-08-02 22:14:57 +00:00
parent a9210ef4f5
commit eb685cd798
2 changed files with 6 additions and 3 deletions

View File

@ -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);

View File

@ -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: ]