00
10
42
-2e
-63
-6f
-6d
-6d
-65
-6e
-74
+2f
+31
+33
+33
+00
+00
+00
+00
54
0b
00
00
00
00
+40
00
-02
-00
-42
+40
+40
2f
31
-33
-33
+34
+34
00
00
00
00
00
00
-95
+a0
00
00
00
00
00
00
-a3
+ae
00
00
00
00
00
00
-b3
+be
00
00
00
00
00
00
-bf
+ca
00
00
00
00
00
00
-cd
+d8
00
00
00
00
00
00
-d9
+e4
00
00
00
00
00
00
-e7
+f2
00
00
00
00
00
00
-f6
-00
+01
+01
00
00
00
00
00
00
-03
+0e
01
00
00
00
00
00
-0d
+18
01
00
00
00
00
00
-18
+23
01
00
00
00
00
00
-25
+30
01
00
00
00
00
00
-35
+40
01
00
00
00
00
00
-44
+4f
01
00
00
00
00
00
-2e
-63
-6f
-6d
-6d
-65
-6e
-74
+00
+00
+00
+00
+5a
+01
+00
+00
00
00
00
00
00
00
-4f
+65
01
00
00
00
00
00
-5f
+75
01
00
00
72
00
2e
+72
+64
+61
+74
+61
+24
+7a
+7a
+7a
+00
+2e
6e
6f
74
72
00
2e
+72
+64
+61
+74
+61
+24
+7a
+7a
+7a
+00
+2e
6e
6f
74
}
iscode = 1;
} else if (strcmp(sectname, ".rdata") == 0
- || strncmp(sectname, ".rodata", 7) == 0) {
+ || strncmp(sectname, ".rodata", 7) == 0
+ || strncmp(sectname, ".rdata$", 7) == 0) {
flags = COFF_STYP_DATA;
if (objfmt_coff->win32) {
flags |= COFF_STYP_READ;
unsigned long line)
{
yasm_objfmt_coff *objfmt_coff = (yasm_objfmt_coff *)objfmt;
+ yasm_valparam *vp = yasm_vps_first(valparams);
if (yasm__strcasecmp(name, "export") == 0) {
- yasm_valparam *vp = yasm_vps_first(valparams);
int isnew;
yasm_section *sect;
yasm_datavalhead dvs;
line));
return 0;
+ } else if (yasm__strcasecmp(name, "ident") == 0) {
+ yasm_valparamhead sect_vps;
+ yasm_datavalhead dvs;
+ yasm_section *comment;
+ const char *sectname;
+
+ if (objfmt_coff->win32) {
+ /* Put ident data into .comment section for COFF, or .rdata$zzz
+ * to be compatible with the GNU linker, which doesn't ignore
+ * .comment (see binutils/gas/config/obj-coff.c:476-502).
+ */
+ sectname = ".rdata$zzz";
+ } else {
+ sectname = ".comment";
+ }
+ yasm_vps_initialize(§_vps);
+ yasm_vps_append(§_vps,
+ yasm_vp_create(yasm__xstrdup(sectname), NULL));
+ comment = coff_objfmt_section_switch(objfmt, §_vps, NULL, line);
+ yasm_vps_delete(§_vps);
+
+ /* To match GAS output, if the comment section is empty, put an
+ * initial 0 byte in the section.
+ */
+ if (yasm_section_bcs_first(comment)
+ == yasm_section_bcs_last(comment)) {
+ yasm_dvs_initialize(&dvs);
+ yasm_dvs_append(&dvs, yasm_dv_create_expr(
+ yasm_expr_create_ident(
+ yasm_expr_int(yasm_intnum_create_uint(0)), line)));
+ yasm_section_bcs_append(comment,
+ yasm_bc_create_data(&dvs, 1, 0, objfmt_coff->arch, line));
+ }
+
+ yasm_dvs_initialize(&dvs);
+ do {
+ yasm_dvs_append(&dvs, yasm_dv_create_string(vp->val,
+ strlen(vp->val)));
+ vp->val = NULL;
+ } while ((vp = yasm_vps_next(vp)));
+
+ yasm_section_bcs_append(comment,
+ yasm_bc_create_data(&dvs, 1, 1, objfmt_coff->arch, line));
} else
return 1;
}
line);
elf_objfmt_symtab_append(objfmt_elf, sym, SHN_UNDEF, STB_WEAK,
0, STV_DEFAULT, NULL, NULL);
+ } else if (yasm__strcasecmp(name, "ident") == 0) {
+ yasm_valparamhead sect_vps;
+ yasm_datavalhead dvs;
+ yasm_section *comment;
+
+ /* Put ident data into .comment section */
+ yasm_vps_initialize(§_vps);
+ yasm_vps_append(§_vps,
+ yasm_vp_create(yasm__xstrdup(".comment"), NULL));
+ comment = elf_objfmt_section_switch(objfmt, §_vps, NULL, line);
+ yasm_vps_delete(§_vps);
+
+ /* To match GAS output, if the comment section is empty, put an
+ * initial 0 byte in the section.
+ */
+ if (yasm_section_bcs_first(comment)
+ == yasm_section_bcs_last(comment)) {
+ yasm_dvs_initialize(&dvs);
+ yasm_dvs_append(&dvs, yasm_dv_create_expr(
+ yasm_expr_create_ident(
+ yasm_expr_int(yasm_intnum_create_uint(0)), line)));
+ yasm_section_bcs_append(comment,
+ yasm_bc_create_data(&dvs, 1, 0, objfmt_elf->arch, line));
+ }
+
+ yasm_dvs_initialize(&dvs);
+ do {
+ yasm_dvs_append(&dvs, yasm_dv_create_string(vp->val,
+ strlen(vp->val)));
+ vp->val = NULL;
+ } while ((vp = yasm_vps_next(vp)));
+
+ yasm_section_bcs_append(comment,
+ yasm_bc_create_data(&dvs, 1, 1, objfmt_elf->arch, line));
} else
return 1; /* unrecognized */
%type <ea> memaddr
%type <exp> expr regmemexpr
%type <sym> explabel
-%type <valparams> dirvals dirvals2
+%type <valparams> dirvals dirvals2 dirstrvals dirstrvals2
%type <datavals> strvals datavals strvals2 datavals2
%type <insn_operands> operands
%type <insn_operand> operand
$$ = NULL;
}
/* Other directives */
- | DIR_IDENT strvals {
- /* Put text into .comment section. */
- /*@dependent@*/ yasm_section *comment =
- gas_get_section(parser_gas, yasm__xstrdup(".comment"), NULL, NULL,
- NULL, 1);
- if (comment) {
- /* To match GAS output, if the comment section is empty, put an
- * initial 0 byte in the section.
- */
- if (yasm_section_bcs_first(comment)
- == yasm_section_bcs_last(comment)) {
- yasm_datavalhead dvs;
-
- yasm_dvs_initialize(&dvs);
- yasm_dvs_append(&dvs, yasm_dv_create_expr(
- p_expr_new_ident(yasm_expr_int(
- yasm_intnum_create_uint(0)))));
- yasm_section_bcs_append(comment,
- yasm_bc_create_data(&dvs, 1, 0, parser_gas->arch,
- cur_line));
- }
- yasm_section_bcs_append(comment,
- yasm_bc_create_data(&$2, 1, 1, parser_gas->arch, cur_line));
- }
+ | DIR_IDENT dirstrvals {
+ yasm_objfmt_directive(parser_gas->objfmt, "ident", &$2, NULL,
+ cur_line);
+ yasm_vps_delete(&$2);
$$ = NULL;
}
| DIR_FILE INTNUM STRING {
}
;
+dirstrvals: /* empty */ { yasm_vps_initialize(&$$); }
+ | dirstrvals2
+;
+
+dirstrvals2: STRING {
+ yasm_valparam *vp = yasm_vp_create($1.contents, NULL);
+ yasm_vps_initialize(&$$);
+ yasm_vps_append(&$$, vp);
+ }
+ | dirstrvals2 ',' STRING {
+ yasm_valparam *vp = yasm_vp_create($3.contents, NULL);
+ yasm_vps_append(&$1, vp);
+ $$ = $1;
+ }
+;
+
strvals: /* empty */ { yasm_dvs_initialize(&$$); }
| strvals2
;