Subversion Repositories Kolibri OS

Rev

Rev 647 | Rev 6441 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 647 Rev 6429
Line 94... Line 94...
94
			if (sym>symtab_section->data_offset/sizeof(Elf32_Sym))
94
			if (sym>symtab_section->data_offset/sizeof(Elf32_Sym))
95
				continue;
95
				continue;
96
			Elf32_Sym* esym = ((Elf32_Sym *)symtab_section->data)+sym;
96
			Elf32_Sym* esym = ((Elf32_Sym *)symtab_section->data)+sym;
97
			int sect=esym->st_shndx;
97
			int sect=esym->st_shndx;
98
			ss=findsection(me,sect);
98
			ss=findsection(me,sect);
99
			if (ss==0) continue;
99
			if (ss==0) 
-
 
100
			{
-
 
101
            	const char *sym_name = strtab_section->data + esym->st_name;
-
 
102
    			tcc_error_noabort("undefined symbol '%s'", sym_name);
-
 
103
				continue;
-
 
104
			}
100
			if (rel->r_offset>s->data_size)
105
			if (rel->r_offset>s->data_size)
101
				continue;
106
				continue;
102
			if (type==R_386_PC32)
107
			if (type==R_386_PC32)
103
				*(int*)(rel->r_offset+s->data)+=ss->sh_addr+esym->st_value-rel->r_offset-s->sh_addr;
108
				*(int*)(rel->r_offset+s->data)+=ss->sh_addr+esym->st_value-rel->r_offset-s->sh_addr;
104
			else if (type==R_386_32)
109
			else if (type==R_386_32)
Line 176... Line 181...
176
	addr=(addr+4)&(~3);
181
	addr=(addr+4)&(~3);
177
	me->header.stack=addr;
182
	me->header.stack=addr;
178
	me->header.memory_size=addr;
183
	me->header.memory_size=addr;
179
	build_reloc(me);
184
	build_reloc(me);
180
}
185
}
-
 
186
 
-
 
187
 
-
 
188
const char *tcc_get_symbol_name(int st_name) 
-
 
189
// return string by index from stringtable section
-
 
190
{
-
 
191
	const char *sym_name = strtab_section->data + st_name;
-
 
192
	return sym_name;
-
 
193
}
-
 
194
 
181
int tcc_find_symbol_me(me_info* me, const char *sym_name)
195
int tcc_find_symbol_me(me_info* me, const char *sym_name)
182
{
196
{
183
	int i;
197
	int i;
184
	int symtab;
198
	int symtab;
185
	int strtab;
199
	int strtab;
Line 197... Line 211...
197
		{
211
		{
198
			strtab=i;
212
			strtab=i;
199
		}
213
		}
200
	}
214
	}
201
	if (symtab==0 || strtab==0)
215
	if (symtab==0 || strtab==0)
-
 
216
	{
-
 
217
        tcc_error_noabort("undefined sections .symtab or .strtab on linking '%s'", sym_name);
202
		return 0;
218
		return 0;
-
 
219
	}
203
	Elf32_Sym* s,*se;
220
	Elf32_Sym* s,*se;
204
	char* name;
221
	char* name;
205
	s=(Elf32_Sym*)me->s1->sections[symtab]->data;
222
	s=(Elf32_Sym*)me->s1->sections[symtab]->data;
206
	se=(Elf32_Sym*)(((void*)s)+me->s1->sections[symtab]->data_offset);
223
	se=(Elf32_Sym*)(((void*)s)+me->s1->sections[symtab]->data_offset);
207
	name=(char*)me->s1->sections[strtab]->data;
224
	name=(char*)me->s1->sections[strtab]->data;
Line 211... Line 228...
211
		{
228
		{
212
			return s->st_value+findsection(me,s->st_shndx)->sh_addr;
229
			return s->st_value+findsection(me,s->st_shndx)->sh_addr;
213
		}
230
		}
214
		s++;
231
		s++;
215
	}
232
	}
-
 
233
    tcc_error_noabort("undefined symbol '%s'", sym_name);
216
	return 0;
234
	return 0;
217
}
235
}
-
 
236
 
218
const char* me_magic="MENUET01";
237
const char* me_magic="MENUET01";
219
int tcc_output_me(TCCState* s1,const char *filename)
238
int tcc_output_me(TCCState* s1,const char *filename)
220
{
239
{
221
	me_info me;
240
	me_info me;
222
    int i;
241
    int i;
Line 244... Line 263...
244
	for (si=me.data_sections;si;si=si->next)
263
	for (si=me.data_sections;si;si=si->next)
245
		fwrite(si->data,1,si->data_size,f);
264
		fwrite(si->data,1,si->data_size,f);
246
	fclose(f);
265
	fclose(f);
247
	return 0;
266
	return 0;
248
}
267
}
-
 
268
 
-
 
269
#ifndef _WIN32
-
 
270
 
-
 
271
static inline int get_current_folder(char* buf, int bufsize){
-
 
272
    register int val;
-
 
273
    asm volatile ("int $0x40":"=a"(val):"a"(30), "b"(2), "c"(buf), "d"(bufsize));
-
 
274
    return val;
-
 
275
}
-
 
276
 
-
 
277
 
-
 
278
char *getcwd(char *buf, size_t size)
-
 
279
{
-
 
280
	int rc = get_current_folder(buf, size);
-
 
281
	if (rc > size)
-
 
282
	{
-
 
283
		errno = ERANGE;
-
 
284
		return 0;
-
 
285
	}
-
 
286
	else
-
 
287
		return buf;
-
 
288
}
-
 
289
 
-
 
290
#endif