summaryrefslogtreecommitdiff
path: root/output
diff options
context:
space:
mode:
authorH. Peter Anvin (Intel) <hpa@zytor.com>2020-06-25 13:57:44 -0700
committerH. Peter Anvin (Intel) <hpa@zytor.com>2020-06-25 13:57:44 -0700
commit45978bb8bcb4fa131a30166f664c647f7c13cd76 (patch)
treec49070c8de5f5c6e4521aad8267871be36cc93b0 /output
parent7869531f27ec415d9d38d38cadc44ebe2fc1f126 (diff)
downloadnasm-45978bb8bcb4fa131a30166f664c647f7c13cd76.tar.gz
BR 3392651: fix the .debug$T section in Codeview output format
The cv8 output format would generate an invalid .debug$T section, containing repeated invalid records, none of which are actually used (which is probably the only reason it actually worked.) Just in case, generate a *single* type record for void func(void); Furthermore, the argument list record should come before the procedure type record (forward references are at least normatively prohibited.) Reported-by: Alexandre Ganea <alexandre.ganea@ubisoft.com> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Diffstat (limited to 'output')
-rw-r--r--output/codeview.c44
1 files changed, 20 insertions, 24 deletions
diff --git a/output/codeview.c b/output/codeview.c
index 4dbc9b3a..979178aa 100644
--- a/output/codeview.c
+++ b/output/codeview.c
@@ -792,31 +792,27 @@ static void build_symbol_table(struct coff_Section *const sect)
static void build_type_table(struct coff_Section *const sect)
{
uint16_t field_len;
- struct cv8_symbol *sym;
+ uint32_t typeindex = 0x1000;
+ uint32_t idx_arglist;
section_write32(sect, 0x00000004);
- saa_rewind(cv8_state.symbols);
- while ((sym = saa_rstruct(cv8_state.symbols))) {
- if (sym->type != SYMTYPE_PROC)
- continue;
-
- /* proc leaf */
-
- field_len = 2 + 4 + 4 + 4 + 2;
- section_write16(sect, field_len);
- section_write16(sect, 0x1008); /* PROC type */
-
- section_write32(sect, 0x00000003); /* return type */
- section_write32(sect, 0); /* calling convention (default) */
- section_write32(sect, sym->typeindex);
- section_write16(sect, 0); /* # params */
-
- /* arglist */
-
- field_len = 2 + 4;
- section_write16(sect, field_len);
- section_write16(sect, 0x1201); /* ARGLIST */
- section_write32(sect, 0); /*num params */
- }
+ /* empty argument list type */
+ field_len = 2 + 4;
+ section_write16(sect, field_len);
+ section_write16(sect, 0x1201); /* ARGLIST */
+ section_write32(sect, 0); /* num params */
+ idx_arglist = typeindex++;
+
+ /* procedure type: void proc(void) */
+ field_len = 2 + 4 + 1 + 1 + 2 + 4;
+ section_write16(sect, field_len);
+ section_write16(sect, 0x1008); /* PROC type */
+
+ section_write32(sect, 0x00000003); /* return type VOID */
+ section_write8(sect, 0); /* calling convention (default) */
+ section_write8(sect, 0); /* function attributes */
+ section_write16(sect, 0); /* # params */
+ section_write32(sect, idx_arglist); /* argument list type */
+ /* idx_voidfunc = typeindex++; */
}