What are the .seh_ * build commands that gcc issues?

I am using gcc -S for a welcome world program. What are the 5 .seh_ commands? I can not find much information about them when I search.

.file "hi.c" .def __main; .scl 2; .type 32; .endef .section .rdata,"dr" .LC0: .ascii "Hello World\0" .text .globl main .def main; .scl 2; .type 32; .endef .seh_proc main main: pushq %rbp .seh_pushreg %rbp movq %rsp, %rbp .seh_setframe %rbp, 0 subq $32, %rsp .seh_stackalloc 32 .seh_endprologue call __main leaq .LC0(%rip), %rcx call puts movl $0, %eax addq $32, %rsp popq %rbp ret .seh_endproc .ident "GCC: (rubenvb-4.8.0) 4.8.0" .def puts; .scl 2; .type 32; .endef 
+8
assembly gcc x86-64
source share
3 answers

This is a gas implementation of MASM aliases for processing frames to generate executable sections .pdata and .xdata (material for handling structured exceptions). Also check out Raw Pseudo Operations . Apparently, if your code might be on the stack during the SEH shutdown operation, you should use them.

I found a bit more information at https://sourceware.org/ml/binutils/2009-08/msg00193.html . This thread seems to be the original gas test to add support for all .set_ * pseudo ops.

I would like to show a patch for generating .pdata and .xdata pe-coff using gas, and get some feedback. This patch includes support for arms, ppc, arm, sh (3 and 4), mips and x64. As for x86 there is no OS support for runtime function information, I spared this part. It would simply increase the executable size for x86 PE and there is no real gain for this purpose.

Short review:
Three different input formats are currently preinstalled.

The first is MIPS. The second version is for ARM, PPC, SH3, and SH4 mainly for Windows CE. The third is the IA64 and x64 versions. Please note: IA64 is not yet implemented, but for information on this, please see the IA64 specification at http://download.intel.com/design/Itanium/Downloads/245358.pdf file.

The first version has only entries in the pdata section: BeginAddress, EndAddress, ExceptionHandler, HandlerData and PrologueEndAddress. Each value is a pointer to the corresponding data and has a size of 4 bytes.

The second option has the following entries in the pdata section. BeginAddress, PrologueLength (8 bits), EndAddress (22 bits), Use 32-bit instruction (1 bit) and Exception-Handler-Exists (1 bit). If the FunctionLength is zero or the Exception-Handler-Exists bit is true, the DATA_EH block is placed immediately before the function input.

In the third version, there is an input block for the BeginAddress (RVA), EndAddress (RVA) and UnwindData (RVA) functions. The prolog description, excepetion handler, and additional SEH data are stored within the UNWIND_DATA field in the xdata section.

.seh_proc <fct_name>
This indicates that the SEH block begins for the function <fct_name>. This is true for all purposes.

.seh_endprologue
According to this pseudo-location of the end address of the prologue (taken by the current code address of the appearance, this is pseudo). Valid for all purposes.

.seh_handler <handler> [, <handler-data>]
This pseudo defines the handler function to be used. For version 2, the handler-data field indicates an optional block of user data. For version 3, the handler data field may be rva for user data (for FHANDLER) if the name @unwind is generated by the UHANDLER unwind block, and if it is @except (or not specified at all), the EHANDLER exception block is generated.

.seh_eh
This pseudo is used for version 2 to indicate the location of a function in an assembly. Here, the PDATA_EH data may be stored.

.seh_32 / .seh_no32
This alias is used only for version 2 (see above for a description). Currently, it defaults to no32 if not specified.

.seh_endproc
This pseudo-definition indicates the end of the SEH block.

.seh_setframe <reg>, <offset>
By this pseudo-frame register and offset (value between 0-240 with 16-byte alignment). It is just used in version 3.

.seh_stackalloc <size>
This stack distribution in the code is described for version 3.

.seh_pushreg <reg>
Moreover, for version 3, a general code for entering the code is described.

.seh_savereg <reg>
Moreover, for version 3, a general register is described, which is stored in memory in code.

.seh_savemm <mm>
In this case, for version 3, the mm register is stored in the code.

.seh_savexmm
Thus, for version 3, the register xmm is stored in memory in code.

.seh_pushframe
This input type information can be described for version 3.

.seh_scope <begin>, <end>, <handler>, <jump>
For these entries, SCOPED can be specified for uncoiling or exception for version 3. This is true only for UHANDLE and EHANDLER xdata descriptor and global handler. For and handlers, you can use the jump arguments, the names @ 1, @ 0 and @null, and they indicate that you need to use a constant instead of rva.

There is also a rather tough discussion of .xdata and .pdata (along with link links) at https://sourceware.org/ml/binutils/2009-04/msg00181.html .

+5
source share

I stopped them from output with:

 gcc -S -fno-asynchronous-unwind-tables hi.c 

so I can look at that. But I am pleased that I no longer have a way out.

+4
source share

They seem to be related to exception handling. That is all I could find.

http://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/external/gpl3/binutils/dist/gas/config/obj-coff-seh.h

+2
source share

All Articles