X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FLinker.c;h=d8f1e435a5585d74dfdc1ab69124d446bf2cc61b;hb=0181f5b8e87edbb50fbbe06efb8fca203ad535ea;hp=d263363c364243f2b51e3192fde36796c37527ca;hpb=20d697a1c300663df2c1472e222e57c84c4385fc;p=ghc-hetmet.git diff --git a/ghc/rts/Linker.c b/ghc/rts/Linker.c index d263363..d8f1e43 100644 --- a/ghc/rts/Linker.c +++ b/ghc/rts/Linker.c @@ -296,6 +296,7 @@ typedef struct _RtsSymbolVal { SymX(log) \ SymX(sqrt) \ SymX(memcpy) \ + SymX(stg_InstallConsoleEvent) \ Sym(mktime) \ Sym(_imp___timezone) \ Sym(_imp___tzname) \ @@ -388,9 +389,12 @@ typedef struct _RtsSymbolVal { SymX(__int_encodeDouble) \ SymX(__int_encodeFloat) \ SymX(andIntegerzh_fast) \ + SymX(atomicallyzh_fast) \ SymX(barf) \ SymX(blockAsyncExceptionszh_fast) \ SymX(catchzh_fast) \ + SymX(catchRetryzh_fast) \ + SymX(catchSTMzh_fast) \ SymX(closure_flags) \ SymX(cmp_thread) \ SymX(cmpIntegerzh_fast) \ @@ -445,6 +449,7 @@ typedef struct _RtsSymbolVal { SymX_redirect(newCAF, newDynCAF) \ SymX(newMVarzh_fast) \ SymX(newMutVarzh_fast) \ + SymX(newTVarzh_fast) \ SymX(atomicModifyMutVarzh_fast) \ SymX(newPinnedByteArrayzh_fast) \ SymX(orIntegerzh_fast) \ @@ -458,10 +463,12 @@ typedef struct _RtsSymbolVal { SymX(quotRemIntegerzh_fast) \ SymX(raisezh_fast) \ SymX(raiseIOzh_fast) \ + SymX(readTVarzh_fast) \ SymX(remIntegerzh_fast) \ SymX(resetNonBlockingFd) \ SymX(resumeThread) \ SymX(resolveObjs) \ + SymX(retryzh_fast) \ SymX(rts_apply) \ SymX(rts_checkSchedStatus) \ SymX(rts_eval) \ @@ -571,6 +578,7 @@ typedef struct _RtsSymbolVal { SymX(waitReadzh_fast) \ SymX(waitWritezh_fast) \ SymX(word2Integerzh_fast) \ + SymX(writeTVarzh_fast) \ SymX(xorIntegerzh_fast) \ SymX(yieldzh_fast) @@ -3654,68 +3662,86 @@ static int ocGetNames_MachO(ObjectCode* oc) // count external symbols defined here oc->n_symbols = 0; - for(i=dsymLC->iextdefsym;iiextdefsym+dsymLC->nextdefsym;i++) + if(dsymLC) { - if((nlist[i].n_type & N_TYPE) == N_SECT) - oc->n_symbols++; + for(i = dsymLC->iextdefsym; + i < dsymLC->iextdefsym + dsymLC->nextdefsym; + i++) + { + if((nlist[i].n_type & N_TYPE) == N_SECT) + oc->n_symbols++; + } } - for(i=0;insyms;i++) + if(symLC) { - if((nlist[i].n_type & N_TYPE) == N_UNDF + for(i=0;insyms;i++) + { + if((nlist[i].n_type & N_TYPE) == N_UNDF && (nlist[i].n_type & N_EXT) && (nlist[i].n_value != 0)) - { - commonSize += nlist[i].n_value; - oc->n_symbols++; - } + { + commonSize += nlist[i].n_value; + oc->n_symbols++; + } + } } oc->symbols = stgMallocBytes(oc->n_symbols * sizeof(char*), "ocGetNames_MachO(oc->symbols)"); - // insert symbols into hash table - for(i=dsymLC->iextdefsym,curSymbol=0;iiextdefsym+dsymLC->nextdefsym;i++) + if(dsymLC) { - if((nlist[i].n_type & N_TYPE) == N_SECT) - { - char *nm = image + symLC->stroff + nlist[i].n_un.n_strx; - ghciInsertStrHashTable(oc->fileName, symhash, nm, image + - sections[nlist[i].n_sect-1].offset - - sections[nlist[i].n_sect-1].addr - + nlist[i].n_value); - oc->symbols[curSymbol++] = nm; - } - } - - // insert local symbols into lochash - for(i=dsymLC->ilocalsym;iilocalsym+dsymLC->nlocalsym;i++) - { - if((nlist[i].n_type & N_TYPE) == N_SECT) - { - char *nm = image + symLC->stroff + nlist[i].n_un.n_strx; - ghciInsertStrHashTable(oc->fileName, oc->lochash, nm, image + - sections[nlist[i].n_sect-1].offset - - sections[nlist[i].n_sect-1].addr - + nlist[i].n_value); - } + // insert symbols into hash table + for(i = dsymLC->iextdefsym, curSymbol = 0; + i < dsymLC->iextdefsym + dsymLC->nextdefsym; + i++) + { + if((nlist[i].n_type & N_TYPE) == N_SECT) + { + char *nm = image + symLC->stroff + nlist[i].n_un.n_strx; + ghciInsertStrHashTable(oc->fileName, symhash, nm, + image + + sections[nlist[i].n_sect-1].offset + - sections[nlist[i].n_sect-1].addr + + nlist[i].n_value); + oc->symbols[curSymbol++] = nm; + } + } + + // insert local symbols into lochash + for(i=dsymLC->ilocalsym;iilocalsym+dsymLC->nlocalsym;i++) + { + if((nlist[i].n_type & N_TYPE) == N_SECT) + { + char *nm = image + symLC->stroff + nlist[i].n_un.n_strx; + ghciInsertStrHashTable(oc->fileName, oc->lochash, nm, + image + + sections[nlist[i].n_sect-1].offset + - sections[nlist[i].n_sect-1].addr + + nlist[i].n_value); + } + } } - commonStorage = stgCallocBytes(1,commonSize,"ocGetNames_MachO(common symbols)"); commonCounter = (unsigned long)commonStorage; - for(i=0;insyms;i++) + if(symLC) { - if((nlist[i].n_type & N_TYPE) == N_UNDF - && (nlist[i].n_type & N_EXT) && (nlist[i].n_value != 0)) - { - char *nm = image + symLC->stroff + nlist[i].n_un.n_strx; - unsigned long sz = nlist[i].n_value; + for(i=0;insyms;i++) + { + if((nlist[i].n_type & N_TYPE) == N_UNDF + && (nlist[i].n_type & N_EXT) && (nlist[i].n_value != 0)) + { + char *nm = image + symLC->stroff + nlist[i].n_un.n_strx; + unsigned long sz = nlist[i].n_value; - nlist[i].n_value = commonCounter; + nlist[i].n_value = commonCounter; - ghciInsertStrHashTable(oc->fileName, symhash, nm, (void*)commonCounter); - oc->symbols[curSymbol++] = nm; + ghciInsertStrHashTable(oc->fileName, symhash, nm, + (void*)commonCounter); + oc->symbols[curSymbol++] = nm; - commonCounter += sz; - } + commonCounter += sz; + } + } } return 1; } @@ -3731,7 +3757,6 @@ static int ocResolve_MachO(ObjectCode* oc) struct symtab_command *symLC = NULL; struct dysymtab_command *dsymLC = NULL; struct nlist *nlist; - unsigned long *indirectSyms; for(i=0;incmds;i++) { @@ -3745,7 +3770,8 @@ static int ocResolve_MachO(ObjectCode* oc) } sections = (struct section*) (segLC+1); - nlist = (struct nlist*) (image + symLC->symoff); + nlist = symLC ? (struct nlist*) (image + symLC->symoff) + : NULL; for(i=0;insects;i++) { @@ -3755,15 +3781,19 @@ static int ocResolve_MachO(ObjectCode* oc) nl_ptrs = §ions[i]; } - indirectSyms = (unsigned long*) (image + dsymLC->indirectsymoff); - - if(la_ptrs) - if(!resolveImports(oc,image,symLC,la_ptrs,indirectSyms,nlist)) - return 0; - if(nl_ptrs) - if(!resolveImports(oc,image,symLC,nl_ptrs,indirectSyms,nlist)) - return 0; - + if(dsymLC) + { + unsigned long *indirectSyms + = (unsigned long*) (image + dsymLC->indirectsymoff); + + if(la_ptrs) + if(!resolveImports(oc,image,symLC,la_ptrs,indirectSyms,nlist)) + return 0; + if(nl_ptrs) + if(!resolveImports(oc,image,symLC,nl_ptrs,indirectSyms,nlist)) + return 0; + } + for(i=0;insects;i++) { if(!relocateSection(oc,image,symLC,nlist,segLC->nsects,sections,§ions[i])) @@ -3792,14 +3822,24 @@ static int ocResolve_MachO(ObjectCode* oc) static void machoInitSymbolsWithoutUnderscore() { - void *p; + extern void* symbolsWithoutUnderscore[]; + void **p = symbolsWithoutUnderscore; + __asm__ volatile(".data\n_symbolsWithoutUnderscore:"); #undef Sym -#define Sym(x) \ - __asm__ ("lis %0,hi16(" #x ")\n\tori %0,%0,lo16(" #x ")" : "=r" (p)); \ - ghciInsertStrHashTable("(GHCi built-in symbols)", symhash, #x, p); +#define Sym(x) \ + __asm__ volatile(".long " # x); RTS_MACHO_NOUNDERLINE_SYMBOLS + __asm__ volatile(".text"); + +#undef Sym +#define Sym(x) \ + ghciInsertStrHashTable("(GHCi built-in symbols)", symhash, #x, *p++); + + RTS_MACHO_NOUNDERLINE_SYMBOLS + +#undef Sym } #endif