summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwolfgang.thaller@gmx.net <unknown>2006-03-06 03:30:52 +0000
committerwolfgang.thaller@gmx.net <unknown>2006-03-06 03:30:52 +0000
commitd52e6f240e8f7091f08d0ef933f4b2725e65cb38 (patch)
tree123cf251dbad15087dfd16fc256e8dceb9608ab6
parent868d7f6665bb6440ad8a462103b3809fffbd8ae7 (diff)
downloadhaskell-d52e6f240e8f7091f08d0ef933f4b2725e65cb38.tar.gz
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.
-rw-r--r--ghc/rts/Linker.c48
1 files changed, 22 insertions, 26 deletions
diff --git a/ghc/rts/Linker.c b/ghc/rts/Linker.c
index 901e0896f3..e09a1151a8 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;i<segLC->nsects;i++)
- {
- if(!strcmp(sections[i].sectname,"__la_symbol_ptr"))
- la_ptrs = &sections[i];
- else if(!strcmp(sections[i].sectname,"__nl_symbol_ptr"))
- nl_ptrs = &sections[i];
- else if(!strcmp(sections[i].sectname,"__la_sym_ptr2"))
- la_ptrs = &sections[i];
- else if(!strcmp(sections[i].sectname,"__la_sym_ptr3"))
- la_ptrs = &sections[i];
- else if(!strcmp(sections[i].sectname,"__pointers"))
- nl_ptrs = &sections[i];
- else if(!strcmp(sections[i].sectname,"__jump_table"))
- jump_table = &sections[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;i<segLC->nsects;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,&sections[i],indirectSyms,nlist))
+ return 0;
+ }
+ else if(!strcmp(sections[i].sectname,"__nl_symbol_ptr")
+ || !strcmp(sections[i].sectname,"__pointers"))
+ {
+ if(!resolveImports(oc,image,symLC,&sections[i],indirectSyms,nlist))
+ return 0;
+ }
+ else if(!strcmp(sections[i].sectname,"__jump_table"))
+ {
+ if(!resolveImports(oc,image,symLC,&sections[i],indirectSyms,nlist))
+ return 0;
+ }
+ }
}
for(i=0;i<segLC->nsects;i++)