Subversion Repositories Kolibri OS

Rev

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

Rev 340 Rev 370
Line 1416... Line 1416...
1416
	ja	value_out_of_range
1416
	ja	value_out_of_range
1417
	jmp	instruction_assembled
1417
	jmp	instruction_assembled
1418
mark_pe_relocation:
1418
mark_pe_relocation:
1419
	push	eax ebx
1419
	push	eax ebx
1420
	mov	al,2
1420
	test	[format_flags],8
1421
	test	[format_flags],8
-
 
1422
	jz	check_pe_relocation_type
1421
	jz	check_pe32_relocation_type
1423
	mov	al,4
1422
	cmp	[value_type],4
1424
      check_pe_relocation_type:
1423
	je	pe_relocation_type_ok
-
 
1424
      check_pe32_relocation_type:
1425
	cmp	[value_type],al
1425
	cmp	[value_type],2
1426
	je	pe_relocation_type_ok
1426
	je	pe_relocation_type_ok
1427
	cmp	[error_line],0
1427
	cmp	[error_line],0
1428
	jne	pe_relocation_type_ok
1428
	jne	pe_relocation_type_ok
1429
	mov	eax,[current_line]
1429
	mov	eax,[current_line]
1430
	mov	[error_line],eax
1430
	mov	[error_line],eax
1431
	mov	[error],invalid_use_of_symbol
1431
	mov	[error],invalid_use_of_symbol
Line 1436... Line 1436...
1436
	add	eax,[ebx+0Ch]
1436
	add	eax,[ebx+0Ch]
1437
	mov	ebx,[free_additional_memory]
1437
	mov	ebx,[free_additional_memory]
1438
	inc	[number_of_relocations]
1438
	inc	[number_of_relocations]
1439
	jz	invalid_use_of_symbol
1439
	jz	invalid_use_of_symbol
1440
	mov	[ebx],eax
1440
	add	ebx,5
1441
	add	ebx,4
-
 
1442
	cmp	ebx,[structures_buffer]
1441
	cmp	ebx,[structures_buffer]
1443
	jae	out_of_memory
1442
	jae	out_of_memory
1444
	mov	[free_additional_memory],ebx
1443
	mov	[free_additional_memory],ebx
1445
	pop	ebx eax
1444
	mov	[ebx-5],eax
-
 
1445
	cmp	[value_type],2
-
 
1446
	je	fixup_32bit
-
 
1447
	mov	byte [ebx-1],0Ah
-
 
1448
	jmp	fixup_ok
-
 
1449
      fixup_32bit:
-
 
1450
	mov	byte [ebx-1],3
-
 
1451
      fixup_ok:
-
 
1452
	pop	ebx eax
1446
	ret
1453
	ret
1447
generate_pe_data:
1454
generate_pe_data:
1448
	cmp	al,2
1455
	cmp	al,2
1449
	je	make_pe_resource
1456
	je	make_pe_resource
1450
	cmp	al,5
1457
	cmp	al,5
1451
	je	make_pe_fixups
1458
	je	make_pe_fixups
1452
	ret
1459
	ret
1453
make_pe_resource:
1460
make_pe_fixups:
-
 
1461
	bts	[resolver_flags],0
-
 
1462
	jc	pe_relocatable_ok
-
 
1463
	or	[next_pass_needed],-1
-
 
1464
     pe_relocatable_ok:
-
 
1465
	push	esi
-
 
1466
	mov	ecx,[number_of_relocations]
-
 
1467
	mov	esi,[free_additional_memory]
-
 
1468
	lea	eax,[ecx*5]
-
 
1469
	sub	esi,eax
-
 
1470
	mov	[free_additional_memory],esi
-
 
1471
	or	[number_of_relocations],-1
-
 
1472
	xor	edx,edx
-
 
1473
	mov	ebp,edi
-
 
1474
      make_fixups:
-
 
1475
	cmp	[esi],edx
-
 
1476
	jb	store_fixup
-
 
1477
	mov	eax,edi
-
 
1478
	sub	eax,ebp
-
 
1479
	test	eax,11b
-
 
1480
	jz	fixups_block
-
 
1481
	xor	ax,ax
-
 
1482
	stos	word [edi]
-
 
1483
	add	dword [ebx],2
-
 
1484
      fixups_block:
-
 
1485
	mov	eax,edx
