public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Proposal for Win64 exception handling directives
@ 2011-05-18 23:12 Charles Davis
  2011-05-19  5:52 ` Kai Tietz
  0 siblings, 1 reply; 3+ messages in thread
From: Charles Davis @ 2011-05-18 23:12 UTC (permalink / raw)
  To: binutils

(Since I'm not subscribed to this mailing list, please reply to all when
replying.)

Hi,

My name is Chip Davis, and I'm working on adding support for Win64-style
exception handling to LLVM (at the behest of several people). I know
there's interest in adding similar support to GCC.

Right now, I'm working on assembler-level directives for emitting the
required data for Win64-style exception handling. Since LLVM's
integrated assembler was designed to be compatible with GAS, I'm writing
you this message to make sure we're on the same page.

So, in no particular order, here are the directives that I propose for
emitting Win64 unwind data from the assembler. They're loosely based on
MASM's directives, but augmented to support compilers such as Clang and GCC.

- .w64_startproc <symbol> [, <ehandler>]

Delimits the beginning of a function callable from <symbol> that has
unwind data. If <ehandler> is specified, it is an exception handler to
be used for this function (or an unwind handler; see below). Roughly
equivalent to MASM's FRAME attribute on procedures.

- .w64_endproc

Delimits the end of a function with unwind data. MASM has no such
directive, but it doesn't need it since it delimits functions with PROC
and ENDP. We need it because GAS (and subsequently, LLVM) has no such
mechanism.

- .w64_startchained

Starts an area of a function with additional operations to be undone in
case of an exception. The unwind info struct is chained to the parent
function. MASM has no equivalent; its support wasn't really designed for
compilers.

- .w64_endchained

Ends an area of a function with additional operations to be undone in
case of an exception. MASM has no equivalent; its support wasn't really
designed for compilers.

- .w64_unwind_only

Indicates that this function doesn't handle any exceptions. If it has a
handler specified in .w64_startproc, it is an unwind handler instead of
an exception handler.

MASM has no equivalent; its support wasn't really designed for compilers.

- .w64_lsda <symbol>, <size>

Specifies the location and <size> of the Language-Specific Data Area
(LSDA). In Win64 EH, the LSDA is stored in the unwind info structure
itself; the data will be copied into it upon emission.

MASM has no equivalent; its support wasn't really designed for compilers.

- .w64_pushreg <register>

Specifies that the non-volatile <register> is pushed onto the stack.
Equivalent to MASM's .pushreg directive.

- .w64_setframe <regsiter>, <offset>

Specifies the frame pointer register, and the offset (as a multiple of
16) from the stack pointer when the frame pointer is established.
Equivalent to MASM's .setframe directive, and similar to the
.cfi_def_cfa DWARF CFI directive.

- .w64_allocstack <size>

Specifies that some stack space was allocated. Equivalent to MASM's
.allocstack directive.

- .w64_savereg <register>, <offset>

Specifies that the <register> was saved at an <offset> relative to the
executable's base address. Only non-volatile registers should be
indicated here. Equivalent to both MASM's .savereg and .savexmm128
directives; I felt there was no need for a separate directive for XMM
registers.

- .w64_pushframe [code]

Specifies that this is an interrupt handler. On x86-64, interrupt
handlers have the original far stack pointer (SS:RSP), flags, and far
program counter (CS:RIP) pushed onto the stack upon entry. If [code] is
present, there is an error code on the stack in addition to the standard
data. Equivalent to MASM's .pushframe directive.

- .w64_endprolog

Delimits the end of the function prolog. After this directive, no Win64
EH directives other than a .w64_endproc (or .w64_endchained, if this is
a chained unwind area) may appear. Equivalent to MASM's .endprolog
directive.

Comments and suggestions are welcome. (And please, no licensing flame
wars.) Thanks for your time.

Chip

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Proposal for Win64 exception handling directives
  2011-05-18 23:12 Proposal for Win64 exception handling directives Charles Davis
@ 2011-05-19  5:52 ` Kai Tietz
  2011-05-19 17:10   ` Charles Davis
  0 siblings, 1 reply; 3+ messages in thread
From: Kai Tietz @ 2011-05-19  5:52 UTC (permalink / raw)
  To: Charles Davis; +Cc: binutils

2011/5/19 Charles Davis <cdavis@mymail.mines.edu>:
> (Since I'm not subscribed to this mailing list, please reply to all when
> replying.)
>
> Hi,
>
> My name is Chip Davis, and I'm working on adding support for Win64-style
> exception handling to LLVM (at the behest of several people). I know
> there's interest in adding similar support to GCC.
>
> Right now, I'm working on assembler-level directives for emitting the
> required data for Win64-style exception handling. Since LLVM's
> integrated assembler was designed to be compatible with GAS, I'm writing
> you this message to make sure we're on the same page.
>
> So, in no particular order, here are the directives that I propose for
> emitting Win64 unwind data from the assembler. They're loosely based on
> MASM's directives, but augmented to support compilers such as Clang and GCC.
>
> - .w64_startproc <symbol> [, <ehandler>]
>
> Delimits the beginning of a function callable from <symbol> that has
> unwind data. If <ehandler> is specified, it is an exception handler to
> be used for this function (or an unwind handler; see below). Roughly
> equivalent to MASM's FRAME attribute on procedures.
>
> - .w64_endproc
>
> Delimits the end of a function with unwind data. MASM has no such
> directive, but it doesn't need it since it delimits functions with PROC
> and ENDP. We need it because GAS (and subsequently, LLVM) has no such
> mechanism.
>
> - .w64_startchained
>
> Starts an area of a function with additional operations to be undone in
> case of an exception. The unwind info struct is chained to the parent
> function. MASM has no equivalent; its support wasn't really designed for
> compilers.
>
> - .w64_endchained
>
> Ends an area of a function with additional operations to be undone in
> case of an exception. MASM has no equivalent; its support wasn't really
> designed for compilers.
>
> - .w64_unwind_only
>
> Indicates that this function doesn't handle any exceptions. If it has a
> handler specified in .w64_startproc, it is an unwind handler instead of
> an exception handler.
>
> MASM has no equivalent; its support wasn't really designed for compilers.
>
> - .w64_lsda <symbol>, <size>
>
> Specifies the location and <size> of the Language-Specific Data Area
> (LSDA). In Win64 EH, the LSDA is stored in the unwind info structure
> itself; the data will be copied into it upon emission.
>
> MASM has no equivalent; its support wasn't really designed for compilers.
>
> - .w64_pushreg <register>
>
> Specifies that the non-volatile <register> is pushed onto the stack.
> Equivalent to MASM's .pushreg directive.
>
> - .w64_setframe <regsiter>, <offset>
>
> Specifies the frame pointer register, and the offset (as a multiple of
> 16) from the stack pointer when the frame pointer is established.
> Equivalent to MASM's .setframe directive, and similar to the
> .cfi_def_cfa DWARF CFI directive.
>
> - .w64_allocstack <size>
>
> Specifies that some stack space was allocated. Equivalent to MASM's
> .allocstack directive.
>
> - .w64_savereg <register>, <offset>
>
> Specifies that the <register> was saved at an <offset> relative to the
> executable's base address. Only non-volatile registers should be
> indicated here. Equivalent to both MASM's .savereg and .savexmm128
> directives; I felt there was no need for a separate directive for XMM
> registers.
>
> - .w64_pushframe [code]
>
> Specifies that this is an interrupt handler. On x86-64, interrupt
> handlers have the original far stack pointer (SS:RSP), flags, and far
> program counter (CS:RIP) pushed onto the stack upon entry. If [code] is
> present, there is an error code on the stack in addition to the standard
> data. Equivalent to MASM's .pushframe directive.
>
> - .w64_endprolog
>
> Delimits the end of the function prolog. After this directive, no Win64
> EH directives other than a .w64_endproc (or .w64_endchained, if this is
> a chained unwind area) may appear. Equivalent to MASM's .endprolog
> directive.
>
> Comments and suggestions are welcome. (And please, no licensing flame
> wars.) Thanks for your time.
>
> Chip

Chip,

well, what you want to do here is already done fot binutils. Please
see in gas/condig/obj-coff-seh.c for the implementation of
pseudo-codes for SEH

Regards,
Kai

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Proposal for Win64 exception handling directives
  2011-05-19  5:52 ` Kai Tietz
