Added relocation support and did my best to do work w/ them
This commit is contained in:
parent
d5d02f8b5b
commit
318cd6adab
11 changed files with 30 additions and 16 deletions
|
@ -5,7 +5,7 @@ SRCS = $(shell find . -name '*.[cS]')
|
|||
OBJS = $(addsuffix .o,$(basename $(SRCS)))
|
||||
ASFLAGS =
|
||||
CFLAGS += -I. -fno-stack-protector -nostdinc -ffreestanding -std=c11 -fno-builtin -w -Werror -nostdlib -fpie
|
||||
LDFLAGS += -T loader.ld
|
||||
LDFLAGS = -T loader.ld
|
||||
all: $(OBJS)
|
||||
$(LD) $(LDFLAGS) -o loader.elf $(OBJS) -L$(HOME)/opt/lib/gcc/$(libpath)/6.1.0/ -lgcc
|
||||
objcopy -O binary loader.elf loader.bin
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "sdmmc.h"
|
||||
#include "fatfs/ff.h"
|
||||
char *lfb=(char*)0x18346500;
|
||||
#ifndef ARM9
|
||||
#ifdef ARM9
|
||||
#define DIAGPXL(i) (lfb[6*(i)]=lfb[6*(i)+1]=lfb[6*(i)+2]=0xFF)
|
||||
#else
|
||||
#define DIAGPXL(i) (0)
|
||||
|
@ -75,6 +75,8 @@ void init() {
|
|||
f_open(&dsp_txt9, "dsp_txt.neun", FA_READ | FA_OPEN_EXISTING);
|
||||
f_read(&dsp_txt9, (void*)off, f_size(&dsp_txt9), &br);
|
||||
off+=f_size(&dsp_txt9);
|
||||
off&=~0xfff;
|
||||
off+=0x1000;
|
||||
FIL dsp_txt11;
|
||||
arm11modtable[0]=off;
|
||||
arm11modtable[1]=0;
|
||||
|
|
|
@ -5,7 +5,7 @@ SRCS = $(shell find . -name '*.[cS]')
|
|||
OBJS = $(addsuffix .o,$(basename $(SRCS)))
|
||||
ASFLAGS +=
|
||||
CFLAGS += -fno-stack-protector -nostdinc -ffreestanding -std=c11 -fno-builtin -w -Werror -nostdlib -fpie
|
||||
LDFLAGS += -T loader.ld
|
||||
LDFLAGS = -T loader.ld
|
||||
all: $(OBJS)
|
||||
$(LD) $(LDFLAGS) -o loader.bin $(OBJS)
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ SRCS = $(shell find . -name '*.[cS]')
|
|||
OBJS = $(addsuffix .o,$(basename $(SRCS)))
|
||||
ASFLAGS =
|
||||
CFLAGS += -fno-stack-protector -nostdinc -ffreestanding -std=c11 -fno-builtin -w -Werror -nostdlib -fpie
|
||||
LDFLAGS += -T loader.ld
|
||||
LDFLAGS = -T loader.ld
|
||||
all: $(OBJS)
|
||||
$(LD) $(LDFLAGS) -o loader.bin $(OBJS)
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ arch = 3ds
|
|||
subvar = 9
|
||||
MODE = debug
|
||||
export PATH := $(HOME)/opt/bin:$(PATH)
|
||||
LDFLAGS =
|
||||
LDFLAGS = -fPIC
|
||||
ifeq ($(arch),x86)
|
||||
PREFIX = i686-mtgos-
|
||||
libpath = i686-mtgos
|
||||
|
@ -37,5 +37,5 @@ else
|
|||
CPPFLAGS := -O2
|
||||
endif
|
||||
ASFLAGS += $(ARCHFLAGS)
|
||||
CFLAGS += $(ARCHFLAGS)
|
||||
CPPFLAGS += $(ARCHFLAGS)
|
||||
CFLAGS += -fPIC $(ARCHFLAGS)
|
||||
CPPFLAGS += -fPIC $(ARCHFLAGS)
|
||||
|
|
|
@ -68,12 +68,19 @@ extern "C" void _start(void ** modtable) {
|
|||
break;
|
||||
DIAGPXL(15);
|
||||
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)
|
||||
continue;
|
||||
DIAGPXL(17);
|
||||
void(**table)()=fptr(modtable[i]);
|
||||
DIAGPXL(18);
|
||||
table=(void(**)())((unsigned int)table+(unsigned int)modtable[i]+0x1000);
|
||||
unsigned int* tbl=(unsigned int*)table;
|
||||
tbl[0]+=(unsigned int)modtable[i]+0x1000;
|
||||
debugNumber((unsigned int)table[0],50+32);
|
||||
ModType type=((getType_type)table[0])(); //Get module type
|
||||
DIAGPXL(19);
|
||||
if(type!=ModType::output_text)
|
||||
|
|
|
@ -103,7 +103,7 @@ private:
|
|||
void(*tbl[3])()={(void(*)())&getType,(void(*)())&size_of,(void(*)())&spawnAt};
|
||||
table_type getTable() {
|
||||
x=y=0;
|
||||
doCtors();
|
||||
// doCtors();
|
||||
DIAGPXL(23);
|
||||
return (table_type)&tbl;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ OUTPUT_FORMAT(elf32-littlearm)
|
|||
OUTPUT_ARCH(arm)
|
||||
SECTIONS
|
||||
{
|
||||
. = 0x20010000;
|
||||
. = 0;
|
||||
module_start = .;
|
||||
.text : {
|
||||
*(.text)
|
||||
|
@ -28,6 +28,9 @@ SECTIONS
|
|||
*(.bss)
|
||||
*(COMMON)
|
||||
}
|
||||
.plt : {
|
||||
*(.plt)
|
||||
}
|
||||
.rel.plt : {
|
||||
*(.rel.plt)
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
2
out
Normal file
2
out
Normal file
|
@ -0,0 +1,2 @@
|
|||
Ny41TQkvdXNyL2xvY2FsL2xpYmV4ZWMvZ2NjNDgvZ2NjL3g4Nl82NC1wb3J0Ymxk
|
||||
LWZyZWVic2QxMS4wLzQuOC41L2NjMXBsdXMK
|
Loading…
Reference in a new issue