-
 
1486
	add	edx,1000h
-
 
1487
	cmp	[esi],edx
-
 
1488
	jae	fixups_block
-
 
1489
	stos	dword [edi]
-
 
1490
	mov	ebx,edi
-
 
1491
	mov	eax,8
-
 
1492
	stos	dword [edi]
-
 
1493
      store_fixup:
-
 
1494
	jecxz	fixups_done
-
 
1495
	add	dword [ebx],2
-
 
1496
	mov	eax,[esi]
-
 
1497
	and	ax,0FFFh
-
 
1498
	mov	dl,[esi+4]
-
 
1499
	shl	dx,12
-
 
1500
	or	ax,dx
-
 
1501
	stos	word [edi]
-
 
1502
	add	esi,5
-
 
1503
	loop	make_fixups
-
 
1504
      fixups_done:
-
 
1505
	pop	esi
-
 
1506
	ret
-
 
1507
make_pe_resource:
1454
	cmp	byte [esi],82h
1508
	cmp	byte [esi],82h
1455
	jne	resource_done
1509
	jne	resource_done
1456
	inc	esi
1510
	inc	esi
1457
	lods	word [esi]
1511
	lods	word [esi]
1458
	cmp	ax,'('
1512
	cmp	ax,'('
Line 2015... Line 2069...
2015
	sub	eax,[resource_data]
2069
	sub	eax,[resource_data]
2016
	mov	[resource_size],eax
2070
	mov	[resource_size],eax
2017
      resource_done:
2071
      resource_done:
2018
	ret
2072
	ret
2019
make_pe_fixups:
2073
close_pe:
2020
	bts	[resolver_flags],0
-
 
2021
	jc	pe_relocatable_ok
-
 
2022
	or	[next_pass_needed],-1
-
 
2023
     pe_relocatable_ok:
-
 
2024
	push	esi
-
 
2025
	mov	ecx,[number_of_relocations]
-
 
2026
	mov	esi,[free_additional_memory]
-
 
2027
	mov	eax,ecx
-
 
2028
	shl	eax,2
-
 
2029
	sub	esi,eax
-
 
2030
	mov	[free_additional_memory],esi
-
 
2031
	or	[number_of_relocations],-1
-
 
2032
	xor	edx,edx
-
 
2033
	mov	ebp,edi
-
 
2034
      make_fixups:
-
 
2035
	cmp	[esi],edx
-
 
2036
	jb	store_fixup
-
 
2037
	mov	eax,edi
-
 
2038
	sub	eax,ebp
-
 
2039
	test	eax,11b
-
 
2040
	jz	fixups_block
-
 
2041
	xor	ax,ax
-
 
2042
	stos	word [edi]
-
 
2043
	add	dword [ebx],2
-
 
2044
      fixups_block:
-
 
2045
	mov	eax,edx
-
 
2046
	add	edx,1000h
-
 
2047
	cmp	[esi],edx
-
 
2048
	jae	fixups_block
-
 
2049
	stos	dword [edi]
-
 
2050
	mov	ebx,edi
-
 
2051
	mov	eax,8
-
 
2052
	stos	dword [edi]
-
 
2053
      store_fixup:
-
 
2054
	jecxz	fixups_done
-
 
2055
	add	dword [ebx],2
-
 
2056
	mov	eax,[esi]
-
 
2057
	and	ax,0FFFh
-
 
2058
	test	[format_flags],8
-
 
2059
	jnz	fixup_64bit
-
 
2060
	or	ax,3000h
-
 
2061
	jmp	fixup_ok
-
 
2062
      fixup_64bit:
-
 
2063
	or	ax,0A000h
-
 
2064
      fixup_ok:
-
 
2065
	stos	word [edi]
-
 
2066
	add	esi,4
-
 
2067
	loop	make_fixups
-
 
2068
      fixups_done:
-
 
2069
	pop	esi
-
 
2070
	ret
-
 
2071
close_pe:
-
 
2072
	call	close_pe_section
2074
	call	close_pe_section
2073
	mov	edx,[code_start]
2075
	mov	edx,[code_start]
2074
	mov	[edx+50h],eax
2076
	mov	[edx+50h],eax
2075
	call	make_timestamp
2077
	call	make_timestamp
2076
	mov	edx,[code_start]
2078
	mov	edx,[code_start]