cmd/cgo: document //export preamble restriction

Fixes issue 3497.

R=golang-dev, iant
CC=golang-dev
https://codereview.appspot.com/7235075
cmd/cgo: fix line number annotations in generated C code

The old version was using go/ast's CommentGroup.Text method,
but that method drops leading blank lines from the result, so that
if the comment looked like one of

//
// syntax error
import "C"

/*
syntax error
*/
import "C"

then the line numbers for the syntax error would be off by the
number of leading blank lines (1 in each of the above cases).

The new text extractor preserves blank lines.

Fixes issue 4019.

R=golang-dev, iant
CC=golang-dev
https://codereview.appspot.com/7232071
cmd/go: clean cgo compiler errors

Cut out temporary cgo file in error message.
Show C.foo instead of _Ctype_foo.

Before:
x.go:20[/var/folders/00/05_b8000h01000cxqpysvccm000n9d/T/go-build242036121/command-line-arguments/_obj/x.cgo1.go:19]: cannot use tv.Usec (type int32) as type _Ctype___darwin_suseconds_t in assignment

After:
x.go:20: cannot use tv.Usec (type int32) as type C.__darwin_suseconds_t in assignment

Fixes issue 4255.

R=golang-dev, iant
CC=golang-dev
https://codereview.appspot.com/7231075
runtime: cgo-related fixes

* Separate internal and external LockOSThread, for cgo safety.
* Show goroutine that made faulting cgo call.
* Never start a panic due to a signal caused by a cgo call.

Fixes issue 3774.
Fixes issue 3775.
Fixes issue 3797.

R=golang-dev, iant
CC=golang-dev
https://codereview.appspot.com/7228081
cmd/6c, cmd/6g: add flag to support large-model code generation

Added the -pic flag to 6c and 6g to avoid assembler instructions that
cannot use RIP-relative adressing. This is needed to support the -shared mode
in 6l.

See also:
https://codereview.appspot.com/6926049
https://codereview.appspot.com/6822078

R=golang-dev, rsc
CC=golang-dev
https://codereview.appspot.com/7064048

Committer: Russ Cox <rsc@golang.org>
bytes, strings: add TrimPrefix and TrimSuffix

Everybody either gets confused and thinks this is
TrimLeft/TrimRight or does this by hand which gets
repetitive looking.

R=rsc, kevlar
CC=golang-dev
https://codereview.appspot.com/7239044
sort: add Reverse as a function

This updates: https://codereview.appspot.com/6909059/
Fixes issue 4511.

R=minux.ma, rsc
CC=golang-dev
https://codereview.appspot.com/6932054

Committer: Russ Cox <rsc@golang.org>
sort: delete now-duplicate example, fix build

R=golang-dev, minux.ma
CC=golang-dev
https://codereview.appspot.com/7220075
reflect: document that Value.Slice panics on an unaddressable array.

Fixes issue 4736.

R=rsc
CC=golang-dev
https://codereview.appspot.com/7239045

Committer: Russ Cox <rsc@golang.org>
runtime, cmd/ld: make code more position-independent

Change the stack unwinding code to compensate for the dynamic
relocation of symbols.
Change the gc instruction GC_CALL to use a relative offset instead of
an absolute address.

R=golang-dev
CC=golang-dev
https://codereview.appspot.com/7248048

Committer: Russ Cox <rsc@golang.org>