@ 2011-05-19 17:10   ` Charles Davis
  0 siblings, 0 replies; 3+ messages in thread
From: Charles Davis @ 2011-05-19 17:10 UTC (permalink / raw)
  To: Kai Tietz; +Cc: binutils

On 5/18/11 11:52 PM, Kai Tietz wrote:
> 2011/5/19 Charles Davis <cdavis@mymail.mines.edu>:
>> (Since I'm not subscribed to this mailing list, please reply to all when
>> replying.)
>>
>> Hi,
>>
>> My name is Chip Davis, and I'm working on adding support for Win64-style
>> exception handling to LLVM (at the behest of several people). I know
>> there's interest in adding similar support to GCC.
>>
>> Right now, I'm working on assembler-level directives for emitting the
>> required data for Win64-style exception handling. Since LLVM's
>> integrated assembler was designed to be compatible with GAS, I'm writing
>> you this message to make sure we're on the same page.
>>
>> So, in no particular order, here are the directives that I propose for
>> emitting Win64 unwind data from the assembler. They're loosely based on
>> MASM's directives, but augmented to support compilers such as Clang and GCC.
>>
>> - .w64_startproc <symbol> [, <ehandler>]
>>
>> Delimits the beginning of a function callable from <symbol> that has
>> unwind data. If <ehandler> is specified, it is an exception handler to
>> be used for this function (or an unwind handler; see below). Roughly
>> equivalent to MASM's FRAME attribute on procedures.
>>
>> - .w64_endproc
>>
>> Delimits the end of a function with unwind data. MASM has no such
>> directive, but it doesn't need it since it delimits functions with PROC
>> and ENDP. We need it because GAS (and subsequently, LLVM) has no such
>> mechanism.
>>
>> - .w64_startchained
>>
>> Starts an area of a function with additional operations to be undone in
>> case of an exception. The unwind info struct is chained to the parent
>> function. MASM has no equivalent; its support wasn't really designed for
>> compilers.
>>
>> - .w64_endchained
>>
>> Ends an area of a function with additional operations to be undone in
>> case of an exception. MASM has no equivalent; its support wasn't really
>> designed for compilers.
>>
>> - .w64_unwind_only
>>
>> Indicates that this function doesn't handle any exceptions. If it has a
>> handler specified in .w64_startproc, it is an unwind handler instead of
>> an exception handler.
>>
>> MASM has no equivalent; its support wasn't really designed for compilers.
>>
>> - .w64_lsda <symbol>, <size>
>>
>> Specifies the location and <size> of the Language-Specific Data Area
>> (LSDA). In Win64 EH, the LSDA is stored in the unwind info structure
>> itself; the data will be copied into it upon emission.
>>
>> MASM has no equivalent; its support wasn't really designed for compilers.
>>
>> - .w64_pushreg <register>
>>
>> Specifies that the non-volatile <register> is pushed onto the stack.
>> Equivalent to MASM's .pushreg directive.
>>
>> - .w64_setframe <regsiter>, <offset>
>>
>> Specifies the frame pointer register, and the offset (as a multiple of
>> 16) from the stack pointer when the frame pointer is established.
>> Equivalent to MASM's .setframe directive, and similar to the
>> .cfi_def_cfa DWARF CFI directive.
>>
>> - .w64_allocstack <size>
>>
>> Specifies that some stack space was allocated. Equivalent to MASM's
>> .allocstack directive.
>>
>> - .w64_savereg <register>, <offset>
>>
>> Specifies that the <register> was saved at an <offset> relative to the
>> executable's base address. Only non-volatile registers should be
>> indicated here. Equivalent to both MASM's .savereg and .savexmm128
>> directives; I felt there was no need for a separate directive for XMM
>> registers.
>>
>> - .w64_pushframe [code]
>>
>> Specifies that this is an interrupt handler. On x86-64, interrupt
>> handlers have the original far stack pointer (SS:RSP), flags, and far
>> program counter (CS:RIP) pushed onto the stack upon entry. If [code] is
>> present, there is an error code on the stack in addition to the standard
>> data. Equivalent to MASM's .pushframe directive.
>>
>> - .w64_endprolog
>>
>> Delimits the end of the function prolog. After this directive, no Win64
>> EH directives other than a .w64_endproc (or .w64_endchained, if this is
>> a chained unwind area) may appear. Equivalent to MASM's .endprolog
>> directive.
>>
>> Comments and suggestions are welcome. (And please, no licensing flame
>> wars.) Thanks for your time.
>>
>> Chip
> 
> Chip,
> 
> well, what you want to do here is already done fot binutils. Please
> see in gas/condig/obj-coff-seh.c for the implementation of
> pseudo-codes for SEH
Thanks for that.

Chip

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-05-19 17:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-18 23:12 Proposal for Win64 exception handling directives Charles Davis
2011-05-19  5:52 ` Kai Tietz
2011-05-19 17:10   ` Charles Davis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).