Commit 5e6bd29c authored by Russ Cox's avatar Russ Cox

liblink: require DATA lines to be ordered by offset, with no overlap

The assembler could give a better error, but this one
is good enough for now.

Fixes #8880.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/153610043
parent 4f80b50e
......@@ -373,6 +373,7 @@ struct Link
char* trimpath;
char* goroot;
char* goroot_final;
int32 enforce_data_order; // for use by assembler
// hash table of all symbols
LSym* hash[LINKHASH];
......@@ -542,6 +543,7 @@ vlong adduint8(Link *ctxt, LSym *s, uint8 v);
vlong adduintxx(Link *ctxt, LSym *s, uint64 v, int wid);
void mangle(char *file);
void savedata(Link *ctxt, LSym *s, Prog *p, char *pn);
void savedata1(Link *ctxt, LSym *s, Prog *p, char *pn, int enforce_order);
vlong setaddr(Link *ctxt, LSym *s, vlong off, LSym *t);
vlong setaddrplus(Link *ctxt, LSym *s, vlong off, LSym *t, vlong add);
vlong setuint16(Link *ctxt, LSym *s, vlong r, uint16 v);
......
......@@ -85,6 +85,7 @@ main(int argc, char *argv[])
ctxt = linknew(&linkarm);
ctxt->diag = yyerror;
ctxt->bso = &bstdout;
ctxt->enforce_data_order = 1;
Binit(&bstdout, 1, OWRITE);
listinit5();
fmtinstall('L', Lconv);
......
......@@ -101,6 +101,7 @@ main(int argc, char *argv[])
ctxt = linknew(thelinkarch);
ctxt->diag = yyerror;
ctxt->bso = &bstdout;
ctxt->enforce_data_order = 1;
Binit(&bstdout, 1, OWRITE);
listinit6();
fmtinstall('L', Lconv);
......
......@@ -90,6 +90,7 @@ main(int argc, char *argv[])
ctxt = linknew(&link386);
ctxt->diag = yyerror;
ctxt->bso = &bstdout;
ctxt->enforce_data_order = 1;
Binit(&bstdout, 1, OWRITE);
listinit8();
fmtinstall('L', Lconv);
......
......@@ -83,6 +83,8 @@ savedata(Link *ctxt, LSym *s, Prog *p, char *pn)
siz = ctxt->arch->datasize(p);
if(off < 0 || siz < 0 || off >= 1<<30 || siz >= 100)
mangle(pn);
if(ctxt->enforce_data_order && off < s->np)
ctxt->diag("data out of order (already have %d)\n%P", p);
symgrow(ctxt, s, off+siz);
if(p->to.type == ctxt->arch->D_FCONST) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment