1
1
mirror of https://github.com/rui314/mold.git synced 2024-10-04 08:37:28 +03:00

Add a test

This commit is contained in:
Rui Ueyama 2022-06-28 11:31:37 +08:00
parent 26d45ed4c1
commit b81f3c22be
2 changed files with 14 additions and 1 deletions

View File

@ -764,6 +764,7 @@ find_external_lib(Context<E> &ctx, std::string_view parent, std::string path) {
template <typename E>
DylibFile<E> *DylibFile<E>::create(Context<E> &ctx, MappedFile<Context<E>> *mf) {
// Read a given file
DylibFile<E> *dylib = new DylibFile<E>(mf);
dylib->is_alive = (ctx.needed_l || !ctx.arg.dead_strip_dylibs);
dylib->is_weak = ctx.weak_l;
@ -781,6 +782,7 @@ DylibFile<E> *DylibFile<E>::create(Context<E> &ctx, MappedFile<Context<E>> *mf)
Fatal(ctx) << mf->name << ": is not a dylib";
}
// Read reexported libraries if any
for (std::string_view path : dylib->reexported_libs) {
MappedFile<Context<E>> *mf =
find_external_lib(ctx, dylib->install_name, std::string(path));
@ -793,6 +795,7 @@ DylibFile<E> *DylibFile<E>::create(Context<E> &ctx, MappedFile<Context<E>> *mf)
dylib->weak_exports.merge(child->weak_exports);
}
// Initialize syms and is_weak_symbols vectors
for (std::string_view s : dylib->exports) {
dylib->syms.push_back(get_symbol(ctx, s));
dylib->is_weak_symbol.push_back(false);

View File

@ -28,15 +28,25 @@ clang --ld-path=./ld64 -shared -o $t/libbar.dylib $t/b.o -L$t -Wl,-reexport-lfoo
objdump --macho --dylibs-used $t/libbar.dylib | grep -q 'libfoo.*reexport'
cat <<EOF | $CC -o $t/c.o -c -xc -
void baz() {}
EOF
clang --ld-path=./ld64 -shared -o $t/libbaz.dylib $t/c.o -L$t -Wl,-reexport-lbar
objdump --macho --dylibs-used $t/libbaz.dylib | grep -q 'libbar.*reexport'
cat <<EOF | $CC -o $t/d.o -c -xc -
void foo();
void bar();
void baz();
int main() {
foo();
bar();
baz();
}
EOF
clang --ld-path=./ld64 -o $t/exe $t/c.o -L$t -lbar
clang --ld-path=./ld64 -o $t/exe $t/d.o -L$t -lbaz
echo OK