From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/7642 Path: news.gmane.org!not-for-mail From: Alex Dowad Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH v3] Build process uses script to add CFI directives to x86 asm Date: Fri, 15 May 2015 19:31:32 +0200 Message-ID: <20150515173132.GA18390@alex-ThinkPad-L530> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1431711116 20476 80.91.229.3 (15 May 2015 17:31:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 15 May 2015 17:31:56 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-7654-gllmg-musl=m.gmane.org@lists.openwall.com Fri May 15 19:31:56 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 1YtJSm-0003kQ-4j for gllmg-musl@m.gmane.org; Fri, 15 May 2015 19:31:56 +0200 Original-Received: (qmail 11947 invoked by uid 550); 15 May 2015 17:31:53 -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 11903 invoked from network); 15 May 2015 17:31:48 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=sFt8XvDL5Z3nxDrZIfxe0dWTyKABkHFXngYmfpwwt4I=; b=uKC7JjF8O9pcJf1UsIPVyqR22+i8UE2zJZdlqEBJFo+c3ZeQXqIyn92RQpwPpov7kB 6ng2mzf5eqGIfEagqw8CV64eD9g0JcPpp6oChgK7yL89NE8POXrr6WxGpV9bDr6qADEx hp2o9H1ShUuXQ19pEp3uCOprf4OPe51isYqnqe+E9fGmgMzgoElzDPh2J1vIbOUBz+XH 1/wSQn3ecAyYQVRhw14vgAYV2jCrG/dXvRytLe/NyA8uXfQ/Oy+FjX77f6VR1wLt/ZSD mFxTmUw/zJcS4+TvqwYInmHVxx4z1/tDQnU1IuNMzWjUODl1NTEL2CPW/AHEXYKgT4IX zBXg== X-Received: by 10.194.187.170 with SMTP id ft10mr20665474wjc.26.1431711097557; Fri, 15 May 2015 10:31:37 -0700 (PDT) Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:7642 Archived-At: Dear Szabolcs Nagy (and other interested parties), > you can use > > .file "foo.s" Thanks for the idea! Unfortunately, implementing it has proved very troublesome. The GAS documentation does refer to ".file ". There's just a tiny little problem with it -- it doesn't actually work for the desired purpose. It does register as a dependency, so it will be included in the dependency file which is written out if you invoke GAS with the --MD option. But that's about it. If you look at asm generated by GCC, it includes a ".file " line at the top, but it *also* includes a ".file " line. Which actually sets the "source file" in the debugging info! (Yay!) Subsequent ".loc" directives use the source file number when identifying source lines. So we just use ".file " and everybody is happy, right? Yes? Good? Right? Wrong. Allow me to quote gas/dwarf2dbg.c:596-598 from the binutils repo: /* A .file directive implies compiler generated debug information is being supplied. Turn off gas generated debug info. */ debug_type = DEBUG_NONE; Snap. Normally, GAS automatically generates debug info on source line numbers, and a few other basic things. As soon as you use a ".file " directive, all that automatic debugging output is shut off, and you have to use explicit assembler directives for *everything*. I guess this makes sense, because if the "source file" is a completely different file from the input asm file, the automatically generated line number info will be completely wrong. What a pain! Well, I guess I'll just have to use my own, explicit ".loc" directives. > i think passing down the build command that way is not ok It does seem like a hack -- but I'm not sure what a better way to do it is. (I'm not a "real" shell programmer, if you hadn't noticed yet. I just fake it using some combination of Stack Overflow and manpages.) > i think > > pushl $123 > push $123 > > are different 'push %eax' and 'pushl %eax' assemble to exactly the same machine code. Likewise, 'push $1' and 'pushl $1' assemble just the same. Interestingly, 'pushl %ax' assembles to 'push %eax', 'push %ax' is just 'push %ax'. > set LC_ALL=C because you depend on collation order > in the awk script Please see if I did this right in the v4. > add new lines at the end Done. Thanks for other enhancements to the awk script (I will credit you in the commit log message). Kind regards, AD