Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does the linker locate code in stripped dynamic libraries?

It's common practice to strip a symbol table from a dynamic library (.dll on Windows, .dylib on OSX, and .so on Linux/Solaris/BSD). This makes sense because it drastically reduces the file size of the library, often more than 75 percent.

However, this one question's been bugging me: A stripped library has no symbol table. If I write an executable that references a function in this library, how does the operating system's dynamic linker know where to locate the section of code in the stripped library when there's no symbol table to provide this information?

This question comprises both the situation where the library was stripped before the executable was linked at compile-time and the situation where the library was stripped after the executable was linked at compile-time.

If someone could explain this to me, that would be great! Thanks.

like image 679
Leo Izen Avatar asked Nov 29 '13 14:11

Leo Izen


1 Answers

The symbols that are stripped when you run strip are the debugging symbols, not the names of actual exported symbols.

The dynamic symbols, the ones that the linker searches for, are still there, and can be listed by using the -D (Lists dynamic symbols) argument.

like image 179
DusteD Avatar answered Sep 30 '22 05:09

DusteD