Skip to content

Commit

Permalink
[Mach-O] Add a test for mach-o stub
Browse files Browse the repository at this point in the history
  • Loading branch information
rui314 committed Sep 8, 2021
1 parent 5dab861 commit 8f10ac5
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ compile_commands.json
options.inc
core
ld
ld64.mold
gentoo
out
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ all: mold mold-wrapper.so
mold: $(OBJS) $(MIMALLOC_LIB) $(TBB_LIB)
$(CXX) $(CPPFLAGS) $(OBJS) -o $@ $(LDFLAGS) $(LIBS)
ln -sf mold ld
ln -sf mold ld64.mold

mold-wrapper.so: elf/mold-wrapper.c Makefile
$(CC) -fPIC -shared -o $@ $< -ldl
Expand Down Expand Up @@ -102,13 +103,12 @@ $(TBB_LIB):
(cd out/tbb; ln -sf *_relwithdebinfo libs)

test tests check: all
$(MAKE) -C test/elf --output-sync --no-print-directory
$(MAKE) -C test --output-sync --no-print-directory

install: all
install -m 755 -d $(DEST)/bin
install -m 755 mold $(DEST)/bin
strip $(DEST)/bin/mold
ln -sf mold $(DEST)/bin/ld.mold

install -m 755 -d $(DEST)/lib/mold
install -m 644 mold-wrapper.so $(DEST)/lib/mold
Expand All @@ -119,12 +119,15 @@ install: all
rm -f $(DEST)/share/man/man1/mold.1.gz
gzip -9 $(DEST)/share/man/man1/mold.1

ln -sf mold $(DEST)/bin/ld.mold
ln -sf mold $(DEST)/bin/ld64.mold

uninstall:
rm -f $(DEST)/bin/mold $(DEST)/bin/ld.mold
rm -f $(DEST)/share/man/man1/mold.1.gz
rm -rf $(DEST)/lib/mold

clean:
rm -rf *~ mold mold-wrapper.so out ld
rm -rf *~ mold mold-wrapper.so out ld ld64.mold

.PHONY: all test tests check clean
3 changes: 3 additions & 0 deletions macho/main.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include "mold.h"

#include <iostream>

namespace mold::macho {

int macho_main(int argc, char **argv) {
std::cout << "mold macho stub\n";
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion test/elf/Makefile → test/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TESTS = $(wildcard *.sh)
TESTS = $(wildcard elf/*.sh macho/*.sh)

test: $(TESTS)

Expand Down
File renamed without changes.
11 changes: 11 additions & 0 deletions test/macho/basic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -e
cd $(dirname $0)
mold=`pwd`/../../ld64.mold
echo -n "Testing $(basename -s .sh $0) ... "
t=$(pwd)/../../out/test/elf/$(basename -s .sh $0)
mkdir -p $t

$mold | grep -q 'mold macho stub'

echo OK

0 comments on commit 8f10ac5

Please sign in to comment.