aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin (Intel) <hpa@zytor.com>2020-06-26 14:10:54 -0700
committerH. Peter Anvin (Intel) <hpa@zytor.com>2020-06-26 14:10:54 -0700
commit241697306cf0e9ee87aac4f7fe0946f436db7bfa (patch)
tree4d519608a8f67131608aed1489b370d830c307b1
parent922afbfc6ce937ecfc90ab772377b497242554f0 (diff)
downloadnasm-241697306cf0e9ee87aac4f7fe0946f436db7bfa.tar.gz
nasm-241697306cf0e9ee87aac4f7fe0946f436db7bfa.tar.xz
nasm-241697306cf0e9ee87aac4f7fe0946f436db7bfa.zip
BR 3392650: Codeview truncates symbol table length to 16 bits
If the source code is large, it is very reasonable for the symbol table length to exceed 2^16 bits. Use uint32_t to keep track of lengths, even where not necessary... there is no real reason to use uint16_t anywhere. Reported-by: <michael@mehlich.com> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
-rw-r--r--output/codeview.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/output/codeview.c b/output/codeview.c
index 979178aa..be3fd27a 100644
--- a/output/codeview.c
+++ b/output/codeview.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
- * Copyright 1996-2017 The NASM Authors - All Rights Reserved
+ * Copyright 1996-2020 The NASM Authors - All Rights Reserved
* See the file AUTHORS included with the NASM distribution for
* the specific copyright holders.
*
@@ -609,9 +609,9 @@ static void write_linenumber_table(struct coff_Section *const sect)
}
}
-static uint16_t write_symbolinfo_obj(struct coff_Section *sect)
+static uint32_t write_symbolinfo_obj(struct coff_Section *sect)
{
- uint16_t obj_len;
+ uint32_t obj_len;
obj_len = 2 + 4 + cv8_state.outfile.namebytes;
@@ -623,11 +623,11 @@ static uint16_t write_symbolinfo_obj(struct coff_Section *sect)
return obj_len;
}
-static uint16_t write_symbolinfo_properties(struct coff_Section *sect,
+static uint32_t write_symbolinfo_properties(struct coff_Section *sect,
const char *const creator_str)
{
/* https://github.com/Microsoft/microsoft-pdb/blob/1d60e041/include/cvinfo.h#L3313 */
- uint16_t creator_len;
+ uint32_t creator_len;
creator_len = 2 + 4 + 2 + 3*2 + 3*2 + strlen(creator_str)+1 + 2;
@@ -671,9 +671,9 @@ static uint16_t write_symbolinfo_properties(struct coff_Section *sect,
return creator_len;
}
-static uint16_t write_symbolinfo_symbols(struct coff_Section *sect)
+static uint32_t write_symbolinfo_symbols(struct coff_Section *sect)
{
- uint16_t len = 0, field_len;
+ uint32_t len = 0, field_len;
uint32_t field_base;
struct cv8_symbol *sym;
@@ -727,7 +727,7 @@ static uint16_t write_symbolinfo_symbols(struct coff_Section *sect)
static void write_symbolinfo_table(struct coff_Section *const sect)
{
static const char creator_str[] = "The Netwide Assembler " NASM_VER;
- uint16_t obj_length, creator_length, sym_length;
+ uint32_t obj_length, creator_length, sym_length;
uint32_t field_length = 0, out_len;
nasm_assert(cv8_state.outfile.namebytes);
@@ -791,7 +791,7 @@ static void build_symbol_table(struct coff_Section *const sect)
static void build_type_table(struct coff_Section *const sect)
{
- uint16_t field_len;
+ uint32_t field_len;
uint32_t typeindex = 0x1000;
uint32_t idx_arglist;