summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2013-09-10 14:54:55 -0400
committerRuss Cox <rsc@golang.org>2013-09-10 14:54:55 -0400
commitf2bf3601385374aa375aca59b1278d3d9b750b5c (patch)
tree674b073a5591d65df58fb1b4767c62526ff1a225
parentfd19b8850fdc7022e1f7d00afbaabf980b205a8b (diff)
downloadgo-f2bf3601385374aa375aca59b1278d3d9b750b5c.tar.gz
build: more "undefined behavior" fixes
Fixes issue 5764. R=golang-dev, bradfitz CC=golang-dev https://codereview.appspot.com/13441051
-rw-r--r--src/cmd/6g/gsubr.c2
-rw-r--r--src/cmd/6l/obj.c2
-rw-r--r--src/cmd/6l/span.c2
-rw-r--r--src/libbio/bgetc.c2
4 files changed, 5 insertions, 3 deletions
diff --git a/src/cmd/6g/gsubr.c b/src/cmd/6g/gsubr.c
index 0e45cc0eb..e68a0899e 100644
--- a/src/cmd/6g/gsubr.c
+++ b/src/cmd/6g/gsubr.c
@@ -540,7 +540,7 @@ ginscon(int as, vlong c, Node *n2)
nodconst(&n1, types[TINT64], c);
- if(as != AMOVQ && (c < -1LL<<31 || c >= 1LL<<31)) {
+ if(as != AMOVQ && (c < -(1LL<<31) || c >= 1LL<<31)) {
// cannot have 64-bit immediokate in ADD, etc.
// instead, MOV into register first.
regalloc(&ntmp, types[TINT64], N);
diff --git a/src/cmd/6l/obj.c b/src/cmd/6l/obj.c
index 12ca0f635..a12b6e6f9 100644
--- a/src/cmd/6l/obj.c
+++ b/src/cmd/6l/obj.c
@@ -346,7 +346,7 @@ zaddr(char *pn, Biobuf *f, Adr *a, Sym *h[])
a->offset = BGETLE4(f);
if(t & T_64) {
a->offset &= 0xFFFFFFFFULL;
- a->offset |= (vlong)BGETLE4(f) << 32;
+ a->offset |= (uvlong)BGETLE4(f) << 32;
}
}
a->sym = S;
diff --git a/src/cmd/6l/span.c b/src/cmd/6l/span.c
index 9fad0eed0..74f11d635 100644
--- a/src/cmd/6l/span.c
+++ b/src/cmd/6l/span.c
@@ -1237,6 +1237,8 @@ found:
break;
}
+ if(z >= nelem(o->op))
+ sysfatal("asmins bad table %P", p);
op = o->op[z];
if(op == 0x0f) {
*andptr++ = op;
diff --git a/src/libbio/bgetc.c b/src/libbio/bgetc.c
index f3db0f302..3399fb16b 100644
--- a/src/libbio/bgetc.c
+++ b/src/libbio/bgetc.c
@@ -83,7 +83,7 @@ Bgetle4(Biobuf *bp)
l = Bgetle2(bp);
h = Bgetle2(bp);
- return l|(h<<16);
+ return l|((uint32)h<<16);
}
int