[PATCH v2 5/5] T360-symbol-hiding: Use nm instead of objdump.

David Bremner david at tethera.net
Thu May 8 15:07:44 PDT 2014


Charles Celerier <cceleri at cs.stanford.edu> writes:

> David Bremner <david at tethera.net> writes:
>
>> Charles Celerier <cceleri at cs.stanford.edu> writes:
>>>  test_begin_subtest 'comparing existing to exported symbols'
>>> -objdump -t $TEST_DIRECTORY/../lib/*.o | awk '$4 == ".text" && $6 ~ "^notmuch" {print $6}' | sort | uniq > ACTUAL
>>> +nm -g $TEST_DIRECTORY/../lib/*.o | sed -n 's/.*\s\+T\s\+_\(notmuch_.*\)/\1/p' | sort | uniq > ACTUAL
>>>  sed -n 's/[[:blank:]]*\(notmuch_[^;]*\);/\1/p' $TEST_DIRECTORY/../notmuch.sym | sort | uniq > EXPORTED
>>
>> Hmm. It seems like the _ there is wrong. It grabs all of the symbols
>> starting with _notmuch, which are symbols we _don't_ want exported.
>> It makes me wonder what ends up in "notmuch.sym" on MacOS, if that test
>> passes for you.
>
> Ok. Apologies in advance for the verbose content of this email. Here is my notmuch.sym:

Actually, that's perfect. I think I finally understand what's going on,
if not completely how to fix it yet.

>
>     $ cat notmuch.sym
>     {
>     global:

this looks fine; only mangled C++ stuff is different.

> The output of the test in question (T360-symbol-hiding) after
> applying all of the patches in this series is
>
>     T360-symbol-hiding: Testing exception symbol hiding
>      PASS   running test
>      PASS   checking output
>      FAIL   comparing existing to exported symbols
> 	--- T360-symbol-hiding.3.EXPORTED   2014-05-08
>      14:48:52.000000000 +0000
> 	+++ T360-symbol-hiding.3.ACTUAL 2014-05-08 14:48:52.000000000
>      +0000
> 	@@ -26,7 +26,11 @@
> 	 notmuch_filenames_valid
> 	 notmuch_message_add_tag
> 	 notmuch_message_destroy
> 	+notmuch_message_file_close
> 	+notmuch_message_file_get_header
> 	+notmuch_message_file_open
>

OK, what's happening here is that your version of the test, I guess
using nm, is not skipping hidden symbols. This should probably be better
documented in the existing test, but in the case of hidden symbols,
$6 is ".hidden".  I don't know if nm understands symbol visibility at
all; I'd guess not.

So as a more portable workaround, I agree we could start being more
rigorous about not naming things "^notmuch_.*" unless they are intended
to be exported.

> This output was a clear motivation for the patch in
> id:1399402716-13714-1-git-send-email-cceleri at cs.stanford.edu.

I see that now. I think I'd prefer a more minimal patch that only adds _
to the front of symbols currently starting with notmuch.

> Here is some of output of the matches made on the output of nm:
>
>     $ nm -g test/../lib/*.o | sed -n '/.*\s\+T\s\+_\(notmuch_.*\)/p'
>     00000000000028c0 T _notmuch_database_add_message
>     0000000000002280 T _notmuch_database_begin_atomic
>     0000000000001af0 T _notmuch_database_close
>     0000000000001de0 T _notmuch_database_compact

With GNU nm, there is no leading _ in front of notmuch here, which is
what causes your version of the test to fail for me.

d


More information about the notmuch mailing list