From d52e6f240e8f7091f08d0ef933f4b2725e65cb38 Mon Sep 17 00:00:00 2001 From: "wolfgang.thaller@gmx.net" Date: Mon, 6 Mar 2006 03:30:52 +0000 Subject: [PATCH] Mach-O Linker: handle multiple import sections In the rare event that a .o file contains more than one flavour of a [non]lazy pointers sections, resolve all of them, not just one. --- ghc/rts/Linker.c | 48 ++++++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/ghc/rts/Linker.c b/ghc/rts/Linker.c index 901e089..e09a115 100644 --- a/ghc/rts/Linker.c +++ b/ghc/rts/Linker.c @@ -4191,7 +4191,7 @@ static int ocResolve_MachO(ObjectCode* oc) struct load_command *lc = (struct load_command*) (image + sizeof(struct mach_header)); unsigned i; struct segment_command *segLC = NULL; - struct section *sections, *la_ptrs = NULL, *nl_ptrs = NULL, *jump_table = NULL; + struct section *sections; struct symtab_command *symLC = NULL; struct dysymtab_command *dsymLC = NULL; struct nlist *nlist; @@ -4211,36 +4211,32 @@ static int ocResolve_MachO(ObjectCode* oc) nlist = symLC ? (struct nlist*) (image + symLC->symoff) : NULL; - for(i=0;insects;i++) - { - if(!strcmp(sections[i].sectname,"__la_symbol_ptr")) - la_ptrs = §ions[i]; - else if(!strcmp(sections[i].sectname,"__nl_symbol_ptr")) - nl_ptrs = §ions[i]; - else if(!strcmp(sections[i].sectname,"__la_sym_ptr2")) - la_ptrs = §ions[i]; - else if(!strcmp(sections[i].sectname,"__la_sym_ptr3")) - la_ptrs = §ions[i]; - else if(!strcmp(sections[i].sectname,"__pointers")) - nl_ptrs = §ions[i]; - else if(!strcmp(sections[i].sectname,"__jump_table")) - jump_table = §ions[i]; - } - 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; - if(jump_table) - if(!resolveImports(oc,image,symLC,jump_table,indirectSyms,nlist)) - return 0; + for(i=0;insects;i++) + { + if( !strcmp(sections[i].sectname,"__la_symbol_ptr") + || !strcmp(sections[i].sectname,"__la_sym_ptr2") + || !strcmp(sections[i].sectname,"__la_sym_ptr3")) + { + if(!resolveImports(oc,image,symLC,§ions[i],indirectSyms,nlist)) + return 0; + } + else if(!strcmp(sections[i].sectname,"__nl_symbol_ptr") + || !strcmp(sections[i].sectname,"__pointers")) + { + if(!resolveImports(oc,image,symLC,§ions[i],indirectSyms,nlist)) + return 0; + } + else if(!strcmp(sections[i].sectname,"__jump_table")) + { + if(!resolveImports(oc,image,symLC,§ions[i],indirectSyms,nlist)) + return 0; + } + } } for(i=0;insects;i++) -- 1.7.10.4