From: Rob Pike Date: Thu, 2 May 2013 00:00:21 +0000 (-0700) Subject: cmd/ld: fix another unsigned value causing bugs on Plan 9 X-Git-Tag: go1.1rc2~18 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d727d147c0c724e9d6489db86925dc61a5ddfd91;p=gostls13.git cmd/ld: fix another unsigned value causing bugs on Plan 9 "The usual conversions" bite again. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/9103044 --- diff --git a/src/cmd/ld/data.c b/src/cmd/ld/data.c index 37ad2f8c87..23fc23e5fc 100644 --- a/src/cmd/ld/data.c +++ b/src/cmd/ld/data.c @@ -247,7 +247,13 @@ relocsym(Sym *s) o = 0; if(r->sym) o += symaddr(r->sym); - o += r->add - (s->value + r->off + r->siz); + // NOTE: The (int32) cast on the next line works around a bug in Plan 9's 8c + // compiler. The expression s->value + r->off + r->siz is int32 + int32 + + // uchar, and Plan 9 8c incorrectly treats the expression as type uint32 + // instead of int32, causing incorrect values when sign extended for adding + // to o. The bug only occurs on Plan 9, because this C program is compiled by + // the standard host compiler (gcc on most other systems). + o += r->add - (s->value + r->off + (int32)r->siz); break; case D_SIZE: o = r->sym->size + r->add;