Once these changes are effected, it is possible to construct
"8l" native on a (386?) Plan 9 system, albeit with assistance
from modules such as mkfiles that are not (yet) included in any
public patches.
8l/asm.c:
. Corrected some format qualifiers.
8l/list.c:
. Cast a print() argument to (int) to match the given format.
It may be possible to change the format (%R), but I have not
looked into it.
8l/obj.c:
. Removed some unused code.
8l/span.c:
. Removed unnecessary incrementation on "bp".
. Corrected some format qualifiers.
ld/data.c:
. Corrected some format qualifiers.
. Cast print argument to (int): used as field size.
. Use braces to suppress warning about empty if() statements.
ld/dwarf.c:
. Trivial spelling mistake in comment.
ld/ldelf.c:
. Added USED() statements to silence warnings.
. Dropped redundant address (&) operators.
. corrected some format qualifiers.
. Cast to (int) for switch selection variable.
ld/macho.c:
. Added USED() statements to silence warnings.
ld/ldpe.c:
. Added USED() statements to silence warnings.
. More careful use of "sect" variable.
. Corrected some format qualifiers.
. Removed redundant assignments.
. Minor fix dropped as it was submitted separately.
ld/pe.c:
. Dropped <time.h> which is now in <u.h>.
. Dropped redundant address (&) operators.
. Added a missing variable initialisation.
ld/symtab.c:
. Added USED() statements to silence warnings.
. Removed redundant incrementation.
. Corrected some format qualifiers.
All the above have been tested against a (very) recent release
and do not seem to trigger any regressions.
All review suggestions have been incorporated.
R=rsc
CC=golang-dev
https://golang.org/cl/
4633043
put(nil, a->asym->name, 'p', a->aoffset, 0, 0, a->gotype);
}
if(debug['v'] || debug['n'])
- Bprint(&bso, "symsize = %uld\n", symsize);
+ Bprint(&bso, "symsize = %d\n", symsize);
Bflush(&bso);
}
}
brk:
if(a->index != D_NONE) {
- sprint(s, "(%R*%d)", a->index, a->scale);
+ sprint(s, "(%R*%d)", (int)a->index, a->scale);
strcat(str, s);
}
conv:
s = lookup(x, r);
if(x != name)
free(x);
- name = nil;
if(debug['S'] && r == 0)
sig = 1729;
lastp = p;
goto loop;
}
- goto loop;
eof:
diag("truncated object file: %s", pn);
autoffset = 0;
q = P;
- q1 = P;
if(pmorestack != P)
if(!(p->from.scale & NOSPLIT)) {
p = appendp(p); // load g into CX
*bp++ = v;
*bp++ = v>>8;
*bp++ = v>>16;
- *bp++ = v>>24;
+ *bp = v>>24;
}
}
p->comefrom = P;
andptr = and;
doasm(p);
if(andptr > and+sizeof and) {
- print("and[] is too short - %d byte instruction\n", andptr - and);
+ print("and[] is too short - %ld byte instruction\n", andptr - and);
errorexit();
}
}
q = sym->p;
while(n >= 16) {
- Bprint(&bso, "%.6ux\t%-20.16I\n", addr, q);
+ Bprint(&bso, "%.6ux\t%-20.16I\n", addr, q);
addr += 16;
q += 16;
n -= 16;
}
if(n > 0)
- Bprint(&bso, "%.6ux\t%-20.*I\n", addr, n, q);
+ Bprint(&bso, "%.6ux\t%-20.*I\n", addr, (int)n, q);
addr += n;
continue;
}
Bprint(&bso, "%.6ux\t", p->pc);
q = sym->p + p->pc - sym->value;
n = epc - p->pc;
- Bprint(&bso, "%-20.*I | %P\n", n, q, p);
+ Bprint(&bso, "%-20.*I | %P\n", (int)n, q, p);
addr += n;
}
}
Bprint(&bso, "%-20s %.8ux| 00 ...\n", "(pre-pad)", addr);
addr = sym->value;
}
- Bprint(&bso, "%-20s %.8ux|", sym->name, addr);
+ Bprint(&bso, "%-20s %.8ux|", sym->name, (uint)addr);
p = sym->p;
ep = p + sym->np;
while(p < ep)
}
if(addr < eaddr)
- Bprint(&bso, "%-20s %.8ux| 00 ...\n", "(post-pad)", addr);
- Bprint(&bso, "%-20s %.8ux|\n", "", eaddr);
+ Bprint(&bso, "%-20s %.8ux| 00 ...\n", "(post-pad)", (uint)addr);
+ Bprint(&bso, "%-20s %.8ux|\n", "", (uint)eaddr);
}
void
t = rnd(t, PtrSize);
else if(t > 2)
t = rnd(t, 4);
- if(t & 1)
+ if(t & 1) {
;
- else if(t & 2)
+ } else if(t & 2)
datsize = rnd(datsize, 2);
else if(t & 4)
datsize = rnd(datsize, 4);
t = rnd(t, PtrSize);
else if(t > 2)
t = rnd(t, 4);
- if(t & 1)
+ if(t & 1) {
;
- else if(t & 2)
+ } else if(t & 2)
datsize = rnd(datsize, 2);
else if(t & 4)
datsize = rnd(datsize, 4);
seek(cout, unitstart, 0);
LPUT(here - unitstart - sizeof(int32)); // unit_length
WPUT(3); // dwarf version
- LPUT(header_length); // header lenght starting here
+ LPUT(header_length); // header length starting here
cflush();
seek(cout, here, 0);
}
Reloc *r, *rp;
Sym *s;
+ USED(pkg);
if(debug['v'])
Bprint(&bso, "%5.2f ldelf %s\n", cputime(), pn);
version++;
base = Boffset(f);
- if(Bread(f, &hdrbuf, sizeof hdrbuf) != sizeof hdrbuf)
+ if(Bread(f, hdrbuf, sizeof hdrbuf) != sizeof hdrbuf)
goto bad;
- hdr = (ElfHdrBytes*)&hdrbuf;
+ hdr = (ElfHdrBytes*)hdrbuf;
if(memcmp(hdr->ident, ElfMagic, 4) != 0)
goto bad;
switch(hdr->ident[5]) {
name = smprint("%s(%s)", pn, sect->name);
s = lookup(name, version);
free(name);
- switch(sect->flags&(ElfSectFlagAlloc|ElfSectFlagWrite|ElfSectFlagExec)) {
+ switch((int)sect->flags&(ElfSectFlagAlloc|ElfSectFlagWrite|ElfSectFlagExec)) {
default:
werrstr("unexpected flags for ELF section %s", sect->name);
goto bad;
Reloc *r, *rp;
char *name;
+ USED(pkg);
version++;
base = Boffset(f);
if(Bread(f, hdr, sizeof hdr) != sizeof hdr)
Sym *s;
Reloc *r, *rp;
PeSym *sym;
-
+
+ USED(len);
+ USED(pkg);
if(debug['v'])
Bprint(&bso, "%5.2f ldpe %s\n", cputime(), pn);
+ sect = nil;
version++;
base = Boffset(f);
diag("%s: %s sectnum <0!", pn, s->name, sym->sectnum);
}
+ if(sect == nil)
+ return;
s->sub = sect->sym->sub;
sect->sym->sub = s;
s->type = sect->sym->type | SSUB;
sym = &obj->pesym[i];
*y = sym;
- s = nil;
name = sym->name;
if(sym->sclass == IMAGE_SYM_CLASS_STATIC && sym->value == 0) // section
if(s != nil && s->type == 0 && !(sym->sclass == IMAGE_SYM_CLASS_STATIC && sym->value == 0))
s->type = SXREF;
- if(strncmp(sym->name, "__imp__", 6) == 0)
+ if(strncmp(sym->name, "__imp__", 7) == 0)
s->got = -2; // flag for __imp__
sym->sym = s;
// PE (Portable Executable) file writing
// http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx
-#include <time.h>
-
#include "l.h"
#include "../ld/lib.h"
#include "../ld/pe.h"
ewrite(cout, &oh64, sizeof oh64);
else
ewrite(cout, &oh, sizeof oh);
- ewrite(cout, &sh, nsect * sizeof sh[0]);
+ ewrite(cout, sh, nsect * sizeof sh[0]);
}
static void
Sym *s, *dynamic;
dr = nil;
-
+ m = nil;
for(s = allsym; s != S; s = s->allsym) {
if(!s->reachable || !s->dynimpname || s->dynexport)
continue;
{
int bind, type, shndx, off;
+ USED(go);
switch(t) {
default:
return;
{
int i;
+ USED(go);
+ USED(ver);
+ USED(size);
+ USED(x);
switch(t) {
case 'T':
case 'L':
int i, f, l;
Reloc *rel;
+ USED(size);
if(t == 'f')
name++;
l = 4;
}
scput(0);
scput(0);
- i++;
}
else {
for(i=0; name[i]; i++)
return;
}
if(ver)
- Bprint(&bso, "%c %.8llux %s<%d> %s\n", t, v, s, ver, typ ? typ->name : "");
+ Bprint(&bso, "%c %.8llux %s<%d> %s\n", t, v, s->name, ver, typ ? typ->name : "");
else
- Bprint(&bso, "%c %.8llux %s %s\n", t, v, s, typ ? typ->name : "");
+ Bprint(&bso, "%c %.8llux %s %s\n", t, v, s->name, typ ? typ->name : "");
}
}