1 /* seh pdata/xdata coff object file format
2 Copyright (C) 2009-2024 Free Software Foundation, Inc.
4 This file is part of GAS.
6 GAS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 GAS is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GAS; see the file COPYING. If not, write to the Free
18 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
21 #include "obj-coff-seh.h"
24 /* Private segment collection list. */
32 static seh_context
*seh_ctx_cur
= NULL
;
34 static htab_t seh_hash
;
36 static struct seh_seg_list
*x_segcur
= NULL
;
37 static struct seh_seg_list
*p_segcur
= NULL
;
39 static void write_function_xdata (seh_context
*);
40 static void write_function_pdata (seh_context
*);
43 /* Build based on segment the derived .pdata/.xdata
44 segment name containing origin segment's postfix name part. */
46 get_pxdata_name (segT seg
, const char *base_name
)
48 const char *name
,*dollar
, *dot
;
51 name
= bfd_section_name (seg
);
53 dollar
= strchr (name
, '$');
54 dot
= strchr (name
+ 1, '.');
62 else if (dot
< dollar
)
67 sname
= notes_concat (base_name
, name
, NULL
);
72 /* Allocate a seh_seg_list structure. */
73 static struct seh_seg_list
*
74 alloc_pxdata_item (segT seg
, int subseg
, char *name
)
76 struct seh_seg_list
*r
;
78 r
= notes_alloc (sizeof (struct seh_seg_list
) + strlen (name
));
85 /* Generate pdata/xdata segment with same linkonce properties
88 make_pxdata_seg (segT cseg
, char *name
)
90 segT save_seg
= now_seg
;
91 int save_subseg
= now_subseg
;
95 r
= subseg_new (name
, 0);
96 /* Check if code segment is marked as linked once. */
97 flags
= (bfd_section_flags (cseg
)
98 & (SEC_LINK_ONCE
| SEC_LINK_DUPLICATES_DISCARD
99 | SEC_LINK_DUPLICATES_ONE_ONLY
| SEC_LINK_DUPLICATES_SAME_SIZE
100 | SEC_LINK_DUPLICATES_SAME_CONTENTS
));
102 /* Add standard section flags. */
103 flags
|= SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
| SEC_DATA
;
105 /* Apply possibly linked once flags to new generated segment, too. */
106 if (!bfd_set_section_flags (r
, flags
))
107 as_bad (_("bfd_set_section_flags: %s"),
108 bfd_errmsg (bfd_get_error ()));
110 /* Restore to previous segment. */
111 subseg_set (save_seg
, save_subseg
);
116 seh_hash_insert (const char *name
, struct seh_seg_list
*item
)
118 str_hash_insert (seh_hash
, name
, item
, 1);
121 static struct seh_seg_list
*
122 seh_hash_find (char *name
)
124 return (struct seh_seg_list
*) str_hash_find (seh_hash
, name
);
127 static struct seh_seg_list
*
128 seh_hash_find_or_make (segT cseg
, const char *base_name
)
130 struct seh_seg_list
*item
;
133 /* Initialize seh_hash once. */
135 seh_hash
= str_htab_create ();
137 name
= get_pxdata_name (cseg
, base_name
);
139 item
= seh_hash_find (name
);
142 item
= alloc_pxdata_item (make_pxdata_seg (cseg
, name
), 0, name
);
144 seh_hash_insert (item
->seg_name
, item
);
152 /* Check if current segment has same name. */
154 seh_validate_seg (const char *directive
)
156 const char *cseg_name
, *nseg_name
;
157 if (seh_ctx_cur
->code_seg
== now_seg
)
159 cseg_name
= bfd_section_name (seh_ctx_cur
->code_seg
);
160 nseg_name
= bfd_section_name (now_seg
);
161 as_bad (_("%s used in segment '%s' instead of expected '%s'"),
162 directive
, nseg_name
, cseg_name
);
163 ignore_rest_of_line ();
167 /* Switch back to the code section, whatever that may be. */
169 obj_coff_seh_code (int ignored ATTRIBUTE_UNUSED
)
171 subseg_set (seh_ctx_cur
->code_seg
, 0);
175 switch_xdata (int subseg
, segT code_seg
)
177 x_segcur
= seh_hash_find_or_make (code_seg
, ".xdata");
179 subseg_set (x_segcur
->seg
, subseg
);
183 switch_pdata (segT code_seg
)
185 p_segcur
= seh_hash_find_or_make (code_seg
, ".pdata");
187 subseg_set (p_segcur
->seg
, p_segcur
->subseg
);
190 /* Parsing routines. */
192 /* Return the style of SEH unwind info to generate. */
195 seh_get_target_kind (void)
198 return seh_kind_unknown
;
200 switch (bfd_get_arch (stdoutput
))
202 case bfd_arch_aarch64
:
204 case bfd_arch_powerpc
:
209 switch (bfd_get_mach (stdoutput
))
211 case bfd_mach_x86_64
:
212 case bfd_mach_x86_64_intel_syntax
:
219 return seh_kind_mips
;
222 /* Should return seh_kind_x64. But not implemented yet. */
223 return seh_kind_unknown
;
228 return seh_kind_unknown
;
231 /* Verify that seh directives are supported. */
234 verify_target (const char *directive
)
236 if (seh_get_target_kind () == seh_kind_unknown
)
238 as_warn (_("%s ignored for this target"), directive
);
239 ignore_rest_of_line ();
245 /* Verify that we're in the context of a seh_proc. */
248 verify_context (const char *directive
)
250 if (seh_ctx_cur
== NULL
)
252 as_bad (_("%s used outside of .seh_proc block"), directive
);
253 ignore_rest_of_line ();
259 /* Similar, except we also verify the appropriate target. */
262 verify_context_and_target (const char *directive
, seh_kind target
)
264 if (seh_get_target_kind () != target
)
266 as_warn (_("%s ignored for this target"), directive
);
267 ignore_rest_of_line ();
270 return verify_context (directive
);
273 /* Skip whitespace and a comma. Error if the comma is not seen. */
276 skip_whitespace_and_comma (int required
)
279 if (*input_line_pointer
== ',')
281 input_line_pointer
++;
287 as_bad (_("missing separator"));
288 ignore_rest_of_line ();
291 demand_empty_rest_of_line ();
295 /* Mark current context to use 32-bit instruction (arm). */
298 obj_coff_seh_32 (int what
)
300 if (!verify_context_and_target ((what
? ".seh_32" : ".seh_no32"),
304 seh_ctx_cur
->use_instruction_32
= (what
? 1 : 0);
305 demand_empty_rest_of_line ();
308 /* Set for current context the handler and optional data (arm). */
311 obj_coff_seh_eh (int what ATTRIBUTE_UNUSED
)
313 if (!verify_context_and_target (".seh_eh", seh_kind_arm
))
316 /* Write block to .text if exception handler is set. */
317 seh_ctx_cur
->handler_written
= 1;
318 emit_expr (&seh_ctx_cur
->handler
, 4);
319 emit_expr (&seh_ctx_cur
->handler_data
, 4);
321 demand_empty_rest_of_line ();
324 /* Set for current context the default handler (x64). */
327 obj_coff_seh_handler (int what ATTRIBUTE_UNUSED
)
332 if (!verify_target (".seh_handler")
333 || !verify_context (".seh_handler"))
336 if (*input_line_pointer
== 0 || *input_line_pointer
== '\n')
338 as_bad (_(".seh_handler requires a handler"));
339 demand_empty_rest_of_line ();
345 if (*input_line_pointer
== '@')
347 name_end
= get_symbol_name (&symbol_name
);
349 seh_ctx_cur
->handler
.X_op
= O_constant
;
350 seh_ctx_cur
->handler
.X_add_number
= 0;
352 if (strcasecmp (symbol_name
, "@0") == 0
353 || strcasecmp (symbol_name
, "@null") == 0)
355 else if (strcasecmp (symbol_name
, "@1") == 0)
356 seh_ctx_cur
->handler
.X_add_number
= 1;
358 as_bad (_("unknown constant value '%s' for handler"), symbol_name
);
360 (void) restore_line_pointer (name_end
);
363 expression (&seh_ctx_cur
->handler
);
365 seh_ctx_cur
->handler_data
.X_op
= O_constant
;
366 seh_ctx_cur
->handler_data
.X_add_number
= 0;
367 seh_ctx_cur
->handler_flags
= 0;
369 if (!skip_whitespace_and_comma (0))
372 if (seh_get_target_kind () == seh_kind_x64
)
376 name_end
= get_symbol_name (&symbol_name
);
378 if (strcasecmp (symbol_name
, "@unwind") == 0)
379 seh_ctx_cur
->handler_flags
|= UNW_FLAG_UHANDLER
;
380 else if (strcasecmp (symbol_name
, "@except") == 0)
381 seh_ctx_cur
->handler_flags
|= UNW_FLAG_EHANDLER
;
383 as_bad (_(".seh_handler constant '%s' unknown"), symbol_name
);
385 (void) restore_line_pointer (name_end
);
387 while (skip_whitespace_and_comma (0));
391 expression (&seh_ctx_cur
->handler_data
);
392 demand_empty_rest_of_line ();
394 if (seh_ctx_cur
->handler_written
)
395 as_warn (_(".seh_handler after .seh_eh is ignored"));
399 /* Switch to subsection for handler data for exception region (x64). */
402 obj_coff_seh_handlerdata (int what ATTRIBUTE_UNUSED
)
404 if (!verify_context_and_target (".seh_handlerdata", seh_kind_x64
))
406 demand_empty_rest_of_line ();
408 switch_xdata (seh_ctx_cur
->subsection
+ 1, seh_ctx_cur
->code_seg
);
411 /* Mark end of current context. */
414 do_seh_endproc (void)
416 seh_ctx_cur
->end_addr
= symbol_temp_new_now ();
418 write_function_xdata (seh_ctx_cur
);
419 write_function_pdata (seh_ctx_cur
);
424 obj_coff_seh_endproc (int what ATTRIBUTE_UNUSED
)
426 if (!verify_target (".seh_endproc"))
428 demand_empty_rest_of_line ();
429 if (seh_ctx_cur
== NULL
)
431 as_bad (_(".seh_endproc used without .seh_proc"));
434 seh_validate_seg (".seh_endproc");
438 /* Mark begin of new context. */
441 obj_coff_seh_proc (int what ATTRIBUTE_UNUSED
)
446 if (!verify_target (".seh_proc"))
448 if (seh_ctx_cur
!= NULL
)
450 as_bad (_("previous SEH entry not closed (missing .seh_endproc)"));
454 if (*input_line_pointer
== 0 || *input_line_pointer
== '\n')
456 as_bad (_(".seh_proc requires function label name"));
457 demand_empty_rest_of_line ();
461 seh_ctx_cur
= XCNEW (seh_context
);
463 seh_ctx_cur
->code_seg
= now_seg
;
465 if (seh_get_target_kind () == seh_kind_x64
)
467 x_segcur
= seh_hash_find_or_make (seh_ctx_cur
->code_seg
, ".xdata");
468 seh_ctx_cur
->subsection
= x_segcur
->subseg
;
469 x_segcur
->subseg
+= 2;
474 name_end
= get_symbol_name (&symbol_name
);
475 seh_ctx_cur
->func_name
= xstrdup (symbol_name
);
476 (void) restore_line_pointer (name_end
);
478 demand_empty_rest_of_line ();
480 seh_ctx_cur
->start_addr
= symbol_temp_new_now ();
483 /* Mark end of prologue for current context. */
486 obj_coff_seh_endprologue (int what ATTRIBUTE_UNUSED
)
488 if (!verify_target (".seh_endprologue")
489 || !verify_context (".seh_endprologue")
490 || !seh_validate_seg (".seh_endprologue"))
492 demand_empty_rest_of_line ();
494 if (seh_ctx_cur
->endprologue_addr
!= NULL
)
495 as_warn (_("duplicate .seh_endprologue in .seh_proc block"));
497 seh_ctx_cur
->endprologue_addr
= symbol_temp_new_now ();
500 /* End-of-file hook. */
503 obj_coff_seh_do_final (void)
505 if (seh_ctx_cur
!= NULL
)
506 as_bad (_("open SEH entry at end of file (missing .seh_endproc)"));
509 /* Enter a prologue element into current context (x64). */
512 seh_x64_make_prologue_element (int code
, int info
, offsetT off
)
514 seh_prologue_element
*n
;
516 if (seh_ctx_cur
== NULL
)
518 if (seh_ctx_cur
->elems_count
== seh_ctx_cur
->elems_max
)
520 seh_ctx_cur
->elems_max
+= 8;
521 seh_ctx_cur
->elems
= XRESIZEVEC (seh_prologue_element
,
523 seh_ctx_cur
->elems_max
);
526 n
= &seh_ctx_cur
->elems
[seh_ctx_cur
->elems_count
++];
530 n
->pc_addr
= symbol_temp_new_now ();
533 /* Helper to read a register name from input stream (x64). */
536 seh_x64_read_reg (const char *directive
, int kind
)
538 static const char * const int_regs
[16] =
539 { "rax", "rcx", "rdx", "rbx", "rsp", "rbp","rsi","rdi",
540 "r8","r9","r10","r11","r12","r13","r14","r15" };
541 static const char * const xmm_regs
[16] =
542 { "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7",
543 "xmm8", "xmm9", "xmm10","xmm11","xmm12","xmm13","xmm14","xmm15" };
545 const char * const *regs
= NULL
;
547 char *symbol_name
= NULL
;
564 if (*input_line_pointer
== '%')
565 ++input_line_pointer
;
566 name_end
= get_symbol_name (& symbol_name
);
568 for (i
= 0; i
< 16; i
++)
569 if (! strcasecmp (regs
[i
], symbol_name
))
572 (void) restore_line_pointer (name_end
);
574 /* Error if register not found, or EAX used as a frame pointer. */
575 if (i
== 16 || (kind
== 0 && i
== 0))
577 as_bad (_("invalid register for %s"), directive
);
584 /* Add a register push-unwind token to the current context. */
587 obj_coff_seh_pushreg (int what ATTRIBUTE_UNUSED
)
591 if (!verify_context_and_target (".seh_pushreg", seh_kind_x64
)
592 || !seh_validate_seg (".seh_pushreg"))
595 reg
= seh_x64_read_reg (".seh_pushreg", 1);
596 demand_empty_rest_of_line ();
601 seh_x64_make_prologue_element (UWOP_PUSH_NONVOL
, reg
, 0);
604 /* Add a register frame-unwind token to the current context. */
607 obj_coff_seh_pushframe (int what ATTRIBUTE_UNUSED
)
611 if (!verify_context_and_target (".seh_pushframe", seh_kind_x64
)
612 || !seh_validate_seg (".seh_pushframe"))
617 if (is_name_beginner (*input_line_pointer
))
621 get_symbol_name (&identifier
);
622 if (strcmp (identifier
, "code") != 0)
624 as_bad(_("invalid argument \"%s\" for .seh_pushframe. Expected \"code\" or nothing"),
631 demand_empty_rest_of_line ();
633 seh_x64_make_prologue_element (UWOP_PUSH_MACHFRAME
, code
, 0);
636 /* Add a register save-unwind token to current context. */
639 obj_coff_seh_save (int what
)
641 const char *directive
= (what
== 1 ? ".seh_savereg" : ".seh_savexmm");
642 int code
, reg
, scale
;
645 if (!verify_context_and_target (directive
, seh_kind_x64
)
646 || !seh_validate_seg (directive
))
649 reg
= seh_x64_read_reg (directive
, what
);
651 if (!skip_whitespace_and_comma (1))
654 off
= get_absolute_expression ();
655 demand_empty_rest_of_line ();
661 as_bad (_("%s offset is negative"), directive
);
665 scale
= (what
== 1 ? 8 : 16);
667 if ((off
& (scale
- 1)) == 0 && off
<= (offsetT
) (0xffff * scale
))
669 code
= (what
== 1 ? UWOP_SAVE_NONVOL
: UWOP_SAVE_XMM128
);
672 else if (off
< (offsetT
) 0xffffffff)
673 code
= (what
== 1 ? UWOP_SAVE_NONVOL_FAR
: UWOP_SAVE_XMM128_FAR
);
676 as_bad (_("%s offset out of range"), directive
);
680 seh_x64_make_prologue_element (code
, reg
, off
);
683 /* Add a stack-allocation token to current context. */
686 obj_coff_seh_stackalloc (int what ATTRIBUTE_UNUSED
)
691 if (!verify_context_and_target (".seh_stackalloc", seh_kind_x64
)
692 || !seh_validate_seg (".seh_stackalloc"))
695 off
= get_absolute_expression ();
696 demand_empty_rest_of_line ();
702 as_bad (_(".seh_stackalloc offset is negative"));
706 if ((off
& 7) == 0 && off
<= 128)
707 code
= UWOP_ALLOC_SMALL
, info
= (off
- 8) >> 3, off
= 0;
708 else if ((off
& 7) == 0 && off
<= (offsetT
) (0xffff * 8))
709 code
= UWOP_ALLOC_LARGE
, info
= 0, off
>>= 3;
710 else if (off
<= (offsetT
) 0xffffffff)
711 code
= UWOP_ALLOC_LARGE
, info
= 1;
714 as_bad (_(".seh_stackalloc offset out of range"));
718 seh_x64_make_prologue_element (code
, info
, off
);
721 /* Add a frame-pointer token to current context. */
724 obj_coff_seh_setframe (int what ATTRIBUTE_UNUSED
)
729 if (!verify_context_and_target (".seh_setframe", seh_kind_x64
)
730 || !seh_validate_seg (".seh_setframe"))
733 reg
= seh_x64_read_reg (".seh_setframe", 0);
735 if (!skip_whitespace_and_comma (1))
738 off
= get_absolute_expression ();
739 demand_empty_rest_of_line ();
744 as_bad (_(".seh_setframe offset is negative"));
746 as_bad (_(".seh_setframe offset out of range"));
748 as_bad (_(".seh_setframe offset not a multiple of 16"));
749 else if (seh_ctx_cur
->framereg
!= 0)
750 as_bad (_("duplicate .seh_setframe in current .seh_proc"));
753 seh_ctx_cur
->framereg
= reg
;
754 seh_ctx_cur
->frameoff
= off
;
755 seh_x64_make_prologue_element (UWOP_SET_FPREG
, 0, 0);
759 /* Data writing routines. */
761 /* Output raw integers in 1, 2, or 4 bytes. */
766 FRAG_APPEND_1_CHAR (byte
);
772 md_number_to_chars (frag_more (2), data
, 2);
778 md_number_to_chars (frag_more (4), data
, 4);
781 /* Write out prologue data for x64. */
784 seh_x64_write_prologue_data (const seh_context
*c
)
788 /* We have to store in reverse order. */
789 for (i
= c
->elems_count
- 1; i
>= 0; --i
)
791 const seh_prologue_element
*e
= c
->elems
+ i
;
794 /* First comes byte offset in code. */
795 exp
.X_op
= O_subtract
;
796 exp
.X_add_symbol
= e
->pc_addr
;
797 exp
.X_op_symbol
= c
->start_addr
;
798 exp
.X_add_number
= 0;
801 /* Second comes code+info packed into a byte. */
802 out_one ((e
->info
<< 4) | e
->code
);
806 case UWOP_PUSH_NONVOL
:
807 case UWOP_ALLOC_SMALL
:
809 case UWOP_PUSH_MACHFRAME
:
810 /* These have no extra data. */
813 case UWOP_ALLOC_LARGE
:
816 case UWOP_SAVE_NONVOL_FAR
:
817 case UWOP_SAVE_XMM128_FAR
:
818 /* An unscaled 4 byte offset. */
824 case UWOP_SAVE_NONVOL
:
825 case UWOP_SAVE_XMM128
:
826 /* A scaled 2 byte offset. */
837 seh_x64_size_prologue_data (const seh_context
*c
)
841 for (i
= c
->elems_count
- 1; i
>= 0; --i
)
842 switch (c
->elems
[i
].code
)
844 case UWOP_PUSH_NONVOL
:
845 case UWOP_ALLOC_SMALL
:
847 case UWOP_PUSH_MACHFRAME
:
851 case UWOP_SAVE_NONVOL
:
852 case UWOP_SAVE_XMM128
:
856 case UWOP_SAVE_NONVOL_FAR
:
857 case UWOP_SAVE_XMM128_FAR
:
861 case UWOP_ALLOC_LARGE
:
862 ret
+= (c
->elems
[i
].info
? 3 : 2);
872 /* Write out the xdata information for one function (x64). */
875 seh_x64_write_function_xdata (seh_context
*c
)
877 int flags
, count_unwind_codes
;
880 /* Set 4-byte alignment. */
881 frag_align (2, 0, 0);
883 c
->xdata_addr
= symbol_temp_new_now ();
884 flags
= c
->handler_flags
;
885 count_unwind_codes
= seh_x64_size_prologue_data (c
);
887 /* ubyte:3 version, ubyte:5 flags. */
888 out_one ((flags
<< 3) | 1);
890 /* Size of prologue. */
891 if (c
->endprologue_addr
)
893 exp
.X_op
= O_subtract
;
894 exp
.X_add_symbol
= c
->endprologue_addr
;
895 exp
.X_op_symbol
= c
->start_addr
;
896 exp
.X_add_number
= 0;
902 /* Number of slots (i.e. shorts) in the unwind codes array. */
903 if (count_unwind_codes
> 255)
904 as_fatal (_("too much unwind data in this .seh_proc"));
905 out_one (count_unwind_codes
);
907 /* ubyte:4 frame-reg, ubyte:4 frame-reg-offset. */
908 /* Note that frameoff is already a multiple of 16, and therefore
909 the offset is already both scaled and shifted into place. */
910 out_one (c
->frameoff
| c
->framereg
);
912 seh_x64_write_prologue_data (c
);
914 /* We need to align prologue data. */
915 if (count_unwind_codes
& 1)
918 if (flags
& (UNW_FLAG_EHANDLER
| UNW_FLAG_UHANDLER
))
920 /* Force the use of segment-relative relocations instead of absolute
921 valued expressions. Don't adjust for constants (e.g. NULL). */
922 if (c
->handler
.X_op
== O_symbol
)
923 c
->handler
.X_op
= O_symbol_rva
;
924 emit_expr (&c
->handler
, 4);
927 /* Handler data will be tacked in here by subsections. */
930 /* Write out xdata for one function. */
933 write_function_xdata (seh_context
*c
)
935 segT save_seg
= now_seg
;
936 int save_subseg
= now_subseg
;
938 /* MIPS, SH, ARM don't have xdata. */
939 if (seh_get_target_kind () != seh_kind_x64
)
942 switch_xdata (c
->subsection
, c
->code_seg
);
944 seh_x64_write_function_xdata (c
);
946 subseg_set (save_seg
, save_subseg
);
949 /* Write pdata section data for one function (arm). */
952 seh_arm_write_function_pdata (seh_context
*c
)
955 unsigned int prol_len
= 0, func_len
= 0;
958 /* Start address of the function. */
960 exp
.X_add_symbol
= c
->start_addr
;
961 exp
.X_add_number
= 0;
964 exp
.X_op
= O_subtract
;
965 exp
.X_add_symbol
= c
->end_addr
;
966 exp
.X_op_symbol
= c
->start_addr
;
967 exp
.X_add_number
= 0;
968 if (resolve_expression (&exp
) && exp
.X_op
== O_constant
)
969 func_len
= exp
.X_add_number
;
971 as_bad (_(".seh_endproc in a different section from .seh_proc"));
973 if (c
->endprologue_addr
)
975 exp
.X_op
= O_subtract
;
976 exp
.X_add_symbol
= c
->endprologue_addr
;
977 exp
.X_op_symbol
= c
->start_addr
;
978 exp
.X_add_number
= 0;
980 if (resolve_expression (&exp
) && exp
.X_op
== O_constant
)
981 prol_len
= exp
.X_add_number
;
983 as_bad (_(".seh_endprologue in a different section from .seh_proc"));
986 /* Both function and prologue are in units of instructions. */
987 func_len
>>= (c
->use_instruction_32
? 2 : 1);
988 prol_len
>>= (c
->use_instruction_32
? 2 : 1);
990 /* Assemble the second word of the pdata. */
991 val
= prol_len
& 0xff;
992 val
|= (func_len
& 0x3fffff) << 8;
993 if (c
->use_instruction_32
)
995 if (c
->handler_written
)
1000 /* Write out pdata for one function. */
1003 write_function_pdata (seh_context
*c
)
1006 segT save_seg
= now_seg
;
1007 int save_subseg
= now_subseg
;
1008 memset (&exp
, 0, sizeof (expressionS
));
1009 switch_pdata (c
->code_seg
);
1011 switch (seh_get_target_kind ())
1014 exp
.X_op
= O_symbol_rva
;
1015 exp
.X_add_number
= 0;
1017 exp
.X_add_symbol
= c
->start_addr
;
1018 emit_expr (&exp
, 4);
1019 exp
.X_op
= O_symbol_rva
;
1020 exp
.X_add_number
= 0;
1021 exp
.X_add_symbol
= c
->end_addr
;
1022 emit_expr (&exp
, 4);
1023 exp
.X_op
= O_symbol_rva
;
1024 exp
.X_add_number
= 0;
1025 exp
.X_add_symbol
= c
->xdata_addr
;
1026 emit_expr (&exp
, 4);
1030 exp
.X_op
= O_symbol
;
1031 exp
.X_add_number
= 0;
1033 exp
.X_add_symbol
= c
->start_addr
;
1034 emit_expr (&exp
, 4);
1035 exp
.X_add_symbol
= c
->end_addr
;
1036 emit_expr (&exp
, 4);
1038 emit_expr (&c
->handler
, 4);
1039 emit_expr (&c
->handler_data
, 4);
1041 exp
.X_add_symbol
= (c
->endprologue_addr
1042 ? c
->endprologue_addr
1044 emit_expr (&exp
, 4);
1048 seh_arm_write_function_pdata (c
);
1055 subseg_set (save_seg
, save_subseg
);