I'm just curious here. I have created a shared object:

```
gcc -o liba.so -fPIC -shared liba.c

```

And one more shared object, that links against the former one:

```
gcc -o libb.so -fPIC -shared libb.c liba.so

```

Now, when creating an executable that links against `libb.so`, I will have to specify -rpath-link to ld so it can find `liba.so` when discovering that `libb.so` depends on it:

```
gcc -o test -Wl,-rpath-link,./ test.c libb.so

```

otherwise ld will complain.

Why is it, that ld MUST be able to locate `liba.so` when linking `test`? Because to me it doesn't seem like ld is doing much else than confirming `liba.so`'s existence. For instance, running `readelf --dynamic ./test` only lists `libb.so` as needed, so I guess the dynamic linker must discover the `libb.so -> liba.so` dependency on its own, and make it's own search for `liba.so`.

I'm on an x86-64 GNU/Linux platform, and the main()-routine in `test` calls a function in `libb.so` that in turn calls a function in `liba.so`.