]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas HANDLE_ALIGN and frag_alloc
authorAlan Modra <amodra@gmail.com>
Tue, 14 Jan 2025 04:38:23 +0000 (15:08 +1030)
committerAlan Modra <amodra@gmail.com>
Thu, 16 Jan 2025 09:27:19 +0000 (19:57 +1030)
This adds the section to HANDLE_ALIGN args, so that the frag created
by the ppc backend can be properly allocated on the frag obstack.
I've added an extra param to frag_alloc too, for cases where we know
the frag requires at least some bytes in fr_literal.  This simplifies
some existing code, for example in compress_debug and relax_segment.
In the case of the relax_segment code, I think we may have had a bug
there in using obstack_blank_fast, which doesn't check that the frag
has room.

* config/tc-ppc.c (ppc_handle_align): Add section param,
use frag obstack to allocate frag.
* config/tc-ppc.h (HANDLE_ALIGN, ppc_handle_align): Add extra
param.
* config/tc-aarch64.h (HANDLE_ALIGN): Add extra param.
* config/tc-alpha.h: Likewise.
* config/tc-arc.h: Likewise.
* config/tc-arm.h: Likewise.
* config/tc-avr.h: Likewise.
* config/tc-epiphany.h: Likewise.
* config/tc-frv.h: Likewise.
* config/tc-i386.h: Likewise.
* config/tc-ia64.h: Likewise.
* config/tc-kvx.h: Likewise.
* config/tc-loongarch.h: Likewise.
* config/tc-m32c.h: Likewise.
* config/tc-m32r.h: Likewise.
* config/tc-metag.h: Likewise.
* config/tc-mips.h: Likewise.
* config/tc-mn10300.h: Likewise.
* config/tc-nds32.h: Likewise.
* config/tc-riscv.h: Likewise.
* config/tc-rl78.h: Likewise.
* config/tc-rx.h: Likewise.
* config/tc-sh.h: Likewise.
* config/tc-sparc.h: Likewise.
* config/tc-spu.h: Likewise.
* config/tc-tilegx.h: Likewise.
* config/tc-tilepro.h: Likewise.
* config/tc-v850.h: Likewise.
* config/tc-visium.h: Likewise.
* config/tc-wasm32.h: Likewise.
* config/tc-xtensa.h: Likewise.
* frags.h (frag_alloc): Update prototype.
* frags.c (frag_alloc): Add extra size param, allocate extra.
(frag_new): Update.
* subsegs.c (subseg_set_rest): Update frag_alloc call.
* write.c: Formatting.
(cvt_frag_to_fill): Pass sec to HANDLE_ALIGN.
(compress_frag): Update frag_alloc call.
(compress_debug): Use new frag_alloc to simplify frag sizing.
(relax_segment): Likewise.

35 files changed:
gas/config/tc-aarch64.h
gas/config/tc-alpha.h
gas/config/tc-arc.h
gas/config/tc-arm.h
gas/config/tc-avr.h
gas/config/tc-epiphany.h
gas/config/tc-frv.h
gas/config/tc-i386.h
gas/config/tc-ia64.h
gas/config/tc-kvx.h
gas/config/tc-loongarch.h
gas/config/tc-m32c.h
gas/config/tc-m32r.h
gas/config/tc-metag.h
gas/config/tc-mips.h
gas/config/tc-mn10300.h
gas/config/tc-nds32.h
gas/config/tc-ppc.c
gas/config/tc-ppc.h
gas/config/tc-riscv.h
gas/config/tc-rl78.h
gas/config/tc-rx.h
gas/config/tc-sh.h
gas/config/tc-sparc.h
gas/config/tc-spu.h
gas/config/tc-tilegx.h
gas/config/tc-tilepro.h
gas/config/tc-v850.h
gas/config/tc-visium.h
gas/config/tc-wasm32.h
gas/config/tc-xtensa.h
gas/frags.c
gas/frags.h
gas/subsegs.c
gas/write.c

index 52381e31b247e8b304a27e275cf247ec09ccfc77..acf1ce4aa03e2e594ab42e88f4285cdc47521de0 100644 (file)
@@ -182,7 +182,7 @@ struct aarch64_frag_type
 
 #define TC_FRAG_TYPE           struct aarch64_frag_type
 #define TC_FRAG_INIT(fragp, max_bytes) aarch64_init_frag (fragp, max_bytes)
