From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/8132 Path: news.gmane.org!not-for-mail From: Alex Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH v9] Build process uses script to add CFI directives to x86 asm Date: Wed, 8 Jul 2015 09:54:55 +0200 Message-ID: References: <1435087088-9860-1-git-send-email-alexinbeijing@gmail.com> <20150707033906.GF1173@brightrain.aerifal.cx> <20150707132156.GG1173@brightrain.aerifal.cx> <20150707181554.GH1173@brightrain.aerifal.cx> <20150708023638.GJ1173@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1436342112 14021 80.91.229.3 (8 Jul 2015 07:55:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 8 Jul 2015 07:55:12 +0000 (UTC) To: Rich Felker , musl@lists.openwall.com Original-X-From: musl-return-8145-gllmg-musl=m.gmane.org@lists.openwall.com Wed Jul 08 09:55:12 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1ZCkCE-0000PK-3Z for gllmg-musl@m.gmane.org; Wed, 08 Jul 2015 09:55:10 +0200 Original-Received: (qmail 20110 invoked by uid 550); 8 Jul 2015 07:55:08 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 20086 invoked from network); 8 Jul 2015 07:55:07 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=3q0Ip9wKej9y7SMz5K9i33OaavmHekQ/fKN1tqolk9I=; b=O985KQ2lhtrYVfGGNR8L7Ft40lMw/xfvLUqi2tGbGE322sEfovymmcXxORE393x4Hf tCIoyYeX4mK9ZYkap3jcDdmrxk4ut9HDzvY17JNzzKXoGjHyyb7oD+8PTPyFxlZS5+EQ OtzSl5YNcLUABEZV1RlhydU0y/erxgCy00BAoccEuFMTCFnj5TR/i0OyofhFO8PmO9Dz njcAlAuzBiDTqtVv+aCMLlDaMrS+m0Fm3oX1gNGo1voPxSctNsteuvxmc9b2nhAopslv QoVrcPgrHIViC0VxPXqMZvBwERMFdRdBxjBqbsjt+eqy4OW2HERQUR+qMNQTvHErCyb6 oQGA== X-Received: by 10.50.4.66 with SMTP id i2mr88436181igi.40.1436342095355; Wed, 08 Jul 2015 00:54:55 -0700 (PDT) In-Reply-To: Xref: news.gmane.org gmane.linux.lib.musl.general:8132 Archived-At: On Wed, Jul 8, 2015 at 9:13 AM, Alex wrote: > On Wed, Jul 8, 2015 at 4:36 AM, Rich Felker wrote: >> On Tue, Jul 07, 2015 at 08:27:46PM +0200, Alex wrote: >>> > 2. I suspect a dynamic-linked binary without the corresponding libc.so >>> > is not useful. Do you want the static-linked binary with a reference >>> > to pthread_cancel added? >>> >>> I want to see the DWARF data, and in this case it should be in >>> libc.so, not in canbt. But let me test under conditions more similar >>> to yours first. >> >> I'm attaching the static a.out which exhibits the problem, and sending >> this off-list since it's (mildly) big. I can send libc.so if you >> prefer but I think the static version is sufficient to see the >> problem. > > Thanks. The problem was nothing to do with differences in our build > environments. The problem was that in src/thread/i386/syscall_cp.s, > _syscall_cp_asm "falls through" into __cp_begin. > > The CFI generation process assumes that each "global" label is a call > target, and hence when a global label is reached, the stack frame > offset should be 4. It assumes that we must have reached the current > point from a CALL, and that the return address should be on the top of > the stack. > > In this case, __cp_begin is NOT a call target. (It is used in > pthread_cancel.c:cancel_handler, which checks whether a saved > instruction pointer value is between __cp_begin and __cp_end.) > > I will amend the script so that it must see a ".global" directive > *and* a ".type @function" directive before it assumes that a label is > an entry point for C function calls. A couple questions: drem(), dremf(), and vfork() are declared as ".type @function", but not ".global". Rather, they use ".weak" directives. Are such labels to be considered entry points? Then there are some labels which are declared as ".global" and ".hidden", like __memcpy_fwd, __exp2l, and ___setjmp. It looks like when any of those 3 are reached, there should be a return address on top of the stack. What would you think of adding a ".type @function" declaration for those 3, so that the CFI generation script will treat them as "functions"? Thanks, AD