summaryrefslogtreecommitdiff
path: root/lld/Common
diff options
context:
space:
mode:
authorJez Ng <jezng@fb.com>2020-07-30 14:28:45 -0700
committerJez Ng <jezng@fb.com>2020-07-30 14:29:31 -0700
commit22e6648a1834aa6680064eaf83e1e051a7248e17 (patch)
treed40dc2d2e5a6bec34d5f5bc02e537179b02e1622 /lld/Common
parent3587de22819869a2925994d8bd75fa1386464660 (diff)
downloadllvm-22e6648a1834aa6680064eaf83e1e051a7248e17.tar.gz
[lld-macho] Implement -headerpad
Tools like `install_name_tool` and `codesign` may modify the Mach-O header and increase its size. The linker has to provide padding to make this possible. This diff does that, plus sets its default value to 32 bytes (which is what ld64 does). Unlike ld64, however, we lay out our sections *exactly* `-headerpad` bytes from the header, whereas ld64 just treats the padding requirement as a lower bound. ld64 actually starts laying out the non-header sections in the __TEXT segment from the end of the (page-aligned) segment rather than the front, so its binaries typically have more than `-headerpad` bytes of actual padding. We should consider implementing the same alignment behavior. Reviewed By: #lld-macho, compnerd Differential Revision: https://reviews.llvm.org/D84714
Diffstat (limited to 'lld/Common')
-rw-r--r--lld/Common/Args.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/lld/Common/Args.cpp b/lld/Common/Args.cpp
index 4ea3a435c7ae..507830f9da34 100644
--- a/lld/Common/Args.cpp
+++ b/lld/Common/Args.cpp
@@ -26,14 +26,14 @@ CodeGenOpt::Level lld::args::getCGOptLevel(int optLevelLTO) {
return CodeGenOpt::Default;
}
-int64_t lld::args::getInteger(opt::InputArgList &args, unsigned key,
- int64_t Default) {
+static int64_t getInteger(opt::InputArgList &args, unsigned key,
+ int64_t Default, unsigned base) {
auto *a = args.getLastArg(key);
if (!a)
return Default;
int64_t v;
- if (to_integer(a->getValue(), v, 10))
+ if (to_integer(a->getValue(), v, base))
return v;
StringRef spelling = args.getArgString(a->getIndex());
@@ -41,6 +41,16 @@ int64_t lld::args::getInteger(opt::InputArgList &args, unsigned key,
return 0;
}
+int64_t lld::args::getInteger(opt::InputArgList &args, unsigned key,
+ int64_t Default) {
+ return ::getInteger(args, key, Default, 10);
+}
+
+int64_t lld::args::getHex(opt::InputArgList &args, unsigned key,
+ int64_t Default) {
+ return ::getInteger(args, key, Default, 16);
+}
+
std::vector<StringRef> lld::args::getStrings(opt::InputArgList &args, int id) {
std::vector<StringRef> v;
for (auto *arg : args.filtered(id))