From f9a57a1bc4e1e11b249ee9f2e5eecf5ba53bb75b Mon Sep 17 00:00:00 2001 From: David Bremner Date: Fri, 9 May 2014 07:07:44 +0900 Subject: [PATCH] Re: [PATCH v2 5/5] T360-symbol-hiding: Use nm instead of objdump. --- 0e/2fbc8dfc86d124fe8177f55da8677368c26e61 | 130 ++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 0e/2fbc8dfc86d124fe8177f55da8677368c26e61 diff --git a/0e/2fbc8dfc86d124fe8177f55da8677368c26e61 b/0e/2fbc8dfc86d124fe8177f55da8677368c26e61 new file mode 100644 index 000000000..eb156e448 --- /dev/null +++ b/0e/2fbc8dfc86d124fe8177f55da8677368c26e61 @@ -0,0 +1,130 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 2FBF7431FBF + for ; Thu, 8 May 2014 15:09:28 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id rUeFe8zQpKxx for ; + Thu, 8 May 2014 15:09:22 -0700 (PDT) +Received: from mx.xen14.node3324.gplhost.com (gitolite.debian.net + [87.98.215.224]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 0A787431FAE + for ; Thu, 8 May 2014 15:09:22 -0700 (PDT) +Received: from remotemail by mx.xen14.node3324.gplhost.com with local (Exim + 4.72) (envelope-from ) + id 1WiWU0-0000NE-FW; Thu, 08 May 2014 22:08:04 +0000 +Received: (nullmailer pid 12014 invoked by uid 1000); Thu, 08 May 2014 + 22:07:44 -0000 +From: David Bremner +To: Charles Celerier , Notmuch Mail + +Subject: Re: [PATCH v2 5/5] T360-symbol-hiding: Use nm instead of objdump. +In-Reply-To: +References: <1399395748-44920-1-git-send-email-cceleri@cs.stanford.edu> + <1399434615-28425-1-git-send-email-cceleri@cs.stanford.edu> + <1399434615-28425-2-git-send-email-cceleri@cs.stanford.edu> + <87d2fov2qj.fsf@maritornes.cs.unb.ca> +User-Agent: Notmuch/0.18 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-pc-linux-gnu) +Date: Fri, 09 May 2014 07:07:44 +0900 +Message-ID: <87a9arvs9b.fsf@maritornes.cs.unb.ca> +MIME-Version: 1.0 +Content-Type: text/plain +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Thu, 08 May 2014 22:09:28 -0000 + +Charles Celerier writes: + +> David Bremner writes: +> +>> Charles Celerier 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@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 -- 2.26.2