1
1
mirror of https://github.com/rui314/mold.git synced 2024-11-13 09:39:13 +03:00

[Mach-O] wip

This commit is contained in:
Rui Ueyama 2021-11-12 17:36:19 +09:00
parent 2b807ddf83
commit 4a1ec53c24
2 changed files with 32 additions and 1 deletions

View File

@ -454,7 +454,7 @@ public:
void compute_size(Context &ctx) override;
void copy_buf(Context &ctx) override;
std::string contents{"\0"};
std::string contents{1, '\0'};
};
class OutputIndirectSymtabSection : public Chunk {

31
test/macho/dead-strip.sh Executable file
View File

@ -0,0 +1,31 @@
#!/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 -
#include <stdio.h>
char msg1[] = "Hello world";
char msg2[] = "Howdy world";
void hello() {
printf("%s\n", msg1);
}
void howdy() {
printf("%s\n", msg2);
}
int main() {
hello();
}
EOF
clang -fuse-ld=$mold -o $t/exe $t/a.o -Wl,-dead_strip
$t/exe | grep -q 'Hello world'
echo OK