type = SHT_PROGBITS;
flags = SHF_ALLOC + SHF_EXECINSTR;
} else if (strcmp(sectname, ".comment") == 0) {
+ align = 0;
type = SHT_PROGBITS;
flags = 0;
} else {
unsigned long align, unsigned long line)
{
/*@dependent@*/ /*@null@*/ elf_secthead *esd;
+ const yasm_intnum *old_align_intn;
+ unsigned long old_align = 0;
esd = yasm_section_get_data(sect, &elf_section_data);
if (!esd)
yasm_internal_error(N_("NULL elf section data in section_align"));
- elf_secthead_set_align(esd, yasm_intnum_create_uint(align));
+ old_align_intn = elf_secthead_get_align(esd);
+ if (old_align_intn)
+ old_align = yasm_intnum_get_uint(old_align_intn);
+
+ if (align > old_align)
+ elf_secthead_set_align(esd, yasm_intnum_create_uint(align));
}
static yasm_symrec *
elf_section_type elf_secthead_get_type(elf_secthead *shead);
int elf_secthead_is_empty(elf_secthead *shead);
struct yasm_symrec *elf_secthead_get_sym(elf_secthead *shead);
+const struct yasm_intnum *elf_secthead_get_align(const elf_secthead *shead);
const struct yasm_intnum *elf_secthead_set_align(elf_secthead *shead,
struct yasm_intnum *align);
elf_section_index elf_secthead_get_index(elf_secthead *shead);
{
/*@dependent@*/ yasm_valparam *bound, *fill = NULL, *maxskip = NULL;
yasm_expr *boundval, *fillval = NULL, *maxskipval = NULL;
+ yasm_intnum *boundintn;
bound = yasm_vps_first(valparams);
boundval = bound->param;
/* If .align is the first bytecode in the section, it's really specifying
* section alignment.
*/
- if (parser_gas->prev_bc
- == yasm_section_bcs_first(parser_gas->cur_section)) {
- yasm_intnum *boundintn = yasm_expr_get_intnum(&boundval, NULL);
- unsigned long boundint;
- if (!boundintn) {
- yasm__error(cur_line, N_("section alignment not constnat"));
- return NULL;
- }
- boundint = yasm_intnum_get_uint(boundintn);
+ boundintn = yasm_expr_get_intnum(&boundval, NULL);
+ if (boundintn) {
+ unsigned long boundint = yasm_intnum_get_uint(boundintn);
/* Alignments must be a power of two. */
- if ((boundint & (boundint - 1)) != 0) {
- yasm__error(cur_line,
- N_("section alignment is not a power of two"));
- return NULL;
+ if ((boundint & (boundint - 1)) == 0) {
+ yasm_objfmt_section_align(parser_gas->objfmt,
+ parser_gas->cur_section, boundint,
+ cur_line);
}
-
- yasm_objfmt_section_align(parser_gas->objfmt, parser_gas->cur_section,
- boundint, cur_line);
- return NULL;
}
return yasm_bc_create_align(boundval, fillval, maxskipval,