]> Cypherpunks repositories - gostls13.git/commitdiff
build: fix elf builds
authorRuss Cox <rsc@golang.org>
Wed, 24 Sep 2014 21:45:11 +0000 (14:45 -0700)
committerRuss Cox <rsc@golang.org>
Wed, 24 Sep 2014 21:45:11 +0000 (14:45 -0700)
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

include/link.h
src/cmd/ld/data.c
src/cmd/ld/lib.c
src/run.bash
src/runtime/vdso_linux_amd64.c

index 292b077394356d96904dc431205b705f6df39360..845f9338d931c5426674d35bbab62a321a424c73 100644 (file)
@@ -204,10 +204,10 @@ enum
        SELFSECT,
        SMACHO, /* Mach-O __nl_symbol_ptr */
        SMACHOGOT,
+       SWINDOWS,
        SNOPTRDATA,
        SINITARR,
        SDATA,
-       SWINDOWS,
        SBSS,
        SNOPTRBSS,
        STLSBSS,
index 9d224d9eb9016bfa41ef0a3267a49a0ee6f44767..89226bfe28a2d5eaaa62e9dae1acaec9c8a1b26e 100644 (file)
@@ -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.
index 36f0f99de20d0aa2f396a5806aea666ead7f01b1..3edf7253d473b8cf0634e5fe677682471adc2aa1 100644 (file)
@@ -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) {
index 4966cf1aa6f086bd7184db15ef9a1d9d66ea2489..3c9430c87e97ae018a120d7df8f28b7eca1a5460 100755 (executable)
@@ -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
index 38e115243813aa2732e5c2d23c122cc3dce40ff4..41a41fdd6ae4adf312961c9a7960d9597f36d827 100644 (file)
@@ -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]) {