{"id":17645033,"url":"https://github.com/kpostoffice/get_dl_usage","last_synced_at":"2025-03-30T07:13:59.459Z","repository":{"id":111132114,"uuid":"320072454","full_name":"KPostOffice/get_dl_usage","owner":"KPostOffice","description":"get dl usage at runtime (calls to dlopen, dlsync)","archived":false,"fork":false,"pushed_at":"2020-12-10T21:59:56.000Z","size":4,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-05T09:17:40.431Z","etag":null,"topics":["dlclose","dlopen","dlsym","ld-preload","monitoring"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KPostOffice.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-09T20:32:32.000Z","updated_at":"2023-07-06T22:28:23.000Z","dependencies_parsed_at":"2023-04-15T20:05:44.357Z","dependency_job_id":null,"html_url":"https://github.com/KPostOffice/get_dl_usage","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KPostOffice%2Fget_dl_usage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KPostOffice%2Fget_dl_usage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KPostOffice%2Fget_dl_usage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KPostOffice%2Fget_dl_usage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KPostOffice","download_url":"https://codeload.github.com/KPostOffice/get_dl_usage/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246285816,"owners_count":20752956,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dlclose","dlopen","dlsym","ld-preload","monitoring"],"created_at":"2024-10-23T10:44:38.795Z","updated_at":"2025-03-30T07:13:59.441Z","avatar_url":"https://github.com/KPostOffice.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Wrap dl(open|sym|close)\n\nThe purpose of this project is to monitor calls to dlopen/dlsym in order to keep track of shared object files that are\nloaded during a projects runtime.  These calls cannot always be statically analyzed due to obfuscation through function\ncalls.\n\n## Usefulness\n\n* **RPM packagers**: When packaging programs from languages such as Python finding all dependencies of the program so\n  that they can easily state them as requirements\n* **Containerized Development**: when running a program in a container it is best to find a container which already\n  provides all required libraries in the correct versions which provide all required symbols.\n* **You**: if you find this tool useful and don't fall into the above categories, open an issue and say what you use it\n  for? :)\n\n## How to\n\n1. `$ make`\n2. `$ LD_PRELOAD=$PWD/overwrite-dl.so \u003cinsert your command\u003e`\n3. `$ cat /tmp/dll_sym_\u003cpid\u003e`\n\n**NOTE:** step 3 can be run before program terminates\n\n## Limitations\n\nAs with any dynamic information, this may not give a complete picture of all possible `dl(open|sym)` usage if during\nexecution it misses conditional branches with these function calls.\n\n## Implementation\n\nThis tool relies on the LD_PRELOAD \"trick\", which you can read more about\n[here](https://rafalcieslak.wordpress.com/2013/04/02/dynamic-linker-tricks-using-ld_preload-to-cheat-inject-features-and-investigate-programs/)\n\nUsing this trick allows the user to overwrite any library functions and redefine them in your own shared object file.  This is extremely useful for program monitoring because it can catch and log interesting function calls without changing anything about the program it is being used inside of.\n\nFor this use case we need to change the behavior of \"dlopen\", \"dlsym\", and \"dlclose\".  The reason we need to alter all\nthree is because the `void * handle` returned by `dlopen` is completely opaque and has no guarantees as to\nimplementation, so it was necessary to maintain a basic linked list for looking up filenames based off of pointers.\n\"dlclose\" was altered to simply free all of this information as dlclose is called.\n\nIt also required minor changes to the LD_PRELOAD trick because the trick itself uses `dlsym`, so it needs to use the\nunderlying `_dlsym` as to not result in infinite recursion.\n\n## Questions\n\nIf you have any questions or requests feel free to open an issue. :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkpostoffice%2Fget_dl_usage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkpostoffice%2Fget_dl_usage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkpostoffice%2Fget_dl_usage/lists"}