[PATCH] D24898: [ELF] Support -z common-page-size option
Petr Hosek via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 24 18:24:04 PDT 2016
phosek updated this revision to Diff 72407.
https://reviews.llvm.org/D24898
Files:
ELF/Config.h
ELF/Driver.cpp
ELF/LinkerScript.cpp
test/ELF/linkerscript/zcommon-page-size.s
Index: test/ELF/linkerscript/zcommon-page-size.s
===================================================================
--- /dev/null
+++ test/ELF/linkerscript/zcommon-page-size.s
@@ -0,0 +1,14 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+
+# RUN: echo "SECTIONS { \
+# RUN: symbol = CONSTANT(COMMONPAGESIZE); \
+# RUN: }" > %t.script
+# RUN: ld.lld -z common-page-size=0x1234 -o %t1 --script %t.script %t
+# RUN: llvm-objdump -t %t1 | FileCheck %s
+
+# CHECK: 0000000000001234 *ABS* 00000000 symbol
+
+.global _start
+_start:
+ nop
Index: ELF/LinkerScript.cpp
===================================================================
--- ELF/LinkerScript.cpp
+++ ELF/LinkerScript.cpp
@@ -1414,7 +1414,7 @@
uint64_t static getConstant(StringRef S) {
if (S == "COMMONPAGESIZE")
- return Target->PageSize;
+ return Config->CommonPageSize;
if (S == "MAXPAGESIZE")
return Target->MaxPageSize;
error("unknown constant: " + S);
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -646,6 +646,15 @@
for (auto *Arg : Args.filtered(OPT_trace_symbol))
Symtab.trace(Arg->getValue());
+ // Initialize Config->PageSize. The default value is defined by the
+ // target, but it can be overriden using the -z common-page-size option.
+ if (Optional<StringRef> Value = getZOptionValue(Args, "common-page-size")) {
+ if (Value->getAsInteger(0, Config->CommonPageSize))
+ error("invalid common page size: " + *Value);
+ } else {
+ Config->CommonPageSize = Target->PageSize;
+ }
+
// Initialize Config->ImageBase.
if (auto *Arg = Args.getLastArg(OPT_image_base)) {
StringRef S = Arg->getValue();
Index: ELF/Config.h
===================================================================
--- ELF/Config.h
+++ ELF/Config.h
@@ -132,6 +132,7 @@
UnresolvedPolicy UnresolvedSymbols;
BuildIdKind BuildId = BuildIdKind::None;
ELFKind EKind = ELFNoneKind;
+ uint64_t CommonPageSize;
uint16_t DefaultSymbolVersion = llvm::ELF::VER_NDX_GLOBAL;
uint16_t EMachine = llvm::ELF::EM_NONE;
uint64_t EntryAddr = 0;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24898.72407.patch
Type: text/x-patch
Size: 2181 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160925/e5e3e689/attachment.bin>
More information about the llvm-commits
mailing list