mirror of
https://github.com/yasm/yasm
synced 2026-08-26 22:26:05 -04:00
* xdf-objfmt.c (xdf_reloc.type): Remove FLAT relocation type and renumber.
(xdf_objfmt_output_expr): Likewise. (xdf_section_data_print): Likewise. * xdf.h (xdf_rtype): Likewise. * xdfdump.c (print_reloc): Likewise. * xdf.h: Bump revision number of xdf due to FLAT relocation removal. * modules/objfmts/xdf/Makefile.inc: Add tests for XDF format. * modules/objfmts/xdf/tests/Makefile.inc: Likewise. * xdf_test.sh: Likewise. * xdflong.asm, xdflong.errwarn, xdflong.hex: Likewise. * xdfprotect.asm, xdfprotect.errwarn, xdfprotect.hex: Likewise. * xdfother.asm, xdfother.errwarn, xdfother.hex: Likewise. svn path=/trunk/yasm/; revision=1151
This commit is contained in:
parent
713ab6d384
commit
da554ebe3b
15 changed files with 50547 additions and 22 deletions
|
|
@ -7,6 +7,6 @@ objfmt_xdf_la_LDFLAGS = -module -avoid-version -no-undefined
|
|||
objfmt_xdf_la_LIBADD = libyasm.la
|
||||
YASM_MODULES += -dlopen objfmt_xdf.la
|
||||
|
||||
#EXTRA_DIST += modules/objfmts/xdf/tests/Makefile.inc
|
||||
EXTRA_DIST += modules/objfmts/xdf/tests/Makefile.inc
|
||||
|
||||
#include modules/objfmts/xdf/tests/Makefile.inc
|
||||
include modules/objfmts/xdf/tests/Makefile.inc
|
||||
|
|
|
|||
14
modules/objfmts/xdf/tests/Makefile.inc
Normal file
14
modules/objfmts/xdf/tests/Makefile.inc
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
# $Id$
|
||||
|
||||
TESTS += modules/objfmts/xdf/tests/xdf_test.sh
|
||||
|
||||
EXTRA_DIST += modules/objfmts/xdf/tests/xdf_test.sh
|
||||
EXTRA_DIST += modules/objfmts/xdf/tests/xdflong.asm
|
||||
EXTRA_DIST += modules/objfmts/xdf/tests/xdflong.hex
|
||||
EXTRA_DIST += modules/objfmts/xdf/tests/xdflong.errwarn
|
||||
EXTRA_DIST += modules/objfmts/xdf/tests/xdfprotect.asm
|
||||
EXTRA_DIST += modules/objfmts/xdf/tests/xdfprotect.hex
|
||||
EXTRA_DIST += modules/objfmts/xdf/tests/xdfprotect.errwarn
|
||||
EXTRA_DIST += modules/objfmts/xdf/tests/xdfother.asm
|
||||
EXTRA_DIST += modules/objfmts/xdf/tests/xdfother.hex
|
||||
EXTRA_DIST += modules/objfmts/xdf/tests/xdfother.errwarn
|
||||
4
modules/objfmts/xdf/tests/xdf_test.sh
Executable file
4
modules/objfmts/xdf/tests/xdf_test.sh
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
#! /bin/sh
|
||||
# $Id$
|
||||
${srcdir}/out_test.sh xdf_test modules/objfmts/xdf/tests "xdf objfmt" "-f xdf" ".xdf"
|
||||
exit $?
|
||||
231
modules/objfmts/xdf/tests/xdflong.asm
Normal file
231
modules/objfmts/xdf/tests/xdflong.asm
Normal file
|
|
@ -0,0 +1,231 @@
|
|||
;; ########################################################################
|
||||
;; Macros
|
||||
;; ########################################################################
|
||||
|
||||
; descriptor type, base, limit, p_dpl_s, g_db_a
|
||||
%macro descriptor 5
|
||||
dw %3 ; Limit 15-0
|
||||
dw %2 ; Base 15-0
|
||||
db %2 >> 16 ; Base 23-16
|
||||
db ((%4 & 0xF) << 4) | (%1 & 0xF ) ; p_dpl_s_type
|
||||
db (%5 << 4) | ((%3 & 0xF0000) >> 16) ; g_db_a limit 19:16
|
||||
db %2 >> 24 ; Base 31-24
|
||||
%endmacro
|
||||
|
||||
; cdesc64 base, limit, dpl
|
||||
%macro cdesc64 3
|
||||
descriptor 0xB, %1, %2, 0x9 | (%3 & 0x3) << 1, 0xD
|
||||
%endmacro
|
||||
|
||||
; gates type, offset, selector, p_dpl_s
|
||||
%macro gates 4
|
||||
dw %2 ; Offset 15-00
|
||||
dw %3 ; Selector
|
||||
db 0 ; Ist
|
||||
db ((%4 & 0xF) << 4) | (%1 & 0xF) ; p_dpl_s_type
|
||||
dw %2 >> 16 ; Offset 31-16
|
||||
dd %2 >> 32 ; Offset 63-32
|
||||
%endmacro
|
||||
|
||||
; idesc64 offset, selector, ring
|
||||
%macro idesc64 3
|
||||
gates 0xE, %1, %2, 0x8 | ((%3 & 0x3) << 1)
|
||||
%endmacro
|
||||
|
||||
|
||||
; pageDirectory2M addr, nx, a, pcd, pwt, u, w, p
|
||||
%macro pageDirectory2M 8
|
||||
db %2 << 7
|
||||
dw %1 >> 40
|
||||
dd %1 >> 8
|
||||
db (%3 << 5) | (%4 << 4) | (%5 << 3) | (%6 << 2) | (%7 << 1) | %8
|
||||
%endmacro
|
||||
|
||||
; pageEntry2M addr, nx, pat, g, d, a, pcd, pwt, u, w, p
|
||||
%macro pageEntry2M 11
|
||||
db %2 << 7
|
||||
db %1 >> 48
|
||||
dd %1 >> 16
|
||||
dw (%3 << 12) | (%4 << 8) | (%5 << 6) | (%6 << 5) | (%7 << 4) | (%8 << 3) | (%9 << 2) | (%10 << 1) | %11 | 0x80
|
||||
%endmacro
|
||||
|
||||
|
||||
;; ########################################################################
|
||||
;; Code Section
|
||||
;; ########################################################################
|
||||
|
||||
SECTION CODE ABSOLUTE=0xFFFFFFFF00000000 FLAT USE64
|
||||
|
||||
test_code:
|
||||
|
||||
;; Your Code Goes Here
|
||||
add r8, r15
|
||||
|
||||
hlt
|
||||
|
||||
;; ########################################################################
|
||||
;; Setup Section
|
||||
;; ########################################################################
|
||||
|
||||
SECTION SETUP ALIGN=16 FLAT USE16
|
||||
|
||||
setup:
|
||||
|
||||
xor edx, edx ; Enable Var MTRRs
|
||||
mov eax, 0x0806 ; WriteBack
|
||||
mov ecx, 0x2FF
|
||||
wrmsr
|
||||
|
||||
mov ebx, cr0
|
||||
or ebx, 0x00000021 ; Protect Mode On, Int 16 for FPU
|
||||
and ebx, 0x9FFFFFFF ; Turn Caches on
|
||||
mov cr0, ebx
|
||||
|
||||
mov edx, cr4
|
||||
or edx, 0x00000620 ; Enable PAE, SSE OSFXSR, SEE OSXMMEXCPT
|
||||
mov cr4, edx
|
||||
|
||||
mov edx, pageMapL4 ; load pagetables
|
||||
mov cr3, edx
|
||||
|
||||
mov ecx, 0x80000080
|
||||
rdmsr ; Read EFER
|
||||
bts eax, 8 ; Enable Long Mode (LME=1)
|
||||
wrmsr ; Write EFER
|
||||
|
||||
bts ebx, 31 ; Enable Paging (PG=1)
|
||||
mov cr0, ebx
|
||||
|
||||
;; At this point LME=1, PAE=1, PG=1, CS.L=0, CS.D=0
|
||||
|
||||
lgdt [pgdt] ; Set GDT
|
||||
lidt [pidt] ; Set IDT
|
||||
|
||||
jmp 0x8 : long_mode
|
||||
|
||||
long_mode:
|
||||
|
||||
BITS 64
|
||||
|
||||
mov rax, test_code ; jmp to testcode
|
||||
jmp [rax]
|
||||
|
||||
|
||||
|
||||
;; ########################################################################
|
||||
;; Long Mode IDT
|
||||
;; ########################################################################
|
||||
|
||||
SECTION IDTP ALIGN=16 FLAT USE64
|
||||
|
||||
;; cdesc32 base, limit, dpl
|
||||
gdt0: dq 0 ; 0x0000 - Null descriptor
|
||||
cdesc64 zero, 0xFFFFF, 0 ; 0x0008 - Code Selector
|
||||
gdt_:
|
||||
|
||||
;; idesc64 offset, selector, dpl
|
||||
idt0: idesc64 isrL, 0x0008, 0 ; 0x00, 0 #DE, Divide Error
|
||||
idesc64 isrL, 0x0008, 0 ; 0x01, 1 #DB, Debug Fault
|
||||
idesc64 isrL, 0x0008, 0 ; 0x02, 2, ---, NMI
|
||||
idesc64 isrL, 0x0008, 0 ; 0x03, 3, #BP, Breakpoint
|
||||
idesc64 isrL, 0x0008, 0 ; 0x04, 4, #OF, INTO detected Overflow
|
||||
idesc64 isrL, 0x0008, 0 ; 0x05, 5, #BR, Bound Range Exceeded
|
||||
idesc64 isrL, 0x0008, 0 ; 0x06, 6, #UD, Invalid Opcode
|
||||
idesc64 isrL, 0x0008, 0 ; 0x07, 7, #NM, Device Not Available
|
||||
idesc64 isrL, 0x0008, 0 ; 0x08, 8, #DF, Double Fault
|
||||
idesc64 isrL, 0x0008, 0 ; 0x09 9, ---, Coprocessor Segment Overrun
|
||||
idesc64 isrL, 0x0008, 0 ; 0x0A, 10, #TS, Invalid TSS
|
||||
idesc64 isrL, 0x0008, 0 ; 0x0B, 11, #NP, Segment Not Present
|
||||
idesc64 isrL, 0x0008, 0 ; 0x0C, 12, #SS, Stack Fault
|
||||
idesc64 isrL, 0x0008, 0 ; 0x0D, 13, #GP, General Protection Fault
|
||||
idesc64 isrL, 0x0008, 0 ; 0x0E, 14, #PF, Page Fault
|
||||
idesc64 isrL, 0x0008, 0 ; 0x0F, 15, ---, Reserved
|
||||
idesc64 isrL, 0x0008, 0 ; 0x10, 16, #MF, Floating Point Fault
|
||||
idesc64 isrL, 0x0008, 0 ; 0x11, 17, #AC, Alignment Check
|
||||
idesc64 isrL, 0x0008, 0 ; 0x12 18, #MC, Machine Check
|
||||
idesc64 isrL, 0x0008, 0 ; 0x13, 19, #XF, SSE Fault
|
||||
idt_:
|
||||
|
||||
pgdt: dw (gdt_ - gdt0) ; Limit
|
||||
dd gdt0 ; base
|
||||
|
||||
pidt: dw (idt_ - idt0) ; Limit
|
||||
dd idt0 ; base
|
||||
|
||||
isrL: mov eax, 0xDEADBEEF ; Default Interrupt Handler
|
||||
out 0x80, eax
|
||||
hlt
|
||||
|
||||
;; ########################################################################
|
||||
;; Real Mode IDT
|
||||
;; ########################################################################
|
||||
|
||||
SECTION IDTR ABSOLUTE=0x00000000 FLAT USE16
|
||||
|
||||
;; FORMAT IP:CS
|
||||
zero: dw isrR, 0 ; 0x00, 0 #DE, Divide Error
|
||||
dw isrR, 0 ; 0x01, 1 #DB, Debug Fault
|
||||
dw isrR, 0 ; 0x02, 2, ---, NMI
|
||||
dw isrR, 0 ; 0x03, 3, #BP, Breakpoint
|
||||
dw isrR, 0 ; 0x04, 4, #OF, INTO detected Overflow
|
||||
dw isrR, 0 ; 0x05, 5, #BR, Bound Range Exceeded
|
||||
dw isrR, 0 ; 0x06, 6, #UD, Invalid Opcode
|
||||
dw isrR, 0 ; 0x07, 7, #NM, Device Not Available
|
||||
dw isrR, 0 ; 0x08, 8, #DF, Double Fault
|
||||
dw isrR, 0 ; 0x09 9, ---, Coprocessor Segment Overrun
|
||||
dw isrR, 0 ; 0x0A, 10, #TS, Invalid TSS
|
||||
dw isrR, 0 ; 0x0B, 11, #NP, Segment Not Present
|
||||
dw isrR, 0 ; 0x0C, 12, #SS, Stack Fault
|
||||
dw isrR, 0 ; 0x0D, 13, #GP, General Protection Fault
|
||||
dw isrR, 0 ; 0x0E, 14, #PF, Page Fault
|
||||
dw isrR, 0 ; 0x0F, 15, ---, Reserved
|
||||
dw isrR, 0 ; 0x10, 16, #MF, Floating Point Fault
|
||||
dw isrR, 0 ; 0x11, 17, #AC, Alignment Check
|
||||
dw isrR, 0 ; 0x12 18, #MC, Machine Check
|
||||
dw isrR, 0 ; 0x13, 19, #XF, SSE Fault
|
||||
|
||||
isrR: mov eax, 0xDEADBEEF ; Default Real Interrupt Handler
|
||||
out 0x80, eax
|
||||
hlt
|
||||
|
||||
;; ########################################################################
|
||||
;; 2 Meg Page Tables
|
||||
;; ########################################################################
|
||||
|
||||
SECTION PAGE ALIGN=4096 FLAT
|
||||
|
||||
pageDirE:
|
||||
%assign addr 0
|
||||
%rep 512
|
||||
; pageEntry addr, nx, pat, g, d, a, pcd, pwt, u, w, p
|
||||
pageEntry2M addr, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1 ; Accessed, WB, User, Writable, Present
|
||||
%assign addr addr + 0x200000
|
||||
%endrep
|
||||
|
||||
pageDirP:
|
||||
%rep 512
|
||||
; pageDirPointer addr, nx, a, pcd, pwt, u, w, p
|
||||
pageDirectory2M pageDirE, 0, 1, 0, 0, 1, 1, 1 ; Accessed, WB, User, Writable, Present
|
||||
%endrep
|
||||
|
||||
pageMapL4:
|
||||
%rep 512
|
||||
; pageDirectory addr, nx, a, pcd, pwt, u, w, p
|
||||
pageDirectory2M pageDirP, 0, 1, 0, 0, 1, 1, 1 ; Accessed, WB, User, Writable, Present
|
||||
%endrep
|
||||
|
||||
;; ########################################################################
|
||||
;; SMM Handler
|
||||
;; ########################################################################
|
||||
|
||||
SECTION SMM ABSOLUTE=0x00038000 USE16
|
||||
|
||||
rsm
|
||||
|
||||
;; ########################################################################
|
||||
;; Reset Vector
|
||||
;; ########################################################################
|
||||
|
||||
SECTION RESET ABSOLUTE=0xFFFFFFF0 USE16
|
||||
|
||||
jmp far setup
|
||||
1
modules/objfmts/xdf/tests/xdflong.errwarn
Normal file
1
modules/objfmts/xdf/tests/xdflong.errwarn
Normal file
|
|
@ -0,0 +1 @@
|
|||
-:123: warning: value does not fit in 16 bit field
|
||||
47795
modules/objfmts/xdf/tests/xdflong.hex
Normal file
47795
modules/objfmts/xdf/tests/xdflong.hex
Normal file
File diff suppressed because it is too large
Load diff
24
modules/objfmts/xdf/tests/xdfother.asm
Normal file
24
modules/objfmts/xdf/tests/xdfother.asm
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
extern var4
|
||||
extern farlabel
|
||||
global equ2
|
||||
|
||||
equ1 equ 4000
|
||||
equ2 equ 5000
|
||||
|
||||
[section foo]
|
||||
mov ax, bar
|
||||
mov ds, ax
|
||||
mov ax, [var2 wrt bar]
|
||||
|
||||
mov ax, seg var4
|
||||
mov es, ax
|
||||
mov ax, [es:var4]
|
||||
|
||||
[section bar]
|
||||
jmp far farlabel
|
||||
|
||||
[section baz]
|
||||
var2 dw 2
|
||||
|
||||
[section bss bss]
|
||||
var3 resd 4
|
||||
0
modules/objfmts/xdf/tests/xdfother.errwarn
Normal file
0
modules/objfmts/xdf/tests/xdfother.errwarn
Normal file
538
modules/objfmts/xdf/tests/xdfother.hex
Normal file
538
modules/objfmts/xdf/tests/xdfother.hex
Normal file
|
|
@ -0,0 +1,538 @@
|
|||
21
|
||||
43
|
||||
65
|
||||
87
|
||||
05
|
||||
00
|
||||
00
|
||||
00
|
||||
0b
|
||||
00
|
||||
00
|
||||
00
|
||||
88
|
||||
01
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
04
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
98
|
||||
01
|
||||
00
|
||||
00
|
||||
19
|
||||
00
|
||||
00
|
||||
00
|
||||
b1
|
||||
01
|
||||
00
|
||||
00
|
||||
04
|
||||
00
|
||||
00
|
||||
00
|
||||
05
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
f1
|
||||
01
|
||||
00
|
||||
00
|
||||
07
|
||||
00
|
||||
00
|
||||
00
|
||||
f8
|
||||
01
|
||||
00
|
||||
00
|
||||
02
|
||||
00
|
||||
00
|
||||
00
|
||||
06
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
18
|
||||
02
|
||||
00
|
||||
00
|
||||
02
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
07
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
04
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
10
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
60
|
||||
01
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
ff
|
||||
ff
|
||||
ff
|
||||
ff
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
66
|
||||
01
|
||||
00
|
||||
00
|
||||
01
|
||||
00
|
||||
00
|
||||
00
|
||||
ff
|
||||
ff
|
||||
ff
|
||||
ff
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
6b
|
||||
01
|
||||
00
|
||||
00
|
||||
01
|
||||
00
|
||||
00
|
||||
00
|
||||
fe
|
||||
ff
|
||||
ff
|
||||
ff
|
||||
88
|
||||
13
|
||||
00
|
||||
00
|
||||
74
|
||||
01
|
||||
00
|
||||
00
|
||||
06
|
||||
00
|
||||
00
|
||||
00
|
||||
01
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
79
|
||||
01
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
02
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
7d
|
||||
01
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
03
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
81
|
||||
01
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
04
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
85
|
||||
01
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
04
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
89
|
||||
01
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
03
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
8e
|
||||
01
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
fe
|
||||
ff
|
||||
ff
|
||||
ff
|
||||
a0
|
||||
0f
|
||||
00
|
||||
00
|
||||
93
|
||||
01
|
||||
00
|
||||
00
|
||||
04
|
||||
00
|
||||
00
|
||||
00
|
||||
2e
|
||||
74
|
||||
65
|
||||
78
|
||||
74
|
||||
00
|
||||
76
|
||||
61
|
||||
72
|
||||
34
|
||||
00
|
||||
66
|
||||
61
|
||||
72
|
||||
6c
|
||||
61
|
||||
62
|
||||
65
|
||||
6c
|
||||
00
|
||||
65
|
||||
71
|
||||
75
|
||||
32
|
||||
00
|
||||
66
|
||||
6f
|
||||
6f
|
||||
00
|
||||
62
|
||||
61
|
||||
72
|
||||
00
|
||||
62
|
||||
61
|
||||
7a
|
||||
00
|
||||
62
|
||||
73
|
||||
73
|
||||
00
|
||||
76
|
||||
61
|
||||
72
|
||||
33
|
||||
00
|
||||
76
|
||||
61
|
||||
72
|
||||
32
|
||||
00
|
||||
65
|
||||
71
|
||||
75
|
||||
31
|
||||
00
|
||||
66
|
||||
b8
|
||||
00
|
||||
00
|
||||
8e
|
||||
d8
|
||||
66
|
||||
a1
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
66
|
||||
b8
|
||||
00
|
||||
00
|
||||
8e
|
||||
c0
|
||||
26
|
||||
66
|
||||
a1
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
02
|
||||
00
|
||||
00
|
||||
00
|
||||
05
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
01
|
||||
02
|
||||
00
|
||||
00
|
||||
08
|
||||
00
|
||||
00
|
||||
00
|
||||
09
|
||||
00
|
||||
00
|
||||
00
|
||||
05
|
||||
00
|
||||
00
|
||||
00
|
||||
02
|
||||
04
|
||||
00
|
||||
00
|
||||
0e
|
||||
00
|
||||
00
|
||||
00
|
||||
01
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
08
|
||||
02
|
||||
00
|
||||
00
|
||||
15
|
||||
00
|
||||
00
|
||||
00
|
||||
01
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
01
|
||||
04
|
||||
00
|
||||
00
|
||||
ea
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
01
|
||||
00
|
||||
00
|
||||
00
|
||||
02
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
01
|
||||
04
|
||||
00
|
||||
00
|
||||
05
|
||||
00
|
||||
00
|
||||
00
|
||||
02
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
00
|
||||
08
|
||||
02
|
||||
00
|
||||
00
|
||||
02
|
||||
00
|
||||
178
modules/objfmts/xdf/tests/xdfprotect.asm
Normal file
178
modules/objfmts/xdf/tests/xdfprotect.asm
Normal file
|
|
@ -0,0 +1,178 @@
|
|||
;; ########################################################################
|
||||
;; Macros
|
||||
;; ########################################################################
|
||||
|
||||
; descriptor type, base, limit, p_dpl_s, g_db_a
|
||||
%macro descriptor 5
|
||||
dw (%3 & 0xFFFF) ; Limit 0-15
|
||||
dw (%2 & 0xFFFF) ; Base 0-15
|
||||
db ((%2 & 0xFF0000) >> 16) ; Base 16-23
|
||||
db ((%4 & 0xF) << 4) | (%1 & 0xF ) ; p_dpl_s_type
|
||||
db (%5 << 4) | ((%3 & 0xF0000) >> 16) ; g_db_a limit 19:16
|
||||
db ((%2 & 0xFF000000) >> 24) ; Base 24-31
|
||||
%endmacro
|
||||
|
||||
; cdesc32 base, limit, dpl
|
||||
%macro cdesc32 3
|
||||
descriptor 0xB, %1, %2, 0x9 | (%3 & 0x3) << 1, 0xD
|
||||
%endmacro
|
||||
|
||||
; ddesc32 base, limit, dpl
|
||||
%macro ddesc32 3
|
||||
descriptor 0x3, %1, %2, 0x9 | (%3 & 0x3) << 1, 0xD
|
||||
%endmacro
|
||||
|
||||
; gates type, offset, selector, p_dpl_s
|
||||
%macro gates 4
|
||||
dw %2 ; Offset 0-15
|
||||
dw (%3 & 0xFFFF) ; Selector 0-15
|
||||
db 0 ; Reserved
|
||||
db ((%4 & 0xF) << 4) | (%1 & 0xF) ; p_dpl_s_type
|
||||
dw 0 ; Offset 16-31
|
||||
%endmacro
|
||||
|
||||
%macro idesc32 3
|
||||
gates 0xE, %1, %2, 0x8 | ((%3 & 0x3) << 1)
|
||||
%endmacro
|
||||
|
||||
|
||||
;; ########################################################################
|
||||
;; Code Section
|
||||
;; ########################################################################
|
||||
|
||||
SECTION CODE ABSOLUTE=0x00400000 FLAT USE32
|
||||
|
||||
test_code:
|
||||
|
||||
;; Your Code Goes Here
|
||||
hlt
|
||||
|
||||
;; ########################################################################
|
||||
;; Setup Section
|
||||
;; ########################################################################
|
||||
|
||||
SECTION SETUP ALIGN=16 FLAT USE16
|
||||
|
||||
setup:
|
||||
|
||||
mov edx, cr0
|
||||
or dl, 0x21 ; Protect Mode On, Int 16 for FPU
|
||||
and edx, 0x9FFFFFFF ; Turn Caches on
|
||||
mov cr0, edx
|
||||
|
||||
xor edx, edx ; Enable Var MTRRs
|
||||
mov eax, 0x0806 ; WriteBack
|
||||
mov ecx, 0x2FF
|
||||
wrmsr
|
||||
|
||||
lgdt [pgdt] ; Set GDT
|
||||
lidt [pidt] ; Set IDT
|
||||
|
||||
jmp 0x8:protect_mode
|
||||
|
||||
protect_mode:
|
||||
|
||||
BITS 32
|
||||
|
||||
mov esp, 0x01000000 ; Get some stack space
|
||||
mov ax, 0x0010 ; Set data selectors
|
||||
mov ss, ax
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
mov fs, ax
|
||||
mov gs, ax
|
||||
|
||||
jmp test_code ; Jmp to test code
|
||||
|
||||
;; ########################################################################
|
||||
;; Protect Mode IDT
|
||||
;; ########################################################################
|
||||
|
||||
SECTION IDTP ALIGN=16 FLAT USE32
|
||||
|
||||
;; cdesc32 base, limit, dpl
|
||||
gdt0: dq 0.0 ; 0x0000 - Null descriptor
|
||||
cdesc32 0x00000000, 0xFFFFF, 0 ; 0x0008 - Code Selector
|
||||
ddesc32 0x00000000, 0xFFFFF, 0 ; 0x0010 - Data Selector
|
||||
cdesc32 0x00000000, 0xFFFFF, 3 ; 0x0018 - Code Select Ring 3
|
||||
ddesc32 0x00000000, 0xFFFFF, 3 ; 0x0020 - Data Select Ring 3
|
||||
|
||||
;; idesc32 offset, selector, dpl
|
||||
idt0: idesc32 isrP, 0x0008, 0 ; 0x00, 0 #DE, Divide Error
|
||||
idesc32 isrP, 0x0008, 0 ; 0x01, 1 #DB, Debug Fault
|
||||
idesc32 isrP, 0x0008, 0 ; 0x02, 2, ---, NMI
|
||||
idesc32 isrP, 0x0008, 0 ; 0x03, 3, #BP, Breakpoint
|
||||
idesc32 isrP, 0x0008, 0 ; 0x04, 4, #OF, INTO detected Overflow
|
||||
idesc32 isrP, 0x0008, 0 ; 0x05, 5, #BR, Bound Range Exceeded
|
||||
idesc32 isrP, 0x0008, 0 ; 0x06, 6, #UD, Invalid Opcode
|
||||
idesc32 isrP, 0x0008, 0 ; 0x07, 7, #NM, Device Not Available
|
||||
idesc32 isrP, 0x0008, 0 ; 0x08, 8, #DF, Double Fault
|
||||
idesc32 isrP, 0x0008, 0 ; 0x09 9, ---, Coprocessor Segment Overrun
|
||||
idesc32 isrP, 0x0008, 0 ; 0x0A, 10, #TS, Invalid TSS
|
||||
idesc32 isrP, 0x0008, 0 ; 0x0B, 11, #NP, Segment Not Present
|
||||
idesc32 isrP, 0x0008, 0 ; 0x0C, 12, #SS, Stack Fault
|
||||
idesc32 isrP, 0x0008, 0 ; 0x0D, 13, #GP, General Protection Fault
|
||||
idesc32 isrP, 0x0008, 0 ; 0x0E, 14, #PF, Page Fault
|
||||
idesc32 isrP, 0x0008, 0 ; 0x0F, 15, ---, Reserved
|
||||
idesc32 isrP, 0x0008, 0 ; 0x10, 16, #MF, Floating Point Fault
|
||||
idesc32 isrP, 0x0008, 0 ; 0x11, 17, #AC, Alignment Check
|
||||
idesc32 isrP, 0x0008, 0 ; 0x12 18, #MC, Machine Check
|
||||
idesc32 isrP, 0x0008, 0 ; 0x13, 19, #XF, SSE Fault
|
||||
|
||||
pgdt: dw 6 * 8 ; Limit
|
||||
dd gdt0 ; base
|
||||
|
||||
pidt: dw 20 * 8 ; Limit
|
||||
dd idt0 ; base
|
||||
|
||||
isrP: mov eax, 0xDEADBEEF ; Default Real Mode Interrupt Handler
|
||||
out 0x80, eax
|
||||
hlt
|
||||
|
||||
;; ########################################################################
|
||||
;; Real Mode IDT
|
||||
;; ########################################################################
|
||||
|
||||
SECTION IDTR ABSOLUTE=0x00000000 FLAT USE16
|
||||
|
||||
;; FORMAT IP:CS
|
||||
dw isrR, 0 ; 0x00, 0 #DE, Divide Error
|
||||
dw isrR, 0 ; 0x01, 1 #DB, Debug Fault
|
||||
dw isrR, 0 ; 0x02, 2, ---, NMI
|
||||
dw isrR, 0 ; 0x03, 3, #BP, Breakpoint
|
||||
dw isrR, 0 ; 0x04, 4, #OF, INTO detected Overflow
|
||||
dw isrR, 0 ; 0x05, 5, #BR, Bound Range Exceeded
|
||||
dw isrR, 0 ; 0x06, 6, #UD, Invalid Opcode
|
||||
dw isrR, 0 ; 0x07, 7, #NM, Device Not Available
|
||||
dw isrR, 0 ; 0x08, 8, #DF, Double Fault
|
||||
dw isrR, 0 ; 0x09 9, ---, Coprocessor Segment Overrun
|
||||
dw isrR, 0 ; 0x0A, 10, #TS, Invalid TSS
|
||||
dw isrR, 0 ; 0x0B, 11, #NP, Segment Not Present
|
||||
dw isrR, 0 ; 0x0C, 12, #SS, Stack Fault
|
||||
dw isrR, 0 ; 0x0D, 13, #GP, General Protection Fault
|
||||
dw isrR, 0 ; 0x0E, 14, #PF, Page Fault
|
||||
dw isrR, 0 ; 0x0F, 15, ---, Reserved
|
||||
dw isrR, 0 ; 0x10, 16, #MF, Floating Point Fault
|
||||
dw isrR, 0 ; 0x11, 17, #AC, Alignment Check
|
||||
dw isrR, 0 ; 0x12 18, #MC, Machine Check
|
||||
dw isrR, 0 ; 0x13, 19, #XF, SSE Fault
|
||||
|
||||
isrR: mov eax, 0xDEADBEEF ; Default Real Mode Interrupt Handler
|
||||
out 0x80, eax
|
||||
hlt
|
||||
|
||||
;; ########################################################################
|
||||
;; SMM Handler
|
||||
;; ########################################################################
|
||||
|
||||
SECTION SMM ABSOLUTE=0x00038000 USE16
|
||||
|
||||
rsm
|
||||
|
||||
;; ########################################################################
|
||||
;; Reset Vector
|
||||
;; ########################################################################
|
||||
|
||||
SECTION RESET ABSOLUTE=0xFFFFFFF0 USE16
|
||||
|
||||
jmp far setup
|
||||
0
modules/objfmts/xdf/tests/xdfprotect.errwarn
Normal file
0
modules/objfmts/xdf/tests/xdfprotect.errwarn
Normal file
1750
modules/objfmts/xdf/tests/xdfprotect.hex
Normal file
1750
modules/objfmts/xdf/tests/xdfprotect.hex
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -49,11 +49,10 @@ typedef struct xdf_reloc {
|
|||
yasm_symrec *sym; /* relocated symbol */
|
||||
/*@null@*/ yasm_symrec *base; /* base symbol (for WRT) */
|
||||
enum {
|
||||
XDF_RELOC_FLAT = 1, /* relative to 0 */
|
||||
XDF_RELOC_REL = 2, /* relative to segment */
|
||||
XDF_RELOC_WRT = 4, /* relative to symbol */
|
||||
XDF_RELOC_RIP = 8, /* RIP-relative */
|
||||
XDF_RELOC_SEG = 16 /* segment containing symbol */
|
||||
XDF_RELOC_REL = 1, /* relative to segment */
|
||||
XDF_RELOC_WRT = 2, /* relative to symbol */
|
||||
XDF_RELOC_RIP = 4, /* RIP-relative */
|
||||
XDF_RELOC_SEG = 8 /* segment containing symbol */
|
||||
} type; /* type of relocation */
|
||||
enum {
|
||||
XDF_RELOC_8 = 1,
|
||||
|
|
@ -281,9 +280,7 @@ xdf_objfmt_output_expr(yasm_expr **ep, unsigned char *buf, size_t destsize,
|
|||
yasm_section_bcs_first(info->sect), 0, (*ep)->line)),
|
||||
(*ep)->line);
|
||||
*ep = yasm_expr_simplify(*ep, yasm_common_calc_bc_dist);
|
||||
} else if (info->xsd->flags & XDF_SECT_FLAT)
|
||||
reloc->type = XDF_RELOC_FLAT;
|
||||
else
|
||||
} else
|
||||
reloc->type = XDF_RELOC_REL;
|
||||
info->xsd->nreloc++;
|
||||
STAILQ_INSERT_TAIL(&info->xsd->relocs, reloc, link);
|
||||
|
|
@ -820,9 +817,6 @@ xdf_section_data_print(void *data, FILE *f, int indent_level)
|
|||
yasm_symrec_print(reloc->sym, f, indent_level+3);
|
||||
fprintf(f, "%*stype=", indent_level+2, "");
|
||||
switch (reloc->type) {
|
||||
case XDF_RELOC_FLAT:
|
||||
printf("Flat");
|
||||
break;
|
||||
case XDF_RELOC_REL:
|
||||
printf("Rel");
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* XDF - Extended Dynamic Object Format */
|
||||
/* Version 1.3 */
|
||||
/* Version 1.4 */
|
||||
/* $Id$ */
|
||||
|
||||
/* FILE HEADER */
|
||||
|
|
@ -52,11 +52,10 @@ typedef enum {
|
|||
|
||||
typedef enum {
|
||||
|
||||
XDF_RELOC_FLAT = 1, /* DISP = ADDRESS - 0 (Relative to 0) */
|
||||
XDF_RELOC_REL = 2, /* DISP = ADDRESS - SEGMENT (Relative to a segment) */
|
||||
XDF_RELOC_WRT = 4, /* DISP = ADDRESS - SYMBOL (Relative to a symbol) */
|
||||
XDF_RELOC_RIP = 8, /* DISP = ADDRESS - RIP - RELOC_SIZE (Relative to end of an instruction) */
|
||||
XDF_RELOC_SEG = 16, /* DISP = SEGMENT/SELECTOR OF SYMBOL (Not symbol itself, but which segment it's in) */
|
||||
XDF_RELOC_REL = 1, /* DISP = ADDRESS - SEGMENT (Relative to a segment) */
|
||||
XDF_RELOC_WRT = 2, /* DISP = ADDRESS - SYMBOL (Relative to a symbol) */
|
||||
XDF_RELOC_RIP = 4, /* DISP = ADDRESS - RIP - RELOC_SIZE (Relative to end of an instruction) */
|
||||
XDF_RELOC_SEG = 8, /* DISP = SEGMENT/SELECTOR OF SYMBOL (Not symbol itself, but which segment it's in) */
|
||||
|
||||
} xdf_rtype;
|
||||
|
||||
|
|
|
|||
|
|
@ -101,9 +101,6 @@ print_reloc(const RELOCATION_ENTRY *relocent, FILE *f, size_t symtab_off)
|
|||
{
|
||||
const char *type = "UNK";
|
||||
switch (relocent->r_type) {
|
||||
case XDF_RELOC_FLAT:
|
||||
type = "FLT";
|
||||
break;
|
||||
case XDF_RELOC_REL:
|
||||
type = "REL";
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue