4 * Create DLL header and things
6 * © 1994-1998 Straylight
9 /*----- Licensing note ----------------------------------------------------*
11 * This file is part of Straylight's Dynamic Linking System (SDLS)
13 * SDLS is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2, or (at your option)
18 * SDLS is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with SDLS. If not, write to the Free Software Foundation,
25 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36 #include "aof/chunk.h"
37 #include "hashtable.h"
48 static void ext__entries(char *p,void *handle)
52 static int entry[4]={0xE92D0007, /* STMFD sp!,{a1-a3} */
53 0xE59FC000, /* LDR ip,=address */
54 0xEA000000}; /* B _dll_extentry */
56 if (hash_find(t->osym,p))
58 r.offset=t->f.area->next+8;
59 r.t.type_1.symbol=t->symbol;
60 r.t.type_1.field=aof_FULLWORD;
61 r.t.type_1.type=aof_PCRELATIVE;
62 r.t.type_1.symreloc=1;
63 aof_add(r,t->f.reloc);
65 aof_reloc(p,t->f.area->next+12,0,&t->f);
66 sprintf(buf,"_extEntry_%s",p);
67 aof_addsym(buf,t->f.area->next,0,4,&t->f);
68 aof_add(entry,t->f.area);
72 void extentry(char *name,readdef_info *inf,hashtable osym)
76 fp=fopen(name,"wb"); /* Open the output file */
77 if (!fp) /* If the file wasn't opened */
78 error(NOOPENOUT,name); /* Better give an error */
81 char _buf[sizeof(chunk_fixedHeader)+5*sizeof(chunk_tableEntry)];
82 chunk_header *h=(chunk_header *)&_buf; /* Allocate memory easily :-) */
84 aof_chunkinfo obj_idfn={0};
85 aof_chunkinfo obj_head={0};
86 aof_chunkinfo obj_area={0};
87 aof_chunkinfo obj_symt={0};
88 aof_chunkinfo obj_strt={0};
89 aof_chunkinfo reloc={0};
94 h->hdr.id=chunk_MAGIC; /* Fill in magic thingy */
95 h->hdr.maxChunks=h->hdr.numChunks=5; /* And number of chunks */
103 aof_string("Straylight Dynamic Link Library building system 1.01",
107 aof_int(0,&obj_strt);
108 aof_string("DLL$$ExtEntry",&obj_strt);
112 sym.name=aof_string("_dll_extentry",&obj_strt);
115 t.symbol=aof_add(sym,&obj_symt)/sizeof(aof_symbol);
118 hash_enumerate(inf->vsym,ext__entries,&t);
120 aof_int((int)aof_RELOC,&obj_head);
121 aof_int(150,&obj_head);
122 aof_int(1,&obj_head);
123 aof_int(obj_symt.next/sizeof(aof_symbol),&obj_head);
124 aof_int(0,&obj_head);
125 aof_int(0,&obj_head);
127 aof_int(4,&obj_head);
128 aof_int(0x00002202,&obj_head);
129 aof_int(obj_area.next,&obj_head);
130 aof_int(reloc.next/8,&obj_head);
131 aof_int(0,&obj_head);
133 aof_addBlock(reloc.p,reloc.next,&obj_area);
135 aof_fill(obj_strt.next,0,&obj_strt);
138 memcpy(h->table[0].chunkName,"OBJ_IDFN",8);
139 memcpy(h->table[1].chunkName,"OBJ_HEAD",8);
140 memcpy(h->table[2].chunkName,"OBJ_AREA",8);
141 memcpy(h->table[3].chunkName,"OBJ_SYMT",8);
142 memcpy(h->table[4].chunkName,"OBJ_STRT",8);
144 o=sizeof(chunk_fixedHeader)+5*sizeof(chunk_tableEntry);
146 h->table[0].offset=o;
147 h->table[0].size=obj_idfn.next;
150 h->table[1].offset=o;
151 h->table[1].size=obj_head.next;
154 h->table[2].offset=o;
155 h->table[2].size=obj_area.next;
158 h->table[3].offset=o;
159 h->table[3].size=obj_symt.next;
162 h->table[4].offset=o;
163 h->table[4].size=obj_strt.next;
166 fwrite(h,sizeof(chunk_fixedHeader)+5*sizeof(chunk_tableEntry),1,fp);
167 fwrite(obj_idfn.p,obj_idfn.next,1,fp);
168 fwrite(obj_head.p,obj_head.next,1,fp);
169 fwrite(obj_area.p,obj_area.next,1,fp);
170 fwrite(obj_symt.p,obj_symt.next,1,fp);
171 fwrite(obj_strt.p,obj_strt.next,1,fp);