mirror of
https://github.com/wiiu-env/wut.git
synced 2024-12-05 05:24:16 +01:00
Proper PIE for RPL.
This commit is contained in:
parent
5e69878ea7
commit
c2c9f05328
@ -15,7 +15,7 @@ endif
|
|||||||
include $(WUT_ROOT)/rules/ppc.mk
|
include $(WUT_ROOT)/rules/ppc.mk
|
||||||
|
|
||||||
LD := $(PREFIX)ld
|
LD := $(PREFIX)ld
|
||||||
RPLCFLAGS := -Wno-unused-variable -fPIC -fpic -fno-builtin
|
RPLCFLAGS := -Wno-unused-variable -fno-builtin
|
||||||
CFLAGS += -O2 -Wall -std=c11 $(RPLCFLAGS)
|
CFLAGS += -O2 -Wall -std=c11 $(RPLCFLAGS)
|
||||||
ODEPS := stub.o lib.o
|
ODEPS := stub.o lib.o
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
.section ".rplTramp.text","ax"; \
|
.section ".rplTramp.text","ax"; \
|
||||||
.global name; \
|
.global name; \
|
||||||
name: \
|
name: \
|
||||||
li %r0, 0; \
|
li %r0, name##_stub@l; \
|
||||||
oris %r0, %r0, 0; \
|
oris %r0, %r0, name##_stub@ha; \
|
||||||
mtctr %r0; \
|
mtctr %r0; \
|
||||||
bctr; \
|
bctr; \
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
LIBPATHS := -L$(WUT_ROOT)/lib
|
LIBPATHS := -L$(WUT_ROOT)/lib
|
||||||
CFLAGS := -I$(WUT_ROOT)/include -fno-builtin -ffreestanding
|
CFLAGS := -I$(WUT_ROOT)/include -fno-builtin -ffreestanding
|
||||||
CXXFLAGS := $(CFLAGS)
|
CXXFLAGS := $(CFLAGS)
|
||||||
LDFLAGS := -nostdlib -nostartfiles -T $(WUT_ROOT)/rules/rpl.ld
|
LDFLAGS := -nostdlib -nostartfiles
|
||||||
|
|
||||||
include $(WUT_ROOT)/rules/base.mk
|
include $(WUT_ROOT)/rules/base.mk
|
||||||
|
|
||||||
|
71
rules/rpl.ld
71
rules/rpl.ld
@ -4,19 +4,24 @@ OUTPUT_ARCH(powerpc:common)
|
|||||||
ENTRY(_start)
|
ENTRY(_start)
|
||||||
|
|
||||||
MEMORY {
|
MEMORY {
|
||||||
system (rw) : ORIGIN = 0x01000000, LENGTH = 32M
|
system (rwx) : ORIGIN = 0x01000000, LENGTH = 32M
|
||||||
code (rwx) : ORIGIN = 0x02000000, LENGTH = 224M
|
code (rwx) : ORIGIN = 0x02000000, LENGTH = 224M
|
||||||
data (rw) : ORIGIN = 0x10000000, LENGTH = 800M
|
data (rw) : ORIGIN = 0x10000000, LENGTH = 800M
|
||||||
|
load (rwx) : ORIGIN = 0xC0000000, LENGTH = 128M
|
||||||
}
|
}
|
||||||
|
|
||||||
PHDRS {
|
PHDRS {
|
||||||
|
hdr_text PT_LOAD FILEHDR PHDRS FLAGS(0x01 | 0x04);
|
||||||
|
hdr_data PT_LOAD FLAGS(0x02 | 0x04);
|
||||||
|
hdr_srodata PT_LOAD FLAGS(0x04);
|
||||||
|
hdr_sdata PT_LOAD FLAGS(0x02 | 0x04);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTIONS {
|
SECTIONS {
|
||||||
. = ORIGIN(code);
|
. = ORIGIN(code);
|
||||||
|
|
||||||
/* Standard code section */
|
/* Standard code section */
|
||||||
.text ALIGN(32) : { *(.text .stub .text.*) }
|
.text ALIGN(32) : { *(.text .stub .text.*) } : hdr_text
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Trampolines for each RPL function, have the same symbol name of
|
* Trampolines for each RPL function, have the same symbol name of
|
||||||
@ -42,7 +47,7 @@ SECTIONS {
|
|||||||
/*
|
/*
|
||||||
* Contains the name of RPLs, referenced by .lib.rplLibs
|
* Contains the name of RPLs, referenced by .lib.rplLibs
|
||||||
*/
|
*/
|
||||||
.rodata.rplNames ALIGN(32) : { KEEP (*(.rodata.rplNames)) }
|
.rodata.rplNames ALIGN(32) : { KEEP (*(.rodata.rplNames)) } : hdr_data
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List of RPL libraries to import, in format:
|
* List of RPL libraries to import, in format:
|
||||||
@ -57,10 +62,64 @@ SECTIONS {
|
|||||||
*/
|
*/
|
||||||
.data.rplFuncStubs ALIGN(32) : { KEEP (*(.data.rplFuncStubs)) }
|
.data.rplFuncStubs ALIGN(32) : { KEEP (*(.data.rplFuncStubs)) }
|
||||||
|
|
||||||
|
.interp ALIGN(32) : { *(.interp) }
|
||||||
|
.hash ALIGN(32) : { *(.hash) }
|
||||||
|
.dynsym ALIGN(32) : { *(.dynsym) }
|
||||||
|
.dynstr ALIGN(32) : { *(.dynstr) }
|
||||||
|
.rela.dyn ALIGN(32) : { *(.rela.dyn) }
|
||||||
|
.rela.text ALIGN(32) : { *(.rela.text) }
|
||||||
|
.eh_frame ALIGN(32) : { *(.eh_frame) }
|
||||||
|
.dynamic ALIGN(32) : { *(.dynamic) }
|
||||||
|
.got ALIGN(32) : { *(.got) }
|
||||||
|
.comment ALIGN(32) : { *(.comment) }
|
||||||
|
.shstrtab ALIGN(32) : { *(.shstrtab) }
|
||||||
|
.symtab ALIGN(32) : { *(.symtab) }
|
||||||
|
.strtab ALIGN(32) : { *(.strtab) }
|
||||||
|
|
||||||
|
.rel.dyn :
|
||||||
|
{
|
||||||
|
*(.rel.init)
|
||||||
|
*(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
|
||||||
|
*(.rel.fini)
|
||||||
|
*(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
|
||||||
|
*(.rel.data.rel.ro*)
|
||||||
|
*(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
|
||||||
|
*(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
|
||||||
|
*(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
|
||||||
|
*(.rel.ctors)
|
||||||
|
*(.rel.dtors)
|
||||||
|
*(.rel.got)
|
||||||
|
*(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*)
|
||||||
|
*(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*)
|
||||||
|
*(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*)
|
||||||
|
*(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*)
|
||||||
|
*(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
.rela.dyn :
|
||||||
|
{
|
||||||
|
*(.rela.init)
|
||||||
|
*(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
|
||||||
|
*(.rela.fini)
|
||||||
|
*(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
|
||||||
|
*(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
|
||||||
|
*(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
|
||||||
|
*(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
|
||||||
|
*(.rela.ctors)
|
||||||
|
*(.rela.dtors)
|
||||||
|
*(.rela.got)
|
||||||
|
*(.rela.toc)
|
||||||
|
*(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*)
|
||||||
|
*(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*)
|
||||||
|
*(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*)
|
||||||
|
*(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*)
|
||||||
|
*(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
|
||||||
|
}
|
||||||
|
|
||||||
/* Standard data sections */
|
/* Standard data sections */
|
||||||
. = ORIGIN(data);
|
. = ORIGIN(data);
|
||||||
|
|
||||||
.rodata ALIGN(256) : { *(.rodata .rodata.*) }
|
.rodata ALIGN(256) : { *(.rodata .rodata.*) } : hdr_srodata
|
||||||
.data ALIGN(256) : { *(.data) }
|
.data ALIGN(256) : { *(.data) } : hdr_sdata
|
||||||
.bss ALIGN(256) : { *(.bss) }
|
.bss ALIGN(256) : { *(.sbss) *(.bss) }
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
LIBPATHS := -L$(WUT_ROOT)/lib
|
LIBPATHS := -L$(WUT_ROOT)/lib
|
||||||
CFLAGS := -I$(WUT_ROOT)/include -fno-builtin -ffreestanding
|
CFLAGS := -I$(WUT_ROOT)/include -fno-builtin -ffreestanding
|
||||||
CXXFLAGS := $(CFLAGS)
|
CXXFLAGS := $(CFLAGS)
|
||||||
LDFLAGS := -nostdlib -nostartfiles $(WUT_ROOT)/lib/crt0.o -T $(WUT_ROOT)/rules/rpl.ld
|
LDFLAGS := -nostdlib -nostartfiles $(WUT_ROOT)/lib/crt0.o -T $(WUT_ROOT)/rules/rpl.ld -pie -fPIE
|
||||||
|
|
||||||
include $(WUT_ROOT)/rules/base.mk
|
include $(WUT_ROOT)/rules/base.mk
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user