cmd/9l: fix bogus C conversion

Looks like c2go and gcc disagree about the exact meaning of the
usual arithmetic conversions, in a way that broke 9l's archreloc.
Fix it.

It's very hard for me to see why the original C code did not say
what c2go interpreted it to say, but apparently it did not.
This is why Go has explicit numerical conversions.

Change-Id: I75bd73afd1fa4ce9a53c887e1bd7d1e26ff43ae4
Reviewed-on: https://go-review.googlesource.com/6405
Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
Russ Cox 2015-03-01 13:32:49 -05:00
parent 621d75999f
commit 2fb88eceb3
2 changed files with 18 additions and 13 deletions

View file

@ -479,7 +479,7 @@ func relocsym(s *LSym) {
// Instead of special casing only amd64, we treat this as an error on all
// 64-bit architectures so as to be future-proof.
if int32(o) < 0 && Thearch.Ptrsize > 4 && siz == 4 {
Diag("non-pc-relative relocation address is too big: %#x", uint64(o))
Diag("non-pc-relative relocation address is too big: %#x (%#x + %#x)", uint64(o), Symaddr(r.Sym), r.Add)
Errorexit()
}
@ -546,7 +546,13 @@ func relocsym(s *LSym) {
o = Thearch.Archrelocvariant(r, s, o)
}
//print("relocate %s %#llux (%#llux+%#llux, size %d) => %s %#llux +%#llx [%llx]\n", s->name, (uvlong)(s->value+off), (uvlong)s->value, (uvlong)r->off, r->siz, r->sym ? r->sym->name : "<nil>", (uvlong)symaddr(r->sym), (vlong)r->add, (vlong)o);
if false {
nam := "<nil>"
if r.Sym != nil {
nam = r.Sym.Name
}
fmt.Printf("relocate %s %#x (%#x+%#x, size %d) => %s %#x +%#x [type %d/%d, %x]\n", s.Name, s.Value+int64(off), s.Value, r.Off, r.Siz, nam, Symaddr(r.Sym), r.Add, r.Type, r.Variant, o)
}
switch siz {
default:
Ctxt.Cursym = s