From 7b37546a4dd86c35d25e48e0bcbb36e34c57adb4 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Tue, 15 Jan 2019 11:42:43 +0100 Subject: [PATCH] tool/abi_symbols: omit known internal symbols This patch prevents the abi_symbols tool from generating symbols that are known to occur in shared objects but must not be part of a library ABI. This saves a bit of time during library-porting work. However, to avoid the accidental use of ABI symbol definitions that lack any form of manual curation, the abi_symbols tool outputs a special message, which is explicitly checked-for by the check_abi tool. Fixes #3112 --- tool/abi_symbols | 14 ++++++++++++++ tool/check_abi | 32 ++++++++++++++------------------ tool/internal_abi.list | 13 +++++++++++++ 3 files changed, 41 insertions(+), 18 deletions(-) create mode 100644 tool/internal_abi.list diff --git a/tool/abi_symbols b/tool/abi_symbols index 6b0c70759f..16e64f53f8 100755 --- a/tool/abi_symbols +++ b/tool/abi_symbols @@ -21,6 +21,14 @@ set demangled [exec c++filt << $symbols] set demangled_lines [split $demangled "\n"] +# obtail list of blacklisted symbols +set fd [open "[file dirname $argv0]/internal_abi.list"] +set symbol_blacklist [split [read $fd] "\n"] +close $fd + +# add notice that the symbols file hasn't undergone any manual inspection +puts "# Please review the symbols and remove this line." + set i 0 set output_lines {} foreach line [split $symbols "\n"] { @@ -78,6 +86,12 @@ foreach line [split $symbols "\n"] { if {[regexp {W|V} $type] && ($name != $demangled_name)} { set keep 0 } + # + # Drop blacklisted symbols + # + foreach blacklisted_symbol $symbol_blacklist { + if {$name == $blacklisted_symbol} { set keep 0 } } + # write result if {$keep} { diff --git a/tool/check_abi b/tool/check_abi index 2ceada136b..49d2592246 100755 --- a/tool/check_abi +++ b/tool/check_abi @@ -31,6 +31,16 @@ proc report_error { message } { } +# +# Warn about an ABI symbol definition that was generated by the 'abi_symbols' +# tool but hasn't undergone any manual review. This is most likely an +# accidental omission. +# +foreach line $abi_content { + if {$line == "# Please review the symbols and remove this line."} { + report_error "attempt to use unreviewed $abi_name ABI\n at $abi_path" } } + + # # Extract symbol list w/o comments and empty lines, check for trailing spaces # @@ -57,26 +67,12 @@ foreach line $abi_content { # # Check for absence of Genode-internal linking artifacts from ABI # - -# -# The following symbols may appear in shared objects but should not by part +# The listed symbols may appear in shared objects but should not by part # of any ABI. # -set symbol_blacklist { - __bss_start - __eh_frame_start__ - __exidx_end - __exidx_start - __l4sys_invoke_indirect - _ctors_end - _ctors_start - _edata - _end - _init - _parent_cap - _parent_cap_local_name - _parent_cap_thread_id -} +set fd [open "[file dirname $argv0]/internal_abi.list"] +set symbol_blacklist [split [read $fd] "\n"] +close $fd foreach line $abi_symbols { set name [lindex $line 0] diff --git a/tool/internal_abi.list b/tool/internal_abi.list new file mode 100644 index 0000000000..d346c9d7a5 --- /dev/null +++ b/tool/internal_abi.list @@ -0,0 +1,13 @@ +__bss_start +__eh_frame_start__ +__exidx_end +__exidx_start +__l4sys_invoke_indirect +_ctors_end +_ctors_start +_edata +_end +_init +_parent_cap +_parent_cap_local_name +_parent_cap_thread_id