[PATCH] D25549: [ELF] - Linkerscript: accept integer values for PHDRS types.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 14 05:55:52 PDT 2016


grimar updated this revision to Diff 74665.
grimar added a comment.

- Addressed review comments.


https://reviews.llvm.org/D25549

Files:
  ELF/LinkerScript.cpp
  test/ELF/linkerscript/phdrs.s


Index: test/ELF/linkerscript/phdrs.s
===================================================================
--- test/ELF/linkerscript/phdrs.s
+++ test/ELF/linkerscript/phdrs.s
@@ -47,6 +47,29 @@
 # AT-NEXT:        PF_X (0x1)
 # AT-NEXT:      ]
 
+## Check the numetic values for PHDRS.
+# RUN: echo "PHDRS {text PT_LOAD FILEHDR PHDRS; foo 0x11223344; } \
+# RUN:       SECTIONS { . = SIZEOF_HEADERS; .foo : { *(.*) } : text : foo}" > %t1.script
+# RUN: ld.lld -o %t2 --script %t1.script %t
+# RUN: llvm-readobj -program-headers %t2 | FileCheck --check-prefix=INT-PHDRS %s
+
+# INT-PHDRS:      ProgramHeaders [
+# INT-PHDRS:        ProgramHeader {
+# INT-PHDRS:           Type:  (0x11223344)
+# INT-PHDRS-NEXT:      Offset: 0xB0
+# INT-PHDRS-NEXT:      VirtualAddress: 0xB0
+# INT-PHDRS-NEXT:      PhysicalAddress: 0xB0
+# INT-PHDRS-NEXT:      FileSize: 9
+# INT-PHDRS-NEXT:      MemSize: 9
+# INT-PHDRS-NEXT:      Flags [
+# INT-PHDRS-NEXT:        PF_R
+# INT-PHDRS-NEXT:        PF_W
+# INT-PHDRS-NEXT:        PF_X
+# INT-PHDRS-NEXT:      ]
+# INT-PHDRS-NEXT:      Alignment: 4
+# INT-PHDRS-NEXT:    }
+# INT-PHDRS-NEXT:  ]
+
 .global _start
 _start:
  nop
Index: ELF/LinkerScript.cpp
===================================================================
--- ELF/LinkerScript.cpp
+++ ELF/LinkerScript.cpp
@@ -1708,6 +1708,10 @@
 
 unsigned ScriptParser::readPhdrType() {
   StringRef Tok = next();
+  uint64_t Val;
+  if (readInteger(Tok, Val))
+    return Val;
+
   unsigned Ret = StringSwitch<unsigned>(Tok)
                      .Case("PT_NULL", PT_NULL)
                      .Case("PT_LOAD", PT_LOAD)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25549.74665.patch
Type: text/x-patch
Size: 1601 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161014/a80365a3/attachment.bin>


More information about the llvm-commits mailing list