From: Alan Modra Date: Fri, 16 May 2025 03:01:39 +0000 (+0930) Subject: gas .align limit X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ff4c03516c;p=thirdparty%2Fbinutils-gdb.git gas .align limit At the moment we allow alignment of up to half the address space, which is stupidly large and results in OOM on x86_64. Change that to 1G alignment in text sections. Also fix the warning message on exceeding max allowed alignment. * read.c (TC_ALIGN_LIMIT): Limit to 30 in text sections. (s_align): Correct "alignment too large" value. --- diff --git a/gas/read.c b/gas/read.c index a73e814324b..2691f31c4ad 100644 --- a/gas/read.c +++ b/gas/read.c @@ -234,7 +234,6 @@ static unsigned int bundle_lock_depth; #endif static void do_s_func (int end_p, const char *default_prefix); -static void s_align (int, int); static void s_altmacro (int); static void s_bad_end (int); static void s_reloc (int); @@ -1514,13 +1513,19 @@ s_abort (int ignore ATTRIBUTE_UNUSED) as_fatal (_(".abort detected. Abandoning ship.")); } +#ifndef TC_ALIGN_LIMIT +/* Limit alignment in code to 1G, to limit the amount of memory used + by rs_code_align frags. */ +#define TC_ALIGN_LIMIT \ + ((subseg_text_p (now_seg) \ + && stdoutput->arch_info->bits_per_address >= 32) \ + ? 30 : stdoutput->arch_info->bits_per_address - 1) +#endif + /* Handle the .align pseudo-op. A positive ARG is a default alignment (in bytes). A negative ARG is the negative of the length of the fill pattern. BYTES_P is non-zero if the alignment value should be interpreted as the byte boundary, rather than the power of 2. */ -#ifndef TC_ALIGN_LIMIT -#define TC_ALIGN_LIMIT (stdoutput->arch_info->bits_per_address - 1) -#endif static void s_align (signed int arg, int bytes_p) @@ -1573,7 +1578,8 @@ s_align (signed int arg, int bytes_p) if (align > align_limit) { align = align_limit; - as_warn (_("alignment too large: %u assumed"), align_limit); + as_warn (_("alignment too large: %u assumed"), + bytes_p ? 1u << align_limit : align_limit); } if (*input_line_pointer != ',')