-#define HANDLE_ALIGN(fragp)    aarch64_handle_align (fragp)
+#define HANDLE_ALIGN(sec, fragp) aarch64_handle_align (fragp)
 
 #define md_do_align(N, FILL, LEN, MAX, LABEL)                                  \
   if (FILL == NULL && (N) != 0 && ! need_pass_2 && subseg_text_p (now_seg))    \
index 6937ba0b0ffee9b40cd4353f297ec66f544e0dfb..466a7a0d9ac213a4b7bd0e82e5e72c93f2da4675 100644 (file)
@@ -108,7 +108,7 @@ extern void alpha_define_label (symbolS *);
 #define md_cons_align(nbytes) alpha_cons_align (nbytes)
 extern void alpha_cons_align (int);
 
-#define HANDLE_ALIGN(fragp) alpha_handle_align (fragp)
+#define HANDLE_ALIGN(sec, fragp) alpha_handle_align (fragp)
 extern void alpha_handle_align (struct frag *);
 
 #define MAX_MEM_FOR_RS_ALIGN_CODE  (3 + 4 + 8)
index 93a1e8d52e8d6122539e404513d1e7c0a372e834..727041a7169a2e314619ec3aba82229702486740 100644 (file)
@@ -111,7 +111,7 @@ extern const char *arc_target_format;
 /* HANDLE_ALIGN called after all the assembly has been done,
    so we can fill in all the rs_align_code type frags with
    nop instructions.  */
-#define HANDLE_ALIGN(FRAGP)     arc_handle_align (FRAGP)
+#define HANDLE_ALIGN(SEC, FRAGP) arc_handle_align (FRAGP)
 
 /* Values passed to md_apply_fix3 don't include the symbol value.  */
 #define MD_APPLY_SYM_VALUE(FIX) 0
index 8274632b9bdfbc4cdd22ee5d5f3210e596344a9c..24e2197d7e05c29776c24a1b43a8cb7f84f2ecd4 100644 (file)
@@ -230,7 +230,7 @@ arm_min (int am_p1, int am_p2)
 #define TC_FRAG_TYPE           struct arm_frag_type
 #define TC_FRAG_INIT(fragp, max_bytes) arm_init_frag (fragp, max_bytes)
 #define TC_ALIGN_ZERO_IS_DEFAULT 1
-#define HANDLE_ALIGN(fragp)    arm_handle_align (fragp)
+#define HANDLE_ALIGN(sec, fragp) arm_handle_align (fragp)
 /* PR gas/19276: COFF/PE segment alignment is already handled in coff_frob_section().  */
 #ifndef TE_PE
 #define SUB_SEGMENT_ALIGN(SEG, FRCHAIN)                                \
index 8e1b7b3d47e7866391d0792b7ccc60dabbe98bda..47f6778df738ce2c03123618aa26cd8ece2a8c26 100644 (file)
@@ -228,7 +228,7 @@ extern symbolS* avr_undefined_symbol (char*);
 #define md_post_relax_hook avr_post_relax_hook ()
 extern void avr_post_relax_hook (void);
 
-#define HANDLE_ALIGN(fragP) avr_handle_align (fragP)
+#define HANDLE_ALIGN(sec, fragP) avr_handle_align (fragP)
 extern void avr_handle_align (fragS *);
 
 struct avr_frag_data
index 63e5d527fa2b1150d344cd7dd628b04afa458470..dde673305f4b4a282c192f02b4235811189abeed 100644 (file)
@@ -72,7 +72,7 @@ extern void epiphany_cgen_md_operand (expressionS *);
   epiphany_cgen_parse_fix_exp (opinfo, exp)
 extern int epiphany_cgen_parse_fix_exp (int, expressionS *);
 
-#define HANDLE_ALIGN(f)  epiphany_handle_align (f)
+#define HANDLE_ALIGN(s, f) epiphany_handle_align (f)
 extern void epiphany_handle_align (fragS *);
 
 #define TARGET_FORMAT "elf32-epiphany"
index 9f86a2a58071fa4b5b72680d2d86d40152909eb4..21e3bac109594f963b613bb7deab41420ef2f86f 100644 (file)
@@ -99,7 +99,7 @@ extern void frv_frob_file (void);
    for little gain.  This code is not meant to be run anyway, so just
    emit nops.  */
 #define MAX_MEM_FOR_RS_ALIGN_CODE (3 + 4)
-#define HANDLE_ALIGN(FRAGP) do                                         \
+#define HANDLE_ALIGN(SEC, FRAGP) do                                            \
   if ((FRAGP)->fr_type == rs_align_code)                               \
     {                                                                  \
       valueT count = ((FRAGP)->fr_next->fr_address                     \
index 78de263b3267184d0f6e654631284fca5df85375..d93de2c7985d0f68134b1df1d09c7ddbacd2f3f3 100644 (file)
@@ -374,7 +374,7 @@ extern void i386_generate_nops (fragS *, char *, offsetT, int);
 #define md_generate_nops(frag, where, amount, control) \
   i386_generate_nops ((frag), (where), (amount), (control))
 
-#define HANDLE_ALIGN(fragP)                                            \
+#define HANDLE_ALIGN(sec, fragP)                                               \
 if (fragP->fr_type == rs_align_code)                                   \
   {                                                                    \
     offsetT __count = (fragP->fr_next->fr_address                      \
index 5ab7823ec85d1ff5f73bbdb7519ca22b26dae263..0f9810d5fd61d3cce1f58dd4dbdc3f401a07b0b0 100644 (file)
@@ -154,7 +154,7 @@ extern void ia64_convert_frag (fragS *);
 #define MD_PCREL_FROM_SECTION(fix,sec) ia64_pcrel_from_section (fix, sec)
 #define md_section_align(seg,size)     (size)
 #define md_do_align(n,f,l,m,j)         ia64_md_do_align (n,f,l,m)
-#define HANDLE_ALIGN(f)                        ia64_handle_align (f)
+#define HANDLE_ALIGN(s, f)             ia64_handle_align (f)
 #define md_elf_section_type(str,len)   ia64_elf_section_type (str, len)
 #define md_after_parse_args()          ia64_after_parse_args ()
 #define TC_DWARF2_EMIT_OFFSET          ia64_dwarf2_emit_offset
index a33b63c1d7914fb699e75e9c811b79e6407bb7c8..a4d0e2d9b13cc5025a90e7f463537f6fe9a94e1f 100644 (file)
@@ -296,8 +296,7 @@ extern void kvx_cons_fix_new (fragS *f, int where, int nbytes,
 
 /* Enable special handling for the alignment directive.  */
 extern void kvx_handle_align (fragS *);
-#undef HANDLE_ALIGN
-#define HANDLE_ALIGN kvx_handle_align
+#define HANDLE_ALIGN(s, f) kvx_handle_align (f)
 
 #ifdef OBJ_ELF
 
index 5873ad4d9f6e4b73eb2a0324aa439acd43a0579c..ebed8e0c049407c4917bb7d97b1678ea3e10204f 100644 (file)
@@ -139,7 +139,7 @@ extern void loongarch_pre_output_hook (void);
 
 #define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) 0
 
-#define HANDLE_ALIGN(fragp) loongarch_handle_align (fragp)
+#define HANDLE_ALIGN(sec, fragp) loongarch_handle_align (fragp)
 extern void loongarch_handle_align (struct frag *);
 #define MAX_MEM_FOR_RS_ALIGN_CODE (3 + 4)
 
index cc155a81cbb3cd1cb9cd52d2d7c2652372145ace..bcdca98a1915ad449068499f48f1a1fd3c495b92 100644 (file)
@@ -79,5 +79,5 @@ extern int m32c_is_colon_insn (char *, char *);
 #define H_TICK_HEX 1
 
 #define NOP_OPCODE (bfd_get_mach (stdoutput) == bfd_mach_m32c ? 0xde : 0x04)
-#define HANDLE_ALIGN(fragP)
+#define HANDLE_ALIGN(sec, fragP)
 #define MAX_MEM_FOR_RS_ALIGN_CODE 1
index 2d50b0a55837789f49b4475e6fd058acc77a39e9..6be96bb3c3183813301dc92b30bcfa6249fa280a 100644 (file)
@@ -63,7 +63,7 @@ extern long m32r_relax_frag (segT, fragS *, long);
 
 /* Fill in rs_align_code fragments.  */
 extern void m32r_handle_align (fragS *);
-#define HANDLE_ALIGN(f)  m32r_handle_align (f)
+#define HANDLE_ALIGN(s, f)  m32r_handle_align (f)
 
 #define MAX_MEM_FOR_RS_ALIGN_CODE  (1 + 2 + 4)
 
index ea7bbb2a0ba6459fa296430afa4f85e489c119ea..9d112c4ae706758a1d88614c0f7b5962ea5c4d37 100644 (file)
@@ -52,7 +52,7 @@ extern int metag_force_relocation (struct fix *);
 /* Call md_pcrel_from_section(), not md_pcrel_from().  */
 #define MD_PCREL_FROM_SECTION(FIX, SEC) md_pcrel_from_section (FIX, SEC)
 
-#define HANDLE_ALIGN(fragp) metag_handle_align (fragp)
+#define HANDLE_ALIGN(sec, fragp) metag_handle_align (fragp)
 extern void metag_handle_align (struct frag *);
 
 #define DWARF2_LINE_MIN_INSN_LENGTH 1
index 02e211e458d0d0a2a7623547f253803db46c2646..38a0e39b93738ac656edb2a643d0260006444c8a 100644 (file)
@@ -59,7 +59,7 @@ extern char mips_nop_opcode (void);
 #define NOP_OPCODE (mips_nop_opcode ())
 
 extern void mips_handle_align (struct frag *);
-#define HANDLE_ALIGN(fragp)  mips_handle_align (fragp)
+#define HANDLE_ALIGN(sec, fragp)  mips_handle_align (fragp)
 
 #define MAX_MEM_FOR_RS_ALIGN_CODE  (3 + 4)
 
index 77917ef6851bb2717029b602aff69504793ea9bf..ab6192e2aa0e7887048a79710b9ca88b602759fb 100644 (file)
@@ -125,7 +125,7 @@ extern bool mn10300_allow_local_subtract (expressionS *, expressionS *, segT);
 
 #define TC_FRAG_TYPE bool
 
-#define HANDLE_ALIGN(frag) mn10300_handle_align (frag)
+#define HANDLE_ALIGN(sec, frag) mn10300_handle_align (frag)
 extern void mn10300_handle_align (fragS *);
 
 /* Only allow call frame debug info optimization when linker relaxation is
index c5449f43476b3455175606c97067b50bfffd8336..14109f09dd06298d819d773744585f09fff2eb79 100644 (file)
@@ -112,7 +112,7 @@ extern void tc_nds32_frame_initial_instructions (void);
 #define GAS_SORT_RELOCS                                1
 /* Values passed to md_apply_fix don't include the symbol value.  */
 #define MD_APPLY_SYM_VALUE(FIX)                        0
-#define HANDLE_ALIGN(f)                                nds32_handle_align (f)
+#define HANDLE_ALIGN(s, f)                     nds32_handle_align (f)
 #undef DIFF_EXPR_OK                            /* They should be fixed in linker.  */
 #define md_relax_frag(segment, fragP, stretch) nds32_relax_frag (segment, fragP, stretch)
 #define WORKING_DOT_WORD                       /* We don't need to handle .word strangely.  */
index 9c3adb39950404235654e1dc956d3c768e36dfc8..f96140357488e03fdfc0e0b22e8431e0ba34a528 100644 (file)
@@ -6889,7 +6889,7 @@ ppc_nop_select (void)
 }
 
 void
-ppc_handle_align (struct frag *fragP)
+ppc_handle_align (segT sec, struct frag *fragP)
 {
   valueT count = (fragP->fr_next->fr_address
                  - (fragP->fr_address + fragP->fr_fix));
@@ -6928,7 +6928,9 @@ ppc_handle_align (struct frag *fragP)
          if (count == 0)
            return;
 
-         rest = xmalloc (SIZEOF_STRUCT_FRAG + 4);
+         segment_info_type *seginfo = seg_info (sec);
+         struct obstack *ob = &seginfo->frchainP->frch_obstack;
+         rest = frag_alloc (ob, 4);
          memcpy (rest, fragP, SIZEOF_STRUCT_FRAG);
          fragP->fr_next = rest;
          fragP = rest;
@@ -6952,7 +6954,9 @@ ppc_handle_align (struct frag *fragP)
             reduce the number of nops in the current frag by one.  */
          if (count > 4)
            {
-             struct frag *group_nop = xmalloc (SIZEOF_STRUCT_FRAG + 4);
+             segment_info_type *seginfo = seg_info (sec);
+             struct obstack *ob = &seginfo->frchainP->frch_obstack;
+             struct frag *group_nop = frag_alloc (ob, 4);
 
              memcpy (group_nop, fragP, SIZEOF_STRUCT_FRAG);
              group_nop->fr_address = group_nop->fr_next->fr_address - 4;
index b0893cd1ab2f540ab8587e629994f1a0e6f55227..f6b37f80ef4645b68d5ddd3d47bb13f71d6ab063 100644 (file)
@@ -73,14 +73,14 @@ extern const char *ppc_target_format (void);
 #define WORKING_DOT_WORD
 
 #define MAX_MEM_FOR_RS_ALIGN_CODE 4
-#define HANDLE_ALIGN(FRAGP)                                            \
+#define HANDLE_ALIGN(SEC, FRAGP)                                               \
   if ((FRAGP)->fr_type == rs_align_code)                               \
-    ppc_handle_align (FRAGP);
+    ppc_handle_align (SEC, FRAGP);
 
 extern unsigned int ppc_nop_select (void);
 #define NOP_OPCODE ppc_nop_select ()
 
-extern void ppc_handle_align (struct frag *);
+extern void ppc_handle_align (segT, struct frag *);
 extern void ppc_frag_check (struct frag *);
 
 #ifdef OBJ_ELF
index 6b25a791da800201b3b441604e7f1501e9a31bf8..e2e8e7af876384bb8d6204860714fd851bae1766 100644 (file)
@@ -62,7 +62,7 @@ extern bool riscv_frag_align_code (int);
     }
 
 extern void riscv_handle_align (fragS *);
-#define HANDLE_ALIGN riscv_handle_align
+#define HANDLE_ALIGN(s, f) riscv_handle_align (f)
 
 #define MAX_MEM_FOR_RS_ALIGN_CODE (3 + 4)
 
index 12aca9ea4c288774ada231f0baee2a56e3a81bbb..4a513250ab98582a03f6abe8538434439e863d3b 100644 (file)
@@ -76,7 +76,7 @@ extern void rl78_cons_fix_new (fragS *, int, int, expressionS *);
 #define MAX_RELOC_EXPANSION      8
 
 #define MAX_MEM_FOR_RS_ALIGN_CODE 8
-#define HANDLE_ALIGN(FRAG) rl78_handle_align (FRAG)
+#define HANDLE_ALIGN(SEC, FRAG) rl78_handle_align (FRAG)
 extern void rl78_handle_align (fragS *);
 
 #define elf_tc_final_processing        rl78_elf_final_processing
index 859a0b77c3a8e759a725cde4f6d550ee16e46d4f..3c4524f4aa9b4f327b46c71651145fbae04259a4 100644 (file)
@@ -97,7 +97,7 @@ extern void rx_cons_fix_new (fragS *, int, int, expressionS *,
     }
 
 #define MAX_MEM_FOR_RS_ALIGN_CODE 8
-#define HANDLE_ALIGN(FRAG) rx_handle_align (FRAG)
+#define HANDLE_ALIGN(SEC, FRAG) rx_handle_align (FRAG)
 extern void rx_handle_align (fragS *);
 
 #define RELOC_EXPANSION_POSSIBLE 1
index 38247ebbe170b96aa5774ee1cd09a779a4761aaf..fb1e4b812443850ab98a418182aae1b4f735a5dc 100644 (file)
@@ -53,7 +53,7 @@ extern int sh_optimize_expr (expressionS *, operatorT, expressionS *);
 
 /* When relaxing, we need to generate relocations for alignment
    directives.  */
-#define HANDLE_ALIGN(frag) sh_handle_align (frag)
+#define HANDLE_ALIGN(sec, frag) sh_handle_align (frag)
 extern void sh_handle_align (fragS *);
 
 #define MAX_MEM_FOR_RS_ALIGN_CODE (1 + 2)
index f18bc1d93ad6c26e8db8394e1c7ce9bf1e0a6372..b87212f011d70fbbbfbf1b142c44971f645ebae5 100644 (file)
@@ -75,7 +75,7 @@ extern int sparc_pic_code;
 #define md_cons_align(nbytes) sparc_cons_align (nbytes)
 extern void sparc_cons_align (int);
 
-#define HANDLE_ALIGN(fragp) sparc_handle_align (fragp)
+#define HANDLE_ALIGN(sec, fragp) sparc_handle_align (fragp)
 extern void sparc_handle_align (struct frag *);
 
 #define MAX_MEM_FOR_RS_ALIGN_CODE  (3 + 4 + 4)
index 8c132d3ce0b4cc29ed5b66f2e441405e1d7cf299..4c164856c1f4efd6f80772b315fc2654bae8fe46 100644 (file)
@@ -102,7 +102,7 @@ extern symbolS *section_symbol (asection *);
 
 /* Fill in rs_align_code fragments.  */
 extern void spu_handle_align (fragS *);
-#define HANDLE_ALIGN(frag)  spu_handle_align (frag)
+#define HANDLE_ALIGN(sec, frag)  spu_handle_align (frag)
 
 #define MAX_MEM_FOR_RS_ALIGN_CODE  (7 + 8)
 
index 08a87ae48d42eb43f919b55b88742a946296abb8..06db4416ec5719d97f973c0397647e7ac1ff1a14 100644 (file)
@@ -39,7 +39,7 @@ extern const char * tilegx_target_format (void);
 
 #define DIFF_EXPR_OK   /* foo-. gets turned into PC relative relocs */
 
-#define HANDLE_ALIGN(fragp) tilegx_handle_align (fragp)
+#define HANDLE_ALIGN(sec, fragp) tilegx_handle_align (fragp)
 extern void tilegx_handle_align (struct frag *);
 
 #define MAX_MEM_FOR_RS_ALIGN_CODE (7 + 8)
index 6fb98532c7ca60dccf23dfd5bd2100ab606cf21d..945d1cac9a1b0c6ec0886dbeea3cf40cc8bf71cf 100644 (file)
@@ -39,7 +39,7 @@
 
 #define DIFF_EXPR_OK   /* foo-. gets turned into PC relative relocs */
 
-#define HANDLE_ALIGN(fragp) tilepro_handle_align (fragp)
+#define HANDLE_ALIGN(sec, fragp) tilepro_handle_align (fragp)
 extern void tilepro_handle_align (struct frag *);
 
 #define MAX_MEM_FOR_RS_ALIGN_CODE (7 + 8)
index c06ab6848bed56ee7fe7a5b62ba83eb4f7ac8671..1e234416cd6719afbbe4b8e7e8704ca4393fd2de 100644 (file)
@@ -69,7 +69,7 @@ extern const struct relax_type md_relax_table[];
 
 /* When relaxing, we need to generate
    relocations for alignment directives.  */
-#define HANDLE_ALIGN(frag) v850_handle_align (frag)
+#define HANDLE_ALIGN(sec, frag) v850_handle_align (frag)
 extern void v850_handle_align (fragS *);
 
 /* We need space in a frag's fixed size to allow for alignment when relaxing.  */
index 6a5e8e2c67b8b0f8a11401edb12dcdfd9c68e9e5..01f86285d3f308b7be97980204e6d56e8f325502 100644 (file)
@@ -45,7 +45,7 @@
 #define tc_fix_adjustable(FIXP) visium_fix_adjustable (FIXP)
 extern bool visium_fix_adjustable (struct fix *);
 
-#define HANDLE_ALIGN(FRAGP)             \
+#define HANDLE_ALIGN(SEC, FRAGP)                \
   if ((FRAGP)->fr_type == rs_align_code) \
     visium_handle_align (FRAGP);
 extern void visium_handle_align (struct frag *);
index 32d7d8783b337699ffc52c8aa3175b8c895852c2..b2ccf1cff595107f1cfb7deb9d114e3f1b35e17b 100644 (file)
@@ -75,7 +75,7 @@ extern int wasm32_force_relocation (struct fix *);
 #define elf_tc_final_processing()
 #define md_post_relax_hook
 #define md_start_line_hook()
-#define HANDLE_ALIGN(fragP)
+#define HANDLE_ALIGN(sec, fragP)
 
 
 extern bool wasm32_fix_adjustable (struct fix *);
index 00d03c019438834cd18519233cd5f5147127dace..3d757e8413cc75b23c9d75089316f3c5a35d4a27 100644 (file)
@@ -378,7 +378,7 @@ extern void xtensa_init (int, char **);
 #define TEXT_SECTION_NAME              xtensa_section_rename (".text")
 #define DATA_SECTION_NAME              xtensa_section_rename (".data")
 #define BSS_SECTION_NAME               xtensa_section_rename (".bss")
-#define HANDLE_ALIGN(fragP)            xtensa_handle_align (fragP)
+#define HANDLE_ALIGN(sec, fragP)       xtensa_handle_align (fragP)
 #define MAX_MEM_FOR_RS_ALIGN_CODE      1
 
 
index a57a4d561873f23c041986a2f1b010513cfb7876..d067bb4761e0a240b1d84e4519ff796555fab425 100644 (file)
@@ -73,7 +73,7 @@ frag_alloc_check (const struct obstack *ob)
    hackery can be done in just one place.  */
 
 fragS *
-frag_alloc (struct obstack *ob)
+frag_alloc (struct obstack *ob, size_t extra)
 {
   fragS *ptr;
   int oalign;
@@ -81,7 +81,7 @@ frag_alloc (struct obstack *ob)
   (void) obstack_alloc (ob, 0);
   oalign = obstack_alignment_mask (ob);
   obstack_alignment_mask (ob) = 0;
-  ptr = (fragS *) obstack_alloc (ob, SIZEOF_STRUCT_FRAG);
+  ptr = (fragS *) obstack_alloc (ob, extra + SIZEOF_STRUCT_FRAG);
   obstack_alignment_mask (ob) = oalign;
   memset (ptr, 0, SIZEOF_STRUCT_FRAG);
   totalfrags++;
@@ -180,7 +180,7 @@ frag_new (size_t old_frags_var_max_size
   former_last_fragP = frchP->frch_last;
   gas_assert (former_last_fragP != 0);
   gas_assert (former_last_fragP == frag_now);
-  frag_now = frag_alloc (&frchP->frch_obstack);
+  frag_now = frag_alloc (&frchP->frch_obstack, 0);
 
   frag_now->fr_file = as_where (&frag_now->fr_line);
 
index a1dcea0be0c9edefa832731991044d9a70fdeb24..695277d7871c8d75b279f7ab7f49d83588f81b01 100644 (file)
@@ -124,7 +124,7 @@ extern void frag_append_1_char (int);
 #define FRAG_APPEND_1_CHAR(X) frag_append_1_char (X)
 
 void frag_init (void);
-fragS *frag_alloc (struct obstack *);
+fragS *frag_alloc (struct obstack *, size_t);
 void frag_grow (size_t nchars);
 char *frag_more (size_t nchars);
 void frag_align (int alignment, int fill_character, int max);
index 837af0564852c64093960d1fcbc25f2c8f353efa..e098ec4302a5f719161c6ff826bb58589093aec4 100644 (file)
@@ -127,7 +127,7 @@ subseg_set_rest (segT seg, subsegT subseg)
 #if __GNUC__ >= 2
       obstack_alignment_mask (&newP->frch_obstack) = __alignof__ (fragS) - 1;
 #endif
-      newP->frch_frag_now = frag_alloc (&newP->frch_obstack);
+      newP->frch_frag_now = frag_alloc (&newP->frch_obstack, 0);
       newP->frch_frag_now->fr_type = rs_fill;
       newP->frch_cfi_data = NULL;
       newP->frch_ginsn_data = NULL;
index e823160396133835b9de12166a780f19e4695467..439f6a6913a7521056fa38e842b7dec9bac2c4a8 100644 (file)
@@ -417,7 +417,7 @@ cvt_frag_to_fill (segT sec ATTRIBUTE_UNUSED, fragS *fragP)
     case rs_org:
     case rs_space:
 #ifdef HANDLE_ALIGN
-      HANDLE_ALIGN (fragP);
+      HANDLE_ALIGN (sec, fragP);
 #endif
     skip_align:
       know (fragP->fr_next != NULL);
@@ -737,11 +737,11 @@ resolve_reloc_expr_symbols (void)
          else if (sym != NULL && sec != NULL)
            {
              /* Convert relocs against local symbols to refer to the
-                corresponding section symbol plus offset instead.  Keep
-                PC-relative relocs of the REL variety intact though to
+                corresponding section symbol plus offset instead.  Keep
+                PC-relative relocs of the REL variety intact though to
                 prevent the offset from overflowing the relocated field,
-                unless it has enough bits to cover the whole address
-                space.  */
+                unless it has enough bits to cover the whole address
+                space.  */
              if (S_IS_LOCAL (sym)
                  && S_IS_DEFINED (sym)
                  && !symbol_section_p (sym)
@@ -1448,17 +1448,17 @@ compress_frag (bool use_zstd, void *ctx, const char *contents, int in_size,
   while (in_size > 0)
     {
       /* Reserve all the space available in the current chunk.
-         If none is available, start a new frag.  */
+        If none is available, start a new frag.  */
       avail_out = obstack_room (ob);
       if (avail_out <= 0)
-        {
-          obstack_finish (ob);
-          f = frag_alloc (ob);
+       {
+         obstack_finish (ob);
+         f = frag_alloc (ob, 0);
          f->fr_type = rs_fill;
-          (*last_newf)->fr_next = f;
-          *last_newf = f;
-          avail_out = obstack_room (ob);
-        }
+         (*last_newf)->fr_next = f;
+         *last_newf = f;
+         avail_out = obstack_room (ob);
+       }
       if (avail_out <= 0)
        as_fatal (_("can't extend frag"));
       next_out = obstack_next_free (ob);
@@ -1510,16 +1510,8 @@ compress_debug (bfd *abfd, asection *sec, void *xxx ATTRIBUTE_UNUSED)
 
   /* Create a new frag to contain the compression header.  */
   struct obstack *ob = &seginfo->frchainP->frch_obstack;
-  fragS *first_newf = frag_alloc (ob);
-  if (obstack_room (ob) < header_size)
-    first_newf = frag_alloc (ob);
-  if (obstack_room (ob) < header_size)
-    as_fatal (ngettext ("can't extend frag %lu char",
-                       "can't extend frag %lu chars",
-                       (unsigned long) header_size),
-             (unsigned long) header_size);
+  fragS *first_newf = frag_alloc (ob, header_size);
   fragS *last_newf = first_newf;
-  obstack_blank_fast (ob, header_size);
   last_newf->fr_type = rs_fill;
   last_newf->fr_fix = header_size;
   char *header = last_newf->fr_literal;
@@ -1577,7 +1569,7 @@ compress_debug (bfd *abfd, asection *sec, void *xxx ATTRIBUTE_UNUSED)
          fragS *newf;
 
          obstack_finish (ob);
-         newf = frag_alloc (ob);
+         newf = frag_alloc (ob, 0);
          newf->fr_type = rs_fill;
          last_newf->fr_next = newf;
          last_newf = newf;
@@ -2994,9 +2986,7 @@ relax_segment (struct frag *segment_frag_root, segT segment, int pass)
                      struct obstack *ob = &seginfo->frchainP->frch_obstack;
                      struct frag *newf;
 
-                     newf = frag_alloc (ob);
-                     obstack_blank_fast (ob, fragP->fr_var);
-                     obstack_finish (ob);
+                     newf = frag_alloc (ob, fragP->fr_var);
                      memcpy (newf, fragP, SIZEOF_STRUCT_FRAG);
                      memcpy (newf->fr_literal,
                              fragP->fr_literal + fragP->fr_fix,