From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3303 invoked by alias); 19 Nov 2008 16:40:44 -0000 Received: (qmail 3200 invoked by uid 22791); 19 Nov 2008 16:40:42 -0000 X-Spam-Check-By: sourceware.org Received: from fmmailgate01.web.de (HELO fmmailgate01.web.de) (217.72.192.221) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 19 Nov 2008 16:40:06 +0000 Received: from smtp05.web.de (fmsmtp05.dlan.cinetic.de [172.20.4.166]) by fmmailgate01.web.de (Postfix) with ESMTP id 99553F9B6E38 for ; Wed, 19 Nov 2008 17:40:03 +0100 (CET) Received: from [82.83.69.133] (helo=[192.168.1.10]) by smtp05.web.de with asmtp (WEB.DE 4.109 #226) id 1L2q5y-0001iq-00 for gcc-help@gcc.gnu.org; Wed, 19 Nov 2008 17:40:02 +0100 Message-ID: <49244161.3010706@web.de> Date: Wed, 19 Nov 2008 17:22:00 -0000 From: Timo Kreuzer User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 To: gcc-help@gcc.gnu.org Subject: Problem Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Sender: timo.kreuzer@web.de Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-11/txt/msg00241.txt.bz2 Hi, I am working on x64 SEH for ReactOS. The idea is to use .cfi_escape codes to mark the code positions where the try block starts / ends and of the except landing pad. The emitted .eh_frame section is parsed after linking and converted into Windows compatible unwind info / scope tables. This works quite well so far. Now the problem: The exception filter and the finally clause are being created as nested functions. Now I need to know (in the parsing step after linking) the addresses of these functions and that they belong to the corresponding try / except statement. Best would be emitting the address of the nested function as .cfi_escape, but that doesn't really work. 1) .cfi_escape only takes bytes, not rvas and 2) the C compiler doesn't want to give me the address of the nested function at compile time. I ended up with a dirty hack, referencing the "parent code" from the inline function with a lea opcode: { __label__ label1; label1: asm volatile (".cfi_escape 0x50, 0x01\n"); int nested_function() { asm volatile ("lea %0, %%eax" : : "m"(*(volatile int*)(&&label1)) : "eax" ) asm volatile (".cfi_escape 0x50, 0x02\n"); } } >From the escape code I know that there must be a lea instruction, that I can read the rva from. Together with the position of the start of the nested function and the position of the label (that would correspond to the end of the try block for example), I have all the information. But it's dirty. Does anyone know a better solution for that? Thanks in advance, Timo