flag, not just sections named ".text".
* section.h (yasm_object_get_general): Add code flag parameter to indicate
if section is intended to contain code.
(yasm_section_is_code): New, to get value of code flag.
* section.c (yasm_section): Add flag to section structure.
(yasm_object_get_general, yasm_section_is_code): Implement flag.
* *-objfmt.c, stabs-dbgfmt.c: Update call to yasm_object_get_general,
setting code flag appropriately (only elf *really* handles this correctly,
coff still needs to handle GAS flags to work fully from GAS mode).
* gas-parser.h (yasm_parser_gas): Remove code_section flag.
* gas-bison.y (gas_switch_section): Don't set.
(gas_parser_align): Use yasm_section_is_code() instead of code_section flag.
* gas-parser.c: Don't initialize code_section flag.
svn path=/trunk/yasm/; revision=1318
unsigned long opt_flags; /* storage for optimizer flags */
+ int code; /* section contains code (instructions) */
int res_only; /* allow only resb family of bytecodes? */
/* the bytecodes for the section's contents */
/*@-onlytrans@*/
yasm_section *
yasm_object_get_general(yasm_object *object, const char *name,
- yasm_expr *start, int res_only, int *isnew,
+ yasm_expr *start, int code, int res_only, int *isnew,
unsigned long line)
{
yasm_section *s;
STAILQ_INIT(&s->relocs);
s->destroy_reloc = NULL;
+ s->code = code;
s->res_only = res_only;
*isnew = 1;
return (sect->type == SECTION_ABSOLUTE);
}
+int
+yasm_section_is_code(yasm_section *sect)
+{
+ return sect->code;
+}
+
unsigned long
yasm_section_get_opt_flags(const yasm_section *sect)
{
* \param name section name
* \param start starting address (ignored if section already exists),
* NULL if 0 or don't care.
+ * \param code if nonzero, section is intended to contain code
+ * (e.g. alignment should be made with NOP instructions, not 0)
* \param res_only if nonzero, only space-reserving bytecodes are allowed in
* the section (ignored if section already exists)
* \param isnew output; set to nonzero if section did not already exist
*/
/*@dependent@*/ yasm_section *yasm_object_get_general
(yasm_object *object, const char *name,
- /*@null@*/ /*@only@*/ yasm_expr *start, int res_only,
+ /*@null@*/ /*@only@*/ yasm_expr *start, int code, int res_only,
/*@out@*/ int *isnew, unsigned long line);
/** Create a new absolute section. No checking is performed at creation to
*/
int yasm_section_is_absolute(yasm_section *sect);
+/** Determine if a section is flagged to contain code.
+ * \param sect section
+ * \return Nonzero if section is flagged to contain code.
+ */
+int yasm_section_is_code(yasm_section *sect);
+
/** Get yasm_optimizer-specific flags. For yasm_optimizer use only.
* \param sect section
* \return Optimizer-specific flags.
info.dbgfmt_stabs = dbgfmt_stabs;
info.lastline = 0;
info.stabcount = 0;
- info.stab = yasm_object_get_general(dbgfmt_stabs->object, ".stab", 0, 0,
+ info.stab = yasm_object_get_general(dbgfmt_stabs->object, ".stab", 0, 0, 0,
&new, 0);
if (!new) {
yasm_bytecode *last = yasm_section_bcs_last(info.stab);
}
info.stabstr = yasm_object_get_general(dbgfmt_stabs->object, ".stabstr", 0,
- 0, &new, 0);
+ 0, 0, &new, 0);
if (!new) {
yasm_bytecode *last = yasm_section_bcs_last(info.stabstr);
if (last == NULL)
retval = yasm_object_get_general(objfmt_bin->object, sectname,
yasm_expr_create_ident(
- yasm_expr_int(yasm_intnum_create_uint(start)), line), resonly,
- &isnew, line);
+ yasm_expr_int(yasm_intnum_create_uint(start)), line),
+ strcmp(sectname, ".text") == 0, resonly, &isnew, line);
if (isnew) {
if (have_alignval) {
N_("Standard COFF does not support qualifier `%s'"), vp->val);
}
- retval = yasm_object_get_general(objfmt_coff->object, sectname, 0, resonly,
- &isnew, line);
+ retval = yasm_object_get_general(objfmt_coff->object, sectname, 0,
+ (flags & COFF_STYP_EXECUTE) != 0,
+ resonly, &isnew, line);
if (isnew)
coff_objfmt_init_new_section(objfmt_coff, retval, sectname, flags,
/* Add to end of linker directives */
sect = yasm_object_get_general(objfmt_coff->object, ".drectve", 0, 0,
- &isnew, line);
+ 0, &isnew, line);
/* Initialize directive section if needed */
if (isnew)
if ((vp = yasm_vps_first(valparams)) && !vp->param && vp->val != NULL) {
retval = yasm_object_get_general(objfmt_dbg->object, vp->val,
yasm_expr_create_ident(yasm_expr_int(yasm_intnum_create_uint(200)),
- line), 0, &isnew, line);
+ line), 0, 0, &isnew, line);
if (isnew) {
fprintf(objfmt_dbg->dbgfile, "(new) ");
yasm_symtab_define_label(
N_("Unrecognized qualifier `%s'"), vp->val);
}
- retval = yasm_object_get_general(objfmt_elf->object, sectname, 0, resonly,
+ retval = yasm_object_get_general(objfmt_elf->object, sectname, 0,
+ (flags & SHF_EXECINSTR) != 0, resonly,
&isnew, line);
if (isnew) {
N_("Unrecognized qualifier `%s'"), vp->val);
}
- retval = yasm_object_get_general(objfmt_xdf->object, sectname, 0, resonly,
- &isnew, line);
+ retval = yasm_object_get_general(objfmt_xdf->object, sectname, 0, 1,
+ resonly, &isnew, line);
if (isnew) {
xdf_section_data *data;
parser_gas->prev_bc = yasm_section_bcs_last(new_section);
} else
yasm__error(cur_line, N_("invalid section name `%s'"), name);
- parser_gas->code_section = !strcmp(name, ".text");
}
static yasm_bytecode *
}
return yasm_bc_create_align(boundval, fillval, maxskipval,
- parser_gas->code_section ?
+ yasm_section_is_code(parser_gas->cur_section) ?
yasm_arch_get_fill(parser_gas->arch) : NULL,
cur_line);
}
parser_gas.state = INITIAL;
- parser_gas.code_section = !strcmp(yasm_section_get_name(def_sect), ".text");
-
parser_gas.rept = NULL;
/* yacc debugging, needs YYDEBUG set in bison.y.in to work */
INSTDIR
} state;
- int code_section;
-
/*@null@*/ gas_rept *rept;
} yasm_parser_gas;
EXTRA_DIST += modules/parsers/gas/tests/datavis2.asm
EXTRA_DIST += modules/parsers/gas/tests/datavis2.errwarn
EXTRA_DIST += modules/parsers/gas/tests/datavis2.hex
+EXTRA_DIST += modules/parsers/gas/tests/execsect.asm
+EXTRA_DIST += modules/parsers/gas/tests/execsect.errwarn
+EXTRA_DIST += modules/parsers/gas/tests/execsect.hex
EXTRA_DIST += modules/parsers/gas/tests/gas-instlabel.asm
EXTRA_DIST += modules/parsers/gas/tests/gas-instlabel.errwarn
EXTRA_DIST += modules/parsers/gas/tests/gas-instlabel.hex
--- /dev/null
+.section .foobar, "ax",@progbits
+xorl %eax, %eax
+.p2align 3
+xorl %eax, %eax
--- /dev/null
+7f
+45
+4c
+46
+01
+01
+01
+00
+00
+00
+00
+00
+00
+00
+00
+00
+01
+00
+03
+00
+01
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+c0
+00
+00
+00
+00
+00
+00
+00
+34
+00
+00
+00
+00
+00
+28
+00
+06
+00
+01
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+31
+c0
+8d
+b6
+00
+00
+00
+00
+31
+c0
+00
+00
+00
+2e
+74
+65
+78
+74
+00
+2e
+66
+6f
+6f
+62
+61
+72
+00
+2e
+73
+74
+72
+74
+61
+62
+00
+2e
+73
+79
+6d
+74
+61
+62
+00
+2e
+73
+68
+73
+74
+72
+74
+61
+62
+00
+00
+00
+00
+00
+2d
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+01
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+04
+00
+f1
+ff
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+03
+00
+05
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+03
+00
+04
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+1f
+00
+00
+00
+03
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+4c
+00
+00
+00
+29
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+0f
+00
+00
+00
+03
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+78
+00
+00
+00
+03
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+17
+00
+00
+00
+02
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+7c
+00
+00
+00
+40
+00
+00
+00
+02
+00
+00
+00
+04
+00
+00
+00
+04
+00
+00
+00
+10
+00
+00
+00
+01
+00
+00
+00
+01
+00
+00
+00
+06
+00
+00
+00
+00
+00
+00
+00
+40
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+10
+00
+00
+00
+00
+00
+00
+00
+07
+00
+00
+00
+01
+00
+00
+00
+06
+00
+00
+00
+00
+00
+00
+00
+40
+00
+00
+00
+0a
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+00
+08
+00
+00
+00
+00
+00
+00
+00