1
1
mirror of https://github.com/rui314/mold.git synced 2024-09-20 09:27:45 +03:00

[Mach-O] Add -headerpad_max_install_names

This commit is contained in:
Rui Ueyama 2021-12-05 15:53:41 +09:00
parent 6fae1d8555
commit c5f5e6153f
2 changed files with 20 additions and 0 deletions

View File

@ -33,6 +33,8 @@ Options:
-framework <NAME>,[,<SUFFIX>]
Search for a given framework
-headerpad <SIZE> Allocate the size of padding after load commands
-headerpad_max_install_names
Allocate MAXPATHLEN byte padding after load commands
-help Report usage information
-l<LIB> Search for a given library
-lto_library <FILE> Ignored
@ -200,6 +202,8 @@ void parse_nonpositional_args(Context<E> &ctx,
ctx.arg.headerpad = std::stol(std::string(arg), &pos, 16);
if (pos != arg.size())
Fatal(ctx) << "malformed -headerpad: " << arg;
} else if (read_flag("-headerpad_max_install_names")) {
ctx.arg.headerpad = 1024;
} else if (read_flag("-dynamic")) {
ctx.arg.dynamic = true;
} else if (read_arg("-e")) {

View File

@ -0,0 +1,16 @@
#!/bin/bash
set -e
cd $(dirname $0)
mold=`pwd`/../../ld64.mold
echo -n "Testing $(basename -s .sh $0) ... "
t=$(pwd)/../../out/test/macho/$(basename -s .sh $0)
mkdir -p $t
cat <<EOF | cc -o $t/a.o -c -xc -
int main() {}
EOF
clang -fuse-ld=$mold -o $t/exe $t/a.o -Wl,-headerpad_max_install_names
otool -l $t/exe | grep -A5 'sectname __text' | grep -q 'addr 0x0000000100000978'
echo OK