From e0f2125068a2c3e3a2c3fc15e484691b349554a7 Mon Sep 17 00:00:00 2001 From: shinyquagsire23 Date: Wed, 28 Sep 2016 23:50:17 -0600 Subject: [PATCH] Move rodata into text so that jump tables work properly without -fno-jump-tables --- rules/ppc.mk | 2 +- rules/rpl.ld | 9 +++------ rules/rpl.mk | 2 +- tools/elf2rpl/main.cpp | 3 +++ 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rules/ppc.mk b/rules/ppc.mk index 76447fa..642cb91 100644 --- a/rules/ppc.mk +++ b/rules/ppc.mk @@ -1,5 +1,5 @@ LIBPATHS := -L$(WUT_ROOT)/lib -CFLAGS := -I$(WUT_ROOT)/include -fno-builtin -ffreestanding -fno-jump-tables -std=c11 +CFLAGS := -I$(WUT_ROOT)/include -fno-builtin -ffreestanding -std=c11 CXXFLAGS := $(CFLAGS) LDFLAGS := -nostdlib -nostartfiles diff --git a/rules/rpl.ld b/rules/rpl.ld index 9062a03..cc4d289 100644 --- a/rules/rpl.ld +++ b/rules/rpl.ld @@ -32,6 +32,9 @@ SECTIONS { /* .text */ *(.text) *(.text.*) + *(.rodata .rodata.*) + *(.gnu.linkonce.r.*) + *(.rodata1) *(.glue_7) *(.glue_7t) *(.stub) @@ -52,12 +55,6 @@ SECTIONS { /* Standard data sections */ . = ORIGIN(data); - .rodata ALIGN(256) : { - *(.rodata .rodata.*) - *(.gnu.linkonce.r.*) - } : hdr_sdata - .rodata1 : { *(.rodata1) } - .data ALIGN(256) : { *(.data) *(.data.*) diff --git a/rules/rpl.mk b/rules/rpl.mk index 2f079a6..b1fae58 100644 --- a/rules/rpl.mk +++ b/rules/rpl.mk @@ -1,5 +1,5 @@ LIBPATHS := -L$(WUT_ROOT)/lib -L$(DEVKITPPC)/lib -CFLAGS := -I$(WUT_ROOT)/include -fno-builtin -ffreestanding -fno-jump-tables +CFLAGS := -I$(WUT_ROOT)/include -fno-builtin -ffreestanding CXXFLAGS := $(CFLAGS) LDFLAGS := -nostartfiles -T $(WUT_ROOT)/rules/rpl.ld -pie -fPIE -z common-page-size=64 -z max-page-size=64 -lcrt \ -Wl,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size \ diff --git a/tools/elf2rpl/main.cpp b/tools/elf2rpl/main.cpp index dd5afcd..81e13b0 100644 --- a/tools/elf2rpl/main.cpp +++ b/tools/elf2rpl/main.cpp @@ -441,6 +441,9 @@ read(ElfFile &file, const std::string &filename) } else if (addend >= DataAddress && addend < WiiuLoadAddress) { relocation->symbol = findSymbol(file, DataAddress); relocation->addend = addend - DataAddress; + } else if (addend >= CodeAddress && addend < DataAddress) { + relocation->symbol = findSymbol(file, CodeAddress); + relocation->addend = addend - CodeAddress; } else { // If we can't find a proper symbol, write the addend in and hope for the best auto ptr = getLoaderDataPtr(inSections, rela.offset);