gas .align limit
Alan Modra
amodra@gmail.com
Fri May 16 12:18:28 GMT 2025
More information about the Binutils mailing list
Fri May 16 12:18:28 GMT 2025
- Previous message (by thread): ld testsuite fail with --disable-plugins
- Next message (by thread): gas .align limit
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 != ',')
--
Alan Modra
- Previous message (by thread): ld testsuite fail with --disable-plugins
- Next message (by thread): gas .align limit
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list