Commit Graph

16 Commits

Author SHA1 Message Date
Baptiste Daroussin
88741a40c8 check-links.sh: treat PIE executable as elf files 2021-09-23 04:49:57 +02:00
Bryan Drewery
fcd2678171 Allow specifying an alternative LD_LIBRARY_PATH for the ldd(1) lookup.
This is needed to be able to run check-links.sh against a "sysrooted"
binary while ensuring that the ldd(1) call done on the host uses the
host libc.  It is not possible to set LD_LIBRARY_PATH before calling
check-links.sh as then the "sysrooted" libc would be incorrectly used.

A LD_PRELOAD=libc.so is used to ldd(1) as it needs to use the host libc
to run.  ldd(1) is a simple wrapper around execve(2) and dlopen(2) with
env LD_TRACE_LOADED_OBJECTS set.  Due to the dlopen(2) restriction on
shared library tracing ldd(1) is still required for this lookup.

Sponsored by:	EMC / Isilon Storage Division
2016-01-19 22:42:16 +00:00
Bryan Drewery
8afa72e569 Add some documentation.
Sponsored by:	EMC / Isilon Storage Division
2016-01-19 22:42:13 +00:00
Bryan Drewery
d1db5f8fef Validate that the file exists rather than obscure 'Not an elf file' error.
Sponsored by:	EMC / Isilon Storage Division
2016-01-19 22:42:10 +00:00
Bryan Drewery
fc2ef3b240 Add a -v to tell where each symbol is resolved from.
Sponsored by:	EMC / Isilon Storage Division
2015-05-01 05:01:56 +00:00
Bryan Drewery
b0cb3920d6 Fix a comment 2015-05-01 04:35:42 +00:00
Bryan Drewery
64ee145b7d Tweak BSS symbol handling from r281811 to not consider them unresolved 2015-04-21 05:41:56 +00:00
Bryan Drewery
5f6c4518c8 Support libraries linked by path.
Sponsored by:	EMC / Isilon Storage Division
2015-04-21 05:10:18 +00:00
Bryan Drewery
3554283a7b - For executables search for matching (B) global uninitialized BSS symbols from
linked libraries. Only do this for BSS symbols that have a size which avoids
  __bss_start. Without this some libraries would be considered unneeded even
  though they were providing a B symbol.
- Add in the symbols from crt1.o to cover a handful of common unresolved symbols.
- Consider (C) common data symbols as provided by libraries/crt1.
- Move libkey() function to more appropriate place.

Sponsored by:	EMC / Isilon Storage Division
2015-04-21 03:29:03 +00:00
Bryan Drewery
60b38ce2b5 Revert r281805 for now as it breaks due to spaces in output 2015-04-21 03:06:58 +00:00
Bryan Drewery
c668010e3f Pass full path to ldd(1) so it works on files in cwd. 2015-04-21 02:02:25 +00:00
Bryan Drewery
9d273a1ffc Support demangling C++ symbols with -D flag.
Sponsored by:	EMC / Isilon Storage Division
2015-04-21 01:37:14 +00:00
Bryan Drewery
3844bbe29e - Speedup significantly by not using subshells for data already fetched.
Ran against /usr/local/sbin/pkg:
   Before:  25.12 real        12.41 user        33.14 sys
   After:   0.53 real         0.49 user         0.13 sys
- Exit with 1 if any missing or unresolved symbol is detected.
- Add option '-U' to skip looking up unresolved symbols.
- Don't consider provided weak objects as unresolved (nm V).

Sponsored by:	EMC / Isilon Storage Division
2015-04-20 20:51:19 +00:00
Bryan Drewery
972b622794 Fix indentation to use tabs 2015-04-20 20:45:10 +00:00
Bryan Drewery
daa301d1d0 - Fix support with new elftoolchain readelf(1)
- Fix not finding global symbols by checking for D and R.
- Follow symlinks
- Show which matching symbol was used to consider the library needed.

Discussed with:	bapt
2015-04-09 22:16:35 +00:00
Baptiste Daroussin
6276797fcd Add a quick and dirty script to check validity of links in elf files 2014-11-06 22:45:03 +00:00