summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2016-10-18 10:49:50 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2016-10-18 10:49:50 +0000
commit95dd718c98a238841d35eba32e265262f83c8cdc (patch)
treef95a54373d85d9617e745714e695a93f81920756
parent33186424666318557e6a3b427201b1f1b2c1a231 (diff)
downloadbcm5719-llvm-95dd718c98a238841d35eba32e265262f83c8cdc.tar.gz
bcm5719-llvm-95dd718c98a238841d35eba32e265262f83c8cdc.zip
[ELF] - Linkerscript: accept integer values for PHDRS types.
Both gold and ld accepts integers instead of named constants for PHDRS. Patch adds support for that. Differential revision: https://reviews.llvm.org/D25549 llvm-svn: 284470
-rw-r--r--lld/ELF/LinkerScript.cpp6
-rw-r--r--lld/test/ELF/linkerscript/phdrs.s23
2 files changed, 29 insertions, 0 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 1690293b02b..fb745417332 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -1706,8 +1706,14 @@ std::vector<StringRef> ScriptParser::readOutputSectionPhdrs() {
return Phdrs;
}
+// Read a program header type name. The next token must be a
+// name of a program header type or a constant (e.g. "0x3").
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)
diff --git a/lld/test/ELF/linkerscript/phdrs.s b/lld/test/ELF/linkerscript/phdrs.s
index 2c41d75d069..7d5201c3726 100644
--- a/lld/test/ELF/linkerscript/phdrs.s
+++ b/lld/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
OpenPOWER on IntegriCloud