Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/birros/ld-exported-symbols-demo

Sows how ld exports / hides static library symbols linked to a dynamic library
https://github.com/birros/ld-exported-symbols-demo

c demo dlopen dynamic gcc ld learning library static

Last synced: 2 days ago
JSON representation

Sows how ld exports / hides static library symbols linked to a dynamic library

Awesome Lists containing this project

README

        

# LD exported symbols demo

This repo shows how `ld` exports / hides static library symbols linked to a
dynamic library.

> **Note**
> By default, `ld` exports all symbols from linked static libraries.
> To hide symbols from a specific static library, we need to use this flag:
> `--exclude-libs libstatic.a`.

## Usage

```shell
$ make env # optional
$ make

RULE run

SYMBOLS FROM libdynamic.so (hidden libstatic.a symbols)
0000000000001020 T hello_from_dynamic

SYMBOLS FROM libdynamic_all.so
0000000000001030 T hello_from_dynamic
0000000000001050 T hello_from_static

RUN prog
Hello from prog!

CALL hello_from_dynamic FROM libdynamic.so (dynamically linked):
Hello from static!
Hello from dynamic!

CALL hello_from_static FROM libdynamic_all.so (dynamically opened):
Hello from static!
```