bug-readline
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-readline] [PATCH] Enable visibility annotations


From: Yury Gribov
Subject: Re: [Bug-readline] [PATCH] Enable visibility annotations
Date: Fri, 15 Apr 2016 14:39:55 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0

On 04/14/2016 09:04 PM, Pedro Alves wrote:
On 04/14/2016 05:42 PM, Yury Gribov wrote:
On 04/14/2016 06:49 PM, Pedro Alves wrote:
On 04/14/2016 03:41 PM, Yury Gribov wrote:

# Find all imported symbols in rootfs
for f in $(find /bin /sbin /usr/bin /usr/sbin /usr/lib* /lib*); do if
file $f | grep -q ELF; then readelf -sDW $f | awk '/UND/{print $9}'; fi

This doesn't seem right -- does it catch references to global variables?
Those won't be UND, I believe?

You mean that linker generates copies of imported globals and then
resolves them via copy relocations? Yeah, to detect those I'll need to
examine copy relocations though, will do that tomorrow.

Right.  For example, running:

# Find all programs/libraries linked to libreadline.so
find /bin /sbin /usr/bin /usr/sbin /usr/lib* /lib* | while read f; do if file $f | grep -q ELF; then match=`readelf -a 
$f 2>&1 | grep -v "Not an ELF" | grep NEEDED | grep readline`; if [ -n "$match" ]; then echo 
"$f"; fi; fi; done > rl-bins

# Look for all symbols that start with "_rl_" in those binaries.
cat rl-bins | while read f; do match=`readelf -s $f | grep " _rl_"`; if [ -n "$match" ] ; 
then echo $f; readelf --dyn-syms $f | grep " _rl_"; fi ; done

I'd rather not limit ourselves to files that have DT_NEEDED for readline. There be weird executables/libs which accidentally use readline symbols through some other shared libs (like libedit that you've mentioned) which link libreadline statically. These should be respected as well.

I've attached the script I've came up with (it properly works around copy relocations and thus detects imported external variables). On my system (with older gdb which only has _rl_echoing_p, _rl_qsort_string_compare and _rl_print_completions_horizontally) it reports:
  emacs_ctlx_keymap
  history_base
  history_length
  history_max_entries
  rl_already_prompted
  rl_catch_signals
  rl_catch_sigwinch
  rl_done
  _rl_echoing_p
  rl_end
  rl_getc_function
  rl_gnu_readline_p
  rl_inhibit_completion
  rl_instream
  rl_line_buffer
  rl_outstream
  rl_point
  rl_pre_input_hook
  rl_prep_term_function
  rl_prompt
  _rl_qsort_string_compare
  rl_readline_name
  rl_redisplay_function
  rl_startup_hook
  rl_terminal_name
  xmalloc
All these symbols are provided by new readline as well (except for xmalloc).

For new gdb it also reports
  _rl_complete_mark_directories
  rl_completer_quote_characters
  rl_completer_word_break_characters
  rl_completion_display_matches_hook
  rl_completion_entry_function
  _rl_completion_prefix_display_length
  rl_completion_query_items
  rl_completion_word_break_hook
  rl_deprep_term_function
  rl_directory_completion_hook
  rl_filename_completion_desired
  rl_ignore_completion_duplicates
  _rl_print_completions_horizontally
  rl_readline_state
  rl_sort_completion_matches
but these are exported as well.

readline has probably more private symbols that are not _rl_-prefixed (e.g., 
sumbols
from the history library?), so we'd need to search for the full set of symbols
your patch hides for a complete picture.

The attached script should handle this.

-Y

Attachment: who_uses.sh
Description: application/shellscript


reply via email to

[Prev in Thread] Current Thread [Next in Thread]