Skip to content

Commit ff4c035

Browse files
committed
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.
1 parent e04c2a8 commit ff4c035

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

gas/read.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ static unsigned int bundle_lock_depth;
234234
#endif
235235

236236
static void do_s_func (int end_p, const char *default_prefix);
237-
static void s_align (int, int);
238237
static void s_altmacro (int);
239238
static void s_bad_end (int);
240239
static void s_reloc (int);
@@ -1514,13 +1513,19 @@ s_abort (int ignore ATTRIBUTE_UNUSED)
15141513
as_fatal (_(".abort detected. Abandoning ship."));
15151514
}
15161515

1516+
#ifndef TC_ALIGN_LIMIT
1517+
/* Limit alignment in code to 1G, to limit the amount of memory used
1518+
by rs_code_align frags. */
1519+
#define TC_ALIGN_LIMIT \
1520+
((subseg_text_p (now_seg) \
1521+
&& stdoutput->arch_info->bits_per_address >= 32) \
1522+
? 30 : stdoutput->arch_info->bits_per_address - 1)
1523+
#endif
1524+
15171525
/* Handle the .align pseudo-op. A positive ARG is a default alignment
15181526
(in bytes). A negative ARG is the negative of the length of the
15191527
fill pattern. BYTES_P is non-zero if the alignment value should be
15201528
interpreted as the byte boundary, rather than the power of 2. */
1521-
#ifndef TC_ALIGN_LIMIT
1522-
#define TC_ALIGN_LIMIT (stdoutput->arch_info->bits_per_address - 1)
1523-
#endif
15241529

15251530
static void
15261531
s_align (signed int arg, int bytes_p)
@@ -1573,7 +1578,8 @@ s_align (signed int arg, int bytes_p)
15731578
if (align > align_limit)
15741579
{
15751580
align = align_limit;
1576-
as_warn (_("alignment too large: %u assumed"), align_limit);
1581+
as_warn (_("alignment too large: %u assumed"),
1582+
bytes_p ? 1u << align_limit : align_limit);
15771583
}
15781584

15791585
if (*input_line_pointer != ',')

0 commit comments

Comments
 (0)