# HG changeset patch # User William Astle # Date 1344719938 21600 # Node ID e3741cf53e008a18ff8080b29fcc64ffb0abf89c # Parent d389adbcc4ab2300fa4b9512de168d0b8b730c6e Fix error messages related to undefined symbols in lwlink Make lwlink not complain about seciton base and length symbols. Also silence duplicate complaints about undefined symbols. There is no need to complain about undefined symbols during the file/section resolution stage! If they are truly undefined, they'll still be undefined at the reference resolution stage. diff -r d389adbcc4ab -r e3741cf53e00 lwlink/link.c --- a/lwlink/link.c Fri Aug 10 23:47:56 2012 -0600 +++ b/lwlink/link.c Sat Aug 11 15:18:58 2012 -0600 @@ -38,6 +38,8 @@ static int nforced = 0; static int resolveonly = 0; +int quietsym = 1; + symlist_t *symlist = NULL; void check_section_name(char *name, int *base, fileinfo_t *fn) @@ -226,10 +228,8 @@ char sym[256]; int len; symlist_t *se; -fprintf(stderr, "Generating symbols\n"); for (sn = 0; sn < nsects; sn++) { - fprintf(stderr, "Section %s (%s)\n", sectlist[sn].ptr -> name, lastsect); if (!lastsect || strcmp(lastsect, (char *)(sectlist[sn].ptr -> name))) { if (lastsect && linkscript.lensympat) @@ -399,8 +399,11 @@ } } // not found - symerr = 1; - fprintf(stderr, "Local symbol %s not found in %s:%s\n", sanitize_symbol(sym), sect -> file -> filename, sect -> name); + if (!quietsym) + { + symerr = 1; + fprintf(stderr, "Local symbol %s not found in %s:%s\n", sanitize_symbol(sym), sect -> file -> filename, sect -> name); + } goto outerr; } else @@ -437,15 +440,18 @@ if (s) return s; } - if (sect) + if (!quietsym) { - fprintf(stderr, "External symbol %s not found in %s:%s\n", sanitize_symbol(sym), sect -> file -> filename, sect -> name); + if (sect) + { + fprintf(stderr, "External symbol %s not found in %s:%s\n", sanitize_symbol(sym), sect -> file -> filename, sect -> name); + } + else + { + fprintf(stderr, "External symbol %s not found\n", sym); + } + symerr = 1; } - else - { - fprintf(stderr, "External symbol %s not found\n", sym); - } - symerr = 1; goto outerr; } fprintf(stderr, "Shouldn't ever get here!!!\n"); @@ -466,6 +472,8 @@ reloc_t *rl; int rval; + quietsym = 0; + // resolve entry point if required // this must resolve to an *exported* symbol and will resolve to the // first instance of that symbol @@ -476,8 +484,8 @@ s = resolve_sym(linkscript.execsym, 0, NULL); if (!s) { - fprintf(stderr, "Cannot resolve exec address '%s'\n", linkscript.execsym); - symerr = 1; + fprintf(stderr, "Cannot resolve exec address '%s'\n", linkscript.execsym); + symerr = 1; } else { @@ -496,8 +504,8 @@ // is it constant? error out if not if (rval != 0 || !lw_expr_is_constant(rl -> expr)) { - fprintf(stderr, "Incomplete reference at %s:%s+%02X\n", sectlist[sn].ptr -> file -> filename, sectlist[sn].ptr -> name, rl -> offset); - symerr = 1; + fprintf(stderr, "Incomplete reference at %s:%s+%02X\n", sectlist[sn].ptr -> file -> filename, sectlist[sn].ptr -> name, rl -> offset); + symerr = 1; } else { @@ -544,11 +552,12 @@ rval = lw_expr_reval(te, resolve_sym, &(fn -> sections[sn])); // is it constant? error out if not - if (rval != 0 || !lw_expr_is_constant(te)) - { - fprintf(stderr, "Incomplete reference at %s:%s+%02X\n", fn -> filename, fn -> sections[sn].name, rl -> offset); - symerr = 1; - } + // incompletes will error out during resolve_references() + //if (rval != 0 || !lw_expr_is_constant(te)) + //{ + // fprintf(stderr, "Incomplete reference at %s:%s+%02X\n", fn -> filename, fn -> sections[sn].name, rl -> offset); + // symerr = 1; + //} lw_expr_stack_free(te); } }