Commit 117a6973 authored by Russ Cox's avatar Russ Cox

build: fix elf builds

Corrections due to new strict type rules for data+bss.
Also disable misc/cgo/cdefstest since you can't compile C code anymore.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/148050044
parent 54111a58
......@@ -204,10 +204,10 @@ enum
SELFSECT,
SMACHO, /* Mach-O __nl_symbol_ptr */
SMACHOGOT,
SWINDOWS,
SNOPTRDATA,
SINITARR,
SDATA,
SWINDOWS,
SBSS,
SNOPTRBSS,
STLSBSS,
......
......@@ -625,6 +625,7 @@ addstrdata(char *name, char *value)
sp = linklookup(ctxt, p, 0);
free(p);
addstring(sp, value);
sp->type = SRODATA;
s = linklookup(ctxt, name, 0);
s->size = 0;
......@@ -816,9 +817,15 @@ proggenaddsym(ProgGen *g, LSym *s)
proggenskip(g, g->pos, s->value - g->pos);
g->pos += s->value - g->pos;
if(s->gotype == nil && s->size >= PtrSize) {
// The test for names beginning with . here is meant
// to keep .dynamic and .dynsym from turning up as
// conservative symbols. They should be marked SELFSECT
// and not SDATA, but sometimes that doesn't happen.
// Leave debugging the SDATA issue for the Go rewrite.
if(s->gotype == nil && s->size >= PtrSize && s->name[0] != '.') {
// conservative scan
diag("missing Go type information for global symbol: %s", s->name);
diag("missing Go type information for global symbol: %s size %d", s->name, (int)s->size);
if((s->size%PtrSize) || (g->pos%PtrSize))
diag("proggenaddsym: unaligned conservative symbol %s: size=%lld pos=%lld",
s->name, s->size, g->pos);
......@@ -834,7 +841,7 @@ proggenaddsym(ProgGen *g, LSym *s)
proggenarrayend(g);
}
g->pos = s->value + size;
} else if(s->gotype == nil || decodetype_noptr(s->gotype) || s->size < PtrSize) {
} else if(s->gotype == nil || decodetype_noptr(s->gotype) || s->size < PtrSize || s->name[0] == '.') {
// no scan
if(s->size < 32*PtrSize) {
// Emit small symbols as data.
......
......@@ -221,8 +221,10 @@ loadlib(void)
// Provided by the code that imports the package.
// Since we are simulating the import, we have to provide this string.
cgostrsym = "go.string.\"runtime/cgo\"";
if(linkrlookup(ctxt, cgostrsym, 0) == nil)
if(linkrlookup(ctxt, cgostrsym, 0) == nil) {
addstrdata(cgostrsym, "runtime/cgo");
linklookup(ctxt, cgostrsym, 0)->type = SRODATA;
}
}
if(linkmode == LinkAuto) {
......
......@@ -167,10 +167,13 @@ esac
# This tests cgo -cdefs. That mode is not supported,
# so it's okay if it doesn't work on some systems.
# In particular, it works badly with clang on OS X.
[ "$CGO_ENABLED" != 1 ] || [ "$GOOS" == darwin ] ||
(xcd ../misc/cgo/testcdefs
./test.bash || exit 1
) || exit $?
# It doesn't work at all now that we disallow C code
# outside runtime. Once runtime has no C code it won't
# even be necessary.
# [ "$CGO_ENABLED" != 1 ] || [ "$GOOS" == darwin ] ||
# (xcd ../misc/cgo/testcdefs
# ./test.bash || exit 1
# ) || exit $?
[ "$CGO_ENABLED" != 1 ] || [ "$GOOS" == darwin ] ||
(xcd ../misc/cgo/testgodefs
......
......@@ -3,6 +3,7 @@
// license that can be found in the LICENSE file.
#include "runtime.h"
#include "textflag.h"
// Look up symbols in the Linux vDSO.
......@@ -171,14 +172,18 @@ struct vdso_info {
Elf64_Verdef *verdef;
};
#pragma dataflag NOPTR
static version_key linux26 = { (byte*)"LINUX_2.6", 0x3ae75f6 };
// initialize with vsyscall fallbacks
#pragma dataflag NOPTR
void* runtime·__vdso_time_sym = (void*)0xffffffffff600400ULL;
#pragma dataflag NOPTR
void* runtime·__vdso_gettimeofday_sym = (void*)0xffffffffff600000ULL;
#pragma dataflag NOPTR
void* runtime·__vdso_clock_gettime_sym = (void*)0;
#define SYM_KEYS_COUNT 3
#pragma dataflag NOPTR
static symbol_key sym_keys[] = {
{ (byte*)"__vdso_time", 0xa33c485, &runtime·__vdso_time_sym },
{ (byte*)"__vdso_gettimeofday", 0x315ca59, &runtime·__vdso_gettimeofday_sym },
......@@ -301,7 +306,7 @@ vdso_parse_symbols(struct vdso_info *vdso_info, int32 version)
if(vdso_info->valid == false)
return;
for(i=0; i<SYM_KEYS_COUNT; i++) {
for(i=0; i<nelem(sym_keys); i++) {
for(chain = vdso_info->bucket[sym_keys[i].sym_hash % vdso_info->nbucket];
chain != 0; chain = vdso_info->chain[chain]) {
......
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