From: Peter Johnson Date: Sat, 1 Apr 2006 09:09:53 +0000 (-0000) Subject: * coff-objfmt.c (coff_objfmt_section_switch): Fix up handling of GAS flags X-Git-Tag: v0.5.0rc2~2^2~21 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=227731f235a3693547ccb63a4b4d5040836fb5cc;p=yasm * coff-objfmt.c (coff_objfmt_section_switch): Fix up handling of GAS flags a bit; add support for .rodata and .debug sections. * dwarf2-line.c (yasm_dwarf2__generate_line): Set alignment for .debug_line explicitly to 1 rather than leaving it implicit. Fix up testcases to match. svn path=/trunk/yasm/; revision=1446 --- diff --git a/modules/dbgfmts/dwarf2/dwarf2-line.c b/modules/dbgfmts/dwarf2/dwarf2-line.c index 29dccf54..6601d191 100644 --- a/modules/dbgfmts/dwarf2/dwarf2-line.c +++ b/modules/dbgfmts/dwarf2/dwarf2-line.c @@ -633,9 +633,8 @@ yasm_dwarf2__generate_line(yasm_dbgfmt_dwarf2 *dbgfmt_dwarf2, int asm_source, info.asm_source = asm_source; info.dbgfmt_dwarf2 = dbgfmt_dwarf2; info.debug_line = yasm_object_get_general(dbgfmt_dwarf2->object, - ".debug_line", 0, 4, 0, 0, &new, + ".debug_line", 0, 1, 0, 0, &new, 0); - yasm_section_set_align(info.debug_line, 0, 0); last = yasm_section_bcs_last(info.debug_line); /* header */ diff --git a/modules/dbgfmts/dwarf2/tests/pass32/dwarf32_testhd.hex b/modules/dbgfmts/dwarf2/tests/pass32/dwarf32_testhd.hex index edaf1bcb..765a9198 100644 --- a/modules/dbgfmts/dwarf2/tests/pass32/dwarf32_testhd.hex +++ b/modules/dbgfmts/dwarf2/tests/pass32/dwarf32_testhd.hex @@ -5526,7 +5526,7 @@ a4 00 00 00 -00 +01 00 00 00 diff --git a/modules/dbgfmts/dwarf2/tests/pass64/dwarf64_2loc.hex b/modules/dbgfmts/dwarf2/tests/pass64/dwarf64_2loc.hex index 6a6e3f4c..d41612cd 100644 --- a/modules/dbgfmts/dwarf2/tests/pass64/dwarf64_2loc.hex +++ b/modules/dbgfmts/dwarf2/tests/pass64/dwarf64_2loc.hex @@ -798,7 +798,7 @@ ec 00 00 00 -00 +01 00 00 00 diff --git a/modules/dbgfmts/dwarf2/tests/pass64/dwarf64_leb128.hex b/modules/dbgfmts/dwarf2/tests/pass64/dwarf64_leb128.hex index 5733368b..3ac0b6c9 100644 --- a/modules/dbgfmts/dwarf2/tests/pass64/dwarf64_leb128.hex +++ b/modules/dbgfmts/dwarf2/tests/pass64/dwarf64_leb128.hex @@ -89950,7 +89950,7 @@ d0 00 00 00 -00 +01 00 00 00 diff --git a/modules/dbgfmts/dwarf2/tests/passwin64/dwarfwin64_testhd.hex b/modules/dbgfmts/dwarf2/tests/passwin64/dwarfwin64_testhd.hex index b74107a2..41ed7bcb 100644 --- a/modules/dbgfmts/dwarf2/tests/passwin64/dwarfwin64_testhd.hex +++ b/modules/dbgfmts/dwarf2/tests/passwin64/dwarfwin64_testhd.hex @@ -94,10 +94,10 @@ c0 00 00 00 -20 -00 +40 00 -60 +10 +42 2f 31 38 @@ -134,10 +134,10 @@ f3 00 00 00 -20 -00 +40 00 -60 +10 +42 2f 33 30 @@ -174,10 +174,10 @@ f3 00 00 00 -20 -00 +40 00 -60 +10 +42 2f 34 32 @@ -214,10 +214,10 @@ d6 00 00 00 -20 -00 +40 00 -60 +40 +40 2f 35 37 @@ -254,10 +254,10 @@ ce 00 00 00 -20 +40 00 40 -60 +42 2f 37 30 @@ -334,10 +334,10 @@ b2 00 00 00 -20 -00 +40 00 -60 +10 +42 2f 39 31 @@ -374,10 +374,10 @@ bf 00 00 00 -20 -00 +40 00 -60 +10 +42 2f 31 30 @@ -414,10 +414,10 @@ da 00 00 00 -20 -00 +40 00 -60 +10 +42 2f 31 32 @@ -454,10 +454,10 @@ aa 00 00 00 -20 -00 +40 00 -60 +10 +42 2e 63 6f @@ -2966,12 +2966,12 @@ ff 08 90 01 -66 -66 -90 -66 -66 -90 +00 +00 +00 +00 +00 +00 2c 00 00 @@ -3014,12 +3014,12 @@ ff 20 8c 02 -66 -66 -90 -66 -66 -90 +00 +00 +00 +00 +00 +00 1c 00 00 @@ -3058,12 +3058,12 @@ ff 08 90 01 -66 -66 -90 -66 -66 -90 +00 +00 +00 +00 +00 +00 2c 00 00 @@ -3106,12 +3106,12 @@ ff 20 8c 02 -66 -66 -90 -66 -66 -90 +00 +00 +00 +00 +00 +00 20 00 00 diff --git a/modules/objfmts/coff/coff-objfmt.c b/modules/objfmts/coff/coff-objfmt.c index 609ea40d..c80309c9 100644 --- a/modules/objfmts/coff/coff-objfmt.c +++ b/modules/objfmts/coff/coff-objfmt.c @@ -1336,7 +1336,8 @@ coff_objfmt_section_switch(yasm_objfmt *objfmt, yasm_valparamhead *valparams, align = 16; } iscode = 1; - } else if (strcmp(sectname, ".rdata") == 0) { + } else if (strcmp(sectname, ".rdata") == 0 + || strncmp(sectname, ".rodata", 7) == 0) { flags = COFF_STYP_DATA; if (objfmt_coff->win32) { flags |= COFF_STYP_READ; @@ -1359,6 +1360,11 @@ coff_objfmt_section_switch(yasm_objfmt *objfmt, yasm_valparamhead *valparams, flags = COFF_STYP_INFO; if (objfmt_coff->win32) flags |= COFF_STYP_DISCARD | COFF_STYP_READ; + } else if (yasm__strncasecmp(sectname, ".debug", 6)==0) { + flags = COFF_STYP_DATA; + if (objfmt_coff->win32) + flags |= COFF_STYP_DISCARD|COFF_STYP_READ; + align = 1; } else { /* Default to code */ flags = COFF_STYP_TEXT; @@ -1424,6 +1430,7 @@ coff_objfmt_section_switch(yasm_objfmt *objfmt, yasm_valparamhead *valparams, /* GAS-style flags */ int alloc = 0, load = 0, readonly = 0, code = 0, data = 0; int shared = 0; + iscode = 0; for (i=4; ival); i++) { switch (vp->val[i]) { case 'a': @@ -1464,6 +1471,7 @@ coff_objfmt_section_switch(yasm_objfmt *objfmt, yasm_valparamhead *valparams, flags = COFF_STYP_TEXT; if (objfmt_coff->win32) flags |= COFF_STYP_EXECUTE | COFF_STYP_READ; + iscode = 1; } else if (data) { flags = COFF_STYP_DATA; if (objfmt_coff->win32) diff --git a/modules/objfmts/coff/tests/x86id.errwarn b/modules/objfmts/coff/tests/x86id.errwarn index e69de29b..b83cc295 100644 --- a/modules/objfmts/coff/tests/x86id.errwarn +++ b/modules/objfmts/coff/tests/x86id.errwarn @@ -0,0 +1,44 @@ +-:37: warning: Standard COFF does not support read-only data sections +-:6284: warning: Standard COFF does not support read-only data sections +-:6527: warning: Standard COFF does not support read-only data sections +-:6540: warning: Standard COFF does not support read-only data sections +-:6549: warning: Standard COFF does not support read-only data sections +-:6559: warning: Standard COFF does not support read-only data sections +-:6562: warning: Standard COFF does not support read-only data sections +-:6629: warning: Standard COFF does not support read-only data sections +-:7499: warning: Standard COFF does not support read-only data sections +-:7518: warning: Standard COFF does not support read-only data sections +-:7991: warning: Standard COFF does not support read-only data sections +-:9105: warning: Standard COFF does not support read-only data sections +-:9121: warning: Standard COFF does not support read-only data sections +-:9143: warning: Standard COFF does not support read-only data sections +-:9298: warning: Standard COFF does not support read-only data sections +-:9368: warning: Standard COFF does not support read-only data sections +-:9511: warning: Standard COFF does not support read-only data sections +-:9596: warning: Standard COFF does not support read-only data sections +-:9661: warning: Standard COFF does not support read-only data sections +-:9741: warning: Standard COFF does not support read-only data sections +-:9810: warning: Standard COFF does not support read-only data sections +-:9879: warning: Standard COFF does not support read-only data sections +-:9945: warning: Standard COFF does not support read-only data sections +-:10005: warning: Standard COFF does not support read-only data sections +-:10069: warning: Standard COFF does not support read-only data sections +-:10139: warning: Standard COFF does not support read-only data sections +-:10208: warning: Standard COFF does not support read-only data sections +-:10270: warning: Standard COFF does not support read-only data sections +-:10935: warning: Standard COFF does not support read-only data sections +-:11679: warning: Standard COFF does not support read-only data sections +-:11848: warning: Standard COFF does not support read-only data sections +-:12534: warning: Standard COFF does not support read-only data sections +-:14533: warning: Standard COFF does not support read-only data sections +-:15942: warning: Standard COFF does not support read-only data sections +-:18092: warning: Standard COFF does not support read-only data sections +-:18170: warning: Standard COFF does not support read-only data sections +-:18580: warning: Standard COFF does not support read-only data sections +-:19769: warning: Standard COFF does not support read-only data sections +-:19878: warning: Standard COFF does not support read-only data sections +-:21893: warning: Standard COFF does not support read-only data sections +-:24311: warning: Standard COFF does not support read-only data sections +-:24465: warning: Standard COFF does not support read-only data sections +-:25481: warning: Standard COFF does not support read-only data sections +-:25614: warning: Standard COFF does not support read-only data sections diff --git a/modules/objfmts/coff/tests/x86id.hex b/modules/objfmts/coff/tests/x86id.hex index 7339666a..ccadb768 100644 --- a/modules/objfmts/coff/tests/x86id.hex +++ b/modules/objfmts/coff/tests/x86id.hex @@ -134,7 +134,7 @@ da 07 00 00 -20 +40 00 60 00