From fa8bedce93d3ba12e961810e3aac4198587af9ae Mon Sep 17 00:00:00 2001 From: "wolfgang.thaller@gmx.net" Date: Thu, 12 Apr 2007 21:01:55 +0000 Subject: [PATCH] Handle Weak Definitions in the Darwin Linker The __i686.get_pc_thunk symbols generated by gcc's PIC code generator are weak definitions that appear in every object file, so we need to deal with them. MERGE TO STABLE. --- rts/Linker.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/rts/Linker.c b/rts/Linker.c index 2dbcc15..598af97 100644 --- a/rts/Linker.c +++ b/rts/Linker.c @@ -4179,12 +4179,17 @@ static int ocGetNames_MachO(ObjectCode* oc) if(nlist[i].n_type & N_EXT) { 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; + if((nlist[i].n_desc & N_WEAK_DEF) && lookupSymbol(nm)) + ; // weak definition, and we already have a definition + else + { + 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; + } } else { -- 1.7.10.4