[patch gas]: Add pseudos for generation of runtime function entries by gas

Kai Tietz ktietz70@googlemail.com
Tue Aug 11 10:29:00 GMT 2009


Hello,

I would like to show the patch for .pdata and .xdata generation of
pe-coff targets via gas, and to get some feed-back.
This patch includes support for arm, ppc, arm, sh (3&4), mips, and
x64. As for x86 there is no OS support for runtime function
information, I spared this part. It would just increase executable
size for x86 PE and there is no real gain for this target.

Short overview:
  There are at the moment three different function entry formats preset.
  The first is the MIPS one (could be also used here for x86). The
second version is for ARM, PPC, SH3, and SH4 mainly for Windows CE.
The third is the IA64 and x64 version. Note, the IA64 isn't
implemented yet, but to find information about it, please see
specification about IA64 on
http://download.intel.com/design/Itanium/Downloads/245358.pdf file.

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

  The second variant 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, a PDATA_EH block is placed directly before function entry
(expressed by .seh_eh pseudo).

  The third version has a function entry block of BeginAddress (RVA),
EndAddress (RVA), and UnwindData (RVA). The description of the
prologue, excepetion-handler, and additional SEH data is stored within
the UNWIND_DATA field in the xdata section.

  The pseudos:
  .seh_proc <fct_name>
     This specifies, that a SEH block begins for the function
<fct_name>. This is valid for all targets.
  .seh_endprologue
     By this pseudo the location of the prologue end-address (taken by
the current code address of the appearance of this pseudo). Valid for
all targets.
  .seh_handler <handler>[,<handler-data>]
    This pseudo specifies the handler function to be used. For version
2 the handler-data field specifies the user optional data block. For
version 3 the handler-data field can be a rva to user-data (for
FHANDLER), if the name is @unwind the UHANDLER unwind block is
generated, and if it is @except (or not specified at all) EHANDLER
exception block is generated.
  .seh_eh
    This pseudo is used for version 2 to indicate the location of the
function begin in assembly. Here the PDATA_EH data is may stored to.
  .seh_32/.seh_no32
   This pseudos are just used for version 2 (see above for
description). At the moment it defaults to no32, if not specified.
  .seh_endproc
   By this pseudo the end of the SEH block is specified.
  .seh_setframe <reg>,<offset>
    By this pseudo the frame-register and the offset (value between
0-240 with 16-byte alignment) can be specified. This is just used by
version 3.
  .seh_stackalloc <size>
    By this stack allocation in code is described for version 3.
  .seh_pushreg <reg>
    By this a general register push in code is described for version 3.
  .seh_savereg <reg>
    By this a general register save to memory in code is described for
version 3.
  .seh_savemm <mm>
    By this a mm register save to memory in code is described for version 3.
  .seh_savexmm
    By this a xmm register save to memory in code is described for version 3.
  .seh_pushframe
    By this information about entry kind can be described for version 3.
  .seh_scope <begin>,<end>,<handler>,<jump>
    By this SCOPED entries for unwind or exceptions can be specified
for version 3. This is just valid for UHANDLE and EHANDLER xdata
descriptor and a global handler has to be specified. For handler and
jump arguments, names of @1,@0, and @null can be used and they are
specifying that a constant instead of a rva has to be used.

2009-08-11  Kai Tietz  <kai.tietz@onevision.com>

	* config/obj-coff-seh.c: New file.
	* config/obj-coff-seh.h: Likewise.
	* config/obj-coff.c (obj-coff-seh.c): Add include.
	(coff_pseudo_table): Add new .seh... commands.
	* config/obj-coff.h (obj_coff_seh_do_final): Add new
	function prototype.
	(obj_coff_generate_pdata): New obj-coff hook.
	* gas/write.c (size_seg): Avoid sizing of already sized
	sections.
	(write_object_file): Call conditional hook
	objc_coff_generate_pdata.
	* Makefile.in: Add dependencies for new files.
	* Makefile.am: Regenerated.

Tested for x86_64-pc-mingw32, i686-pc-linux, x86_64-pc-linux,
i686-pc-mingw32, and for cygwin. Base test I did for mips and arm.
This patch needs additional documentation in gas, and a lot of tests,
but first I would like to get response about it.

Cheers,
Kai

-- 
|  (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x64_gas_seh.diff
Type: text/x-c
Size: 46481 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20090811/07bcc837/attachment.bin>


More information about the Binutils mailing list