actually working x86 relocations
This commit is contained in:
parent
04f7a213b1
commit
4694d6f490
7 changed files with 31 additions and 17 deletions
|
@ -8,7 +8,6 @@ typedef unsigned short uint16_t;
|
||||||
typedef unsigned int uint32_t;
|
typedef unsigned int uint32_t;
|
||||||
typedef unsigned long long int uint64_t;
|
typedef unsigned long long int uint64_t;
|
||||||
typedef unsigned int uintptr_t;
|
typedef unsigned int uintptr_t;
|
||||||
typedef unsigned int size_t;
|
|
||||||
#else
|
#else
|
||||||
typedef signed char int8_t;
|
typedef signed char int8_t;
|
||||||
typedef signed short int16_t;
|
typedef signed short int16_t;
|
||||||
|
@ -19,5 +18,5 @@ typedef unsigned short uint16_t;
|
||||||
typedef unsigned int uint32_t;
|
typedef unsigned int uint32_t;
|
||||||
typedef unsigned long int uint64_t;
|
typedef unsigned long int uint64_t;
|
||||||
typedef unsigned long int uintptr_t;
|
typedef unsigned long int uintptr_t;
|
||||||
typedef unsigned long int size_t;
|
|
||||||
#endif
|
#endif
|
||||||
|
typedef __SIZE_TYPE__ size_t;
|
|
@ -1,4 +1,4 @@
|
||||||
arch = 3ds
|
arch = x86
|
||||||
subvar = 9
|
subvar = 9
|
||||||
MODE = debug
|
MODE = debug
|
||||||
export PATH := $(HOME)/opt/bin:$(PATH)
|
export PATH := $(HOME)/opt/bin:$(PATH)
|
||||||
|
|
|
@ -54,6 +54,12 @@ void debugNumber(unsigned int i, int start) {
|
||||||
start++;
|
start++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void adjustVTable(unsigned int** obj, unsigned int mod, int vtableSize) {
|
||||||
|
mod+=0x1000;
|
||||||
|
for(int i=0;i<vtableSize;i++) {
|
||||||
|
(*obj)[i]+=mod;
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* \function _start()
|
* \function _start()
|
||||||
* \brief Initializes the kernel
|
* \brief Initializes the kernel
|
||||||
|
@ -68,19 +74,21 @@ extern "C" void _start(void ** modtable) {
|
||||||
break;
|
break;
|
||||||
DIAGPXL(15);
|
DIAGPXL(15);
|
||||||
void(**(*fptr)(void*))() = load((Elf_Ehdr*) modtable[i]);
|
void(**(*fptr)(void*))() = load((Elf_Ehdr*) modtable[i]);
|
||||||
fptr=(void(**(*)(void*))())((unsigned int)fptr-8);
|
|
||||||
DIAGPXL(16);
|
|
||||||
debugNumber((unsigned int)fptr,50);
|
|
||||||
// debugNumber((unsigned int)modtable[i],50+32);
|
|
||||||
if(!fptr)
|
if(!fptr)
|
||||||
continue;
|
continue;
|
||||||
|
// fptr=(void(**(*)(void*))())((unsigned int)fptr-8);
|
||||||
|
DIAGPXL(16);
|
||||||
|
debugNumber((unsigned int)fptr,50);
|
||||||
|
// debugNumber((unsigned int)modtable[i],50+32);
|
||||||
DIAGPXL(17);
|
DIAGPXL(17);
|
||||||
void(**table)()=fptr(modtable[i]);
|
void(**table)()=fptr(modtable[i]);
|
||||||
DIAGPXL(18);
|
DIAGPXL(18);
|
||||||
table=(void(**)())((unsigned int)table+(unsigned int)modtable[i]+0x1000);
|
table=(void(**)())((unsigned int)table+(unsigned int)modtable[i]+0x1000);
|
||||||
unsigned int* tbl=(unsigned int*)table;
|
unsigned int* tbl=(unsigned int*)table;
|
||||||
tbl[0]+=(unsigned int)modtable[i]+0x1000;
|
tbl[0]+=(unsigned int)modtable[i]+0x1000;
|
||||||
debugNumber((unsigned int)table[0],50+32);
|
tbl[1]+=(unsigned int)modtable[i]+0x1000;
|
||||||
|
tbl[2]+=(unsigned int)modtable[i]+0x1000;
|
||||||
|
debugNumber((unsigned int)table[0],50+32);
|
||||||
ModType type=((getType_type)table[0])(); //Get module type
|
ModType type=((getType_type)table[0])(); //Get module type
|
||||||
DIAGPXL(19);
|
DIAGPXL(19);
|
||||||
if(type!=ModType::output_text)
|
if(type!=ModType::output_text)
|
||||||
|
@ -90,12 +98,15 @@ extern "C" void _start(void ** modtable) {
|
||||||
DIAGPXL(21);
|
DIAGPXL(21);
|
||||||
((spawnAt_type)table[2])((void*)&out);
|
((spawnAt_type)table[2])((void*)&out);
|
||||||
DIAGPXL(22);
|
DIAGPXL(22);
|
||||||
|
adjustVTable((unsigned int**) &out, (unsigned int)modtable[i], 1);
|
||||||
out << "HI!\nbye!\n";
|
out << "HI!\nbye!\n";
|
||||||
#ifdef ARM9
|
#ifdef ARM9
|
||||||
out << "Here arm9!\n";
|
out << "Here arm9!\n";
|
||||||
#else
|
#else
|
||||||
out << "Here arm11!\n";
|
out << "Here arm11!\n";
|
||||||
#endif
|
#endif
|
||||||
|
char* x=(char*)0xB80000;
|
||||||
|
x[0]='H';
|
||||||
}
|
}
|
||||||
for(void(**i)()=&start_dtors;i<&end_dtors;i++)
|
for(void(**i)()=&start_dtors;i<&end_dtors;i++)
|
||||||
(*i)(); //Calling destructors
|
(*i)(); //Calling destructors
|
||||||
|
|
|
@ -6,8 +6,8 @@ CPP = $(PREFIX)g++
|
||||||
CC = $(PREFIX)gcc
|
CC = $(PREFIX)gcc
|
||||||
LD = $(PREFIX)g++
|
LD = $(PREFIX)g++
|
||||||
|
|
||||||
CFLAGS += -Wall -fno-stack-protector -nostdinc -Ic_include/ -I../../../../c_include -ffreestanding -std=c11 -fno-builtin -Werror -nostdlib -g -fpic
|
CFLAGS += -Wall -fno-stack-protector -nostdinc -Ic_include/ -I../../../../c_include -ffreestanding -std=c11 -fno-builtin -Werror -nostdlib -g -fPIC -pie
|
||||||
CPPFLAGS += -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -I../../../../c_include -I../../../../include -fno-rtti -fno-exceptions -ffreestanding -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fpic -Wno-reorder -fdump-class-hierarchy
|
CPPFLAGS += -Wall -fno-stack-protector -nostdinc -std=c++14 -Iinclude/ -Ic_include/ -I../../../../c_include -I../../../../include -fno-rtti -fno-exceptions -ffreestanding -fno-builtin -Werror -nostdlib -fno-use-cxa-atexit -Wextra -Wno-unused -g -fPIC -pie -Wno-reorder -fdump-class-hierarchy
|
||||||
LDFLAGS += -nostdlib -nodefaultlibs -nostdlib -fno-builtin -T ../../link.ld
|
LDFLAGS += -nostdlib -nodefaultlibs -nostdlib -fno-builtin -T ../../link.ld
|
||||||
all: $(OBJS)
|
all: $(OBJS)
|
||||||
$(LD) $(LDFLAGS) -o ../../../../dsp_txt.elf $(OBJS) -lgcc
|
$(LD) $(LDFLAGS) -o ../../../../dsp_txt.elf $(OBJS) -lgcc
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace {
|
||||||
*/
|
*/
|
||||||
class Screen: public Base::Output {
|
class Screen: public Base::Output {
|
||||||
public:
|
public:
|
||||||
Screen() {}
|
Screen() {x=0;y=0;vmem = (uint16_t*)0xB8000;}
|
||||||
auto scroll() -> void {
|
auto scroll() -> void {
|
||||||
for(int p=0;p<80*25;p++)
|
for(int p=0;p<80*25;p++)
|
||||||
vmem[p]=vmem[p+80];
|
vmem[p]=vmem[p+80];
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
ENTRY(getTable)
|
ENTRY(getTable)
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
. = 0x106000;
|
. = /*0x106000;*/0;
|
||||||
module_start = .;
|
module_start = .;
|
||||||
.text : {
|
.text : {
|
||||||
*(.text)
|
*(.text)
|
||||||
|
@ -18,6 +18,10 @@ SECTIONS
|
||||||
*(.data.*)
|
*(.data.*)
|
||||||
*(.rodata)
|
*(.rodata)
|
||||||
*(.bss)
|
*(.bss)
|
||||||
|
*(COMMON)
|
||||||
|
*(.plt)
|
||||||
|
*(.rel.plt)
|
||||||
|
*(.rel.dyn)
|
||||||
}
|
}
|
||||||
module_end = .;
|
module_end = .;
|
||||||
}
|
}
|
Binary file not shown.
Loading…
Reference in a new issue