Skip to content

Commit fe9f6bb

Browse files
exportacion de sym oka
1 parent 22820b9 commit fe9f6bb

15 files changed

Lines changed: 31 additions & 14 deletions

File tree

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,17 @@ $(UEFI_SYS): build ./obj/lib.o ./obj/efi.o
4747
$(LD) --oformat=elf64-x86-64 -T $(LD_DIR)/uefi.ld -o $(UEFI_ELF) $(UEFI_OBJ) $(OBJ_DIR)/lib.o $(OBJ_DIR)/efi.o
4848

4949
$(TSL_SYS): build $(TSL_OBJS_LO) $(TSL_OBJS_HI) ./obj/bios16.o ./obj/bios32.o
50-
$(LD) -T $(LD_DIR)/tsl.ld -o $@ $(TSL_OBJS_LO) $(TSL_OBJS_HI) $(OBJ_DIR)/lib.o $(OBJ_DIR)/bios16.o $(OBJ_DIR)/bios32.o
51-
$(LD) --oformat=elf64-x86-64 -T $(LD_DIR)/tsl.ld -o $(TSL_ELF_LO) $(TSL_OBJS_LO) $(TSL_OBJS_HI) $(OBJ_DIR)/lib.o $(OBJ_DIR)/bios16.o $(OBJ_DIR)/bios32.o
50+
$(LD) -T $(LD_DIR)/tsl.ld -o $@ $(TSL_OBJS_LO) $(TSL_OBJS_HI) $(OBJ_DIR)/lib.o $(OBJ_DIR)/bios16.o $(OBJ_DIR)/bios32.o $(OBJ_DIR)/mbr_symbols.o
51+
$(LD) --oformat=elf64-x86-64 -T $(LD_DIR)/tsl.ld -o $(TSL_ELF_LO) $(TSL_OBJS_LO) $(TSL_OBJS_HI) $(OBJ_DIR)/lib.o $(OBJ_DIR)/bios16.o $(OBJ_DIR)/bios32.o $(OBJ_DIR)/mbr_symbols.o
5252
$(LD) --oformat=elf64-x86-64 -T $(LD_DIR)/tsl_hi.ld -o $(TSL_ELF_HI) $(TSL_OBJS_HI) $(OBJ_DIR)/lib.o
5353

5454
mbr: build
5555
$(ASM) -g -F DWARF -f elf64 ./asm/bios/mbr.asm -o $(OBJ_DIR)/mbr.o
5656
$(LD) -T $(LD_DIR)/mbr.ld -o ./out/mbr.sys $(OBJ_DIR)/mbr.o
5757
$(LD) --oformat=elf64-x86-64 -T $(LD_DIR)/mbr.ld -o ./elf/mbr.elf $(OBJ_DIR)/mbr.o
58+
$(LD) -r --just-symbols=./elf/mbr.elf -o $(OBJ_DIR)/mbr_symbols.o
59+
#--retain-symbols-file exported_symbols.txt
60+
#nm --defined-only --extern-only ./elf/mbr.elf | awk '{print "PROVIDE(", $$3, " = ", $$1, ");"}' > ./asm/include/mbr_symbols.inc
5861

5962
start16: build
6063
$(ASM) -g -F DWARF -f elf64 ./asm/bios/start16.asm -o $(OBJ_DIR)/start16.o

TO-DO.rm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
-- pasar todo lo que se pueda de start32 a /lib/bios.asm
44

5+
-- evaluar si de uefi puedo reutilizar las funciones de print, que duplique, ahora hacer exportacion de simbolos y ver cuando no se pisa la memoria.
6+
57
-- no le estoy apuntando vien a pasar el flag de step mode al inicio de uefi.
68

79
-- corregir que start16 se carga en 0x7e00 y no en 8000 (ver tsl.ld).

asm/bios/mbr.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
%include "./asm/include/mbr.inc"
3131
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;%include "./asm/include/sysvar.inc"
3232

33-
;;global print_bios ;; Export symbol so to use this print function in start16.asm.
33+
global print_bios ;; Export symbol so to use this print function in start16.asm.
3434

3535

3636
section .text

asm/include/mbr_symbols.inc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
PROVIDE( mbr_code_end_reloc_aligned = 0000000000007d90 );
2+
PROVIDE( mbr_code_load = 0000000000000000 );
3+
PROVIDE( mbr_code_reloc = 0000000000007c00 );
4+
PROVIDE( mbr_code_size_aligned = 0000000000000190 );
5+
PROVIDE( mbr_data_start_load = 0000000000000190 );
6+
PROVIDE( mbr_data_start_reloc_aligned = 0000000000007d90 );
7+
PROVIDE( print_bios = 0000000000007ccd );

asm/lib/bios16.asm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44

55
%include "./asm/include/sysvar.inc"
66

7+
;; mbr.asm
78
;; TO-DO: print_bios reponer el address correcto.
89
extern print_bios
9-
print_bios: equ 0
10+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;print_bios: equ 0
1011

1112
global vesa
12-
global failure
13+
;;;;;;;;;;;;;;;;;;;;;;;;;global failure
1314

1415

1516
section .text_low
@@ -79,3 +80,4 @@ failure:
7980

8081

8182
msg_halt: db "System halted", 0
83+
x: dq print_bios

build/tsl.sys

0 Bytes
Binary file not shown.

elf/mbr.elf

24 Bytes
Binary file not shown.

elf/tsl_lo.elf

296 Bytes
Binary file not shown.

ldScript/mbr.ld

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1+
/* En este ld script es importante mantener diferenciados con el prefijo "mbr_"
2+
* los simbolos code_end, code_size, etc porque todos los simbolos de mbr son ex
3+
* portados ya que se usan en la linkedicion de tsl.sys */
4+
15
OUTPUT_FORMAT("binary")
26

37
SECTIONS {
48

5-
code_reloc = 0x7c00 ;
6-
code_load = 0x0000;
7-
.text code_reloc : AT (code_load) {
9+
mbr_code_reloc = 0x7c00 ;
10+
mbr_code_load = 0x0000;
11+
.text mbr_code_reloc : AT (mbr_code_load) {
812
./obj/mbr.o (.text)
913
}
1014

1115
. = ALIGN(0x10);
12-
code_end_reloc_aligned = . ;
13-
code_size_aligned = code_end_reloc_aligned - code_reloc;
14-
data_start_reloc_aligned = . ;
15-
data_start_load = code_load + code_size_aligned;
16-
.data data_start_reloc_aligned : AT (data_start_load) {
16+
mbr_code_end_reloc_aligned = . ;
17+
mbr_code_size_aligned = mbr_code_end_reloc_aligned - mbr_code_reloc;
18+
mbr_data_start_reloc_aligned = . ;
19+
mbr_data_start_load = mbr_code_load + mbr_code_size_aligned;
20+
.data mbr_data_start_reloc_aligned : AT (mbr_data_start_load) {
1721
./obj/mbr.o (.data)
1822
}
1923

ldScript/tsl.ld

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
OUTPUT_FORMAT("binary")
22

3-
/* TO-DO: generar simbolos ya realocados de mbr */
43
SECTIONS {
54

65
code_start16_reloc = 0x7e00;

0 commit comments

Comments
 (0)