Minor fixes needed to compile with MSVC++ 2005

Minor fixes to make it possible to compile with MS Visual C++ 2005.
Unfortunately, MSVC++ is not fully C99 compliant; in particular, it
doesn't handle interspersed declarations and other code.  Furthermore,
it chokes on some expressions in outelf64.c, which fortunately can be
easily substituted with simpler expressions.
This commit is contained in:
H. Peter Anvin 2007-09-16 22:14:50 -07:00
parent 9e8e948f86
commit 21d6be423f
5 changed files with 25 additions and 23 deletions

View File

@ -206,7 +206,6 @@ static struct Section *create_section(char *name)
static void bin_cleanup(int debuginfo)
{
(void)debuginfo; /* placate optimizers */
struct Section *g, **gp;
struct Section *gs = NULL, **gsp;
struct Section *s, **sp;
@ -217,6 +216,8 @@ static void bin_cleanup(int debuginfo)
uint64_t pend;
int h;
(void)debuginfo; /* placate optimizers */
#ifdef DEBUG
fprintf(stdout,
"bin_cleanup: Sections were initially referenced in this order:\n");

View File

@ -203,8 +203,8 @@ void stabs32_deflabel(char *, int32_t, int32_t, int, char *);
void stabs32_directive(const char *, const char *);
void stabs32_typevalue(int32_t);
void stabs32_output(int, void *);
void stabs32_generate();
void stabs32_cleanup();
void stabs32_generate(void);
void stabs32_cleanup(void);
/* end of stabs debugging stuff */
@ -1256,10 +1256,10 @@ static int32_t elf_segbase(int32_t segment)
static int elf_directive(char *directive, char *value, int pass)
{
(void)directive;
(void)value;
(void)pass;
return 0;
(void)directive;
(void)value;
(void)pass;
return 0;
}
static void elf_filename(char *inname, char *outname, efunc error)
@ -1344,6 +1344,7 @@ void stabs32_init(struct ofmt *of, void *id, FILE * fp, efunc error)
void stabs32_linenum(const char *filename, int32_t linenumber, int32_t segto)
{
(void)segto;
if (!stabs_filename) {
stabs_filename = (char *)nasm_malloc(strlen(filename) + 1);
strcpy(stabs_filename, filename);
@ -1555,7 +1556,7 @@ void stabs32_generate(void)
stabstrbuf = ssbuf;
}
void stabs32_cleanup()
void stabs32_cleanup(void)
{
struct linelist *ptr, *del;
if (!stabslines)

View File

@ -215,8 +215,8 @@ void stabs64_deflabel(char *, int32_t, int32_t, int, char *);
void stabs64_directive(const char *, const char *);
void stabs64_typevalue(int32_t);
void stabs64_output(int, void *);
void stabs64_generate();
void stabs64_cleanup();
void stabs64_generate(void);
void stabs64_cleanup(void);
/* end of stabs debugging stuff */
@ -1291,7 +1291,7 @@ static int elf_directive(char *directive, char *value, int pass)
(void)directive;
(void)value;
(void)pass;
return 0;
return 0;
}
static void elf_filename(char *inname, char *outname, efunc error)
@ -1525,7 +1525,8 @@ void stabs64_generate(void)
/* member must be adjusted by adding 3 */
WRITEDLONG(rptr, (int64_t)(sptr - sbuf) - 4);
WRITEDLONG(rptr, ((int64_t)(ptr->info.section + 3) << 32) | R_X86_64_32);
WRITELONG(rptr, R_X86_64_32);
WRITELONG(rptr, ptr->info.section + 3);
numstabs++;
currfile = mainfileindex;
@ -1545,7 +1546,8 @@ void stabs64_generate(void)
/* relocation table entry */
WRITEDLONG(rptr, (int64_t)(sptr - sbuf) - 4);
WRITEDLONG(rptr, ((int64_t)(ptr->info.section + 3) << 32) | R_X86_64_32);
WRITELONG(rptr, R_X86_64_32);
WRITELONG(rptr, ptr->info.section + 3);
}
WRITE_STAB(sptr, 0, N_SLINE, 0, ptr->line, ptr->info.offset);
@ -1554,7 +1556,8 @@ void stabs64_generate(void)
/* relocation table entry */
WRITEDLONG(rptr, (int64_t)(sptr - sbuf) - 4);
WRITEDLONG(rptr, ((int64_t)(ptr->info.section + 3) << 32) | R_X86_64_32);
WRITELONG(rptr, R_X86_64_32);
WRITELONG(rptr, ptr->info.section + 3);
ptr = ptr->next;

View File

@ -522,14 +522,13 @@ static void macho_output(int32_t secto, const void *data, uint32_t type,
static int32_t macho_section(char *name, int pass, int *bits)
{
(void)pass;
int32_t index, originalIndex;
char *sectionAttributes;
struct sectmap *sm;
struct section *s;
(void)pass;
/* Default to 32 bits. */
if (!name) {
*bits = 32;

View File

@ -84,14 +84,13 @@ static int32_t headerlength;
static void rdf2_init(FILE * fp, efunc errfunc, ldfunc ldef, evalfunc eval)
{
int segtext, segdata, segbss;
(void)ldef;
(void)eval;
maxbits = 64;
int segtext, segdata, segbss;
/* set up the initial segments */
segments[0].segname = ".text";
segments[0].segnumber = 0;
@ -135,14 +134,13 @@ static void rdf2_init(FILE * fp, efunc errfunc, ldfunc ldef, evalfunc eval)
static int32_t rdf2_section_names(char *name, int pass, int *bits)
{
(void)pass;
int i;
char *p, *q;
int code = -1;
int reserved = 0;
(void)pass;
/*
* Default is 32 bits, in the text segment.
*/