From 0a7a0ef857ad097e4fc6ca3ae23b899702b37242 Mon Sep 17 00:00:00 2001 From: Princess-of-Sleeping <29831892+Princess-of-Sleeping@users.noreply.github.com> Date: Mon, 4 Jan 2021 18:28:29 +0900 Subject: [PATCH] Fix vita elf vaddr and size (#78) * Create 0003-fix-elf-vaddr.patch * Fixed temporary elf size for vita. Related to this issue : https://github.com/vitasdk/vita-toolchain/issues/150 * Add 0003-fix-elf-vaddr.patch for binutils * Remove comment --- CMakeLists.txt | 1 + patches/binutils/0001-vita.patch | 21 ++++++++++++++------- patches/binutils/0003-fix-elf-vaddr.patch | 12 ++++++++++++ 3 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 patches/binutils/0003-fix-elf-vaddr.patch diff --git a/CMakeLists.txt b/CMakeLists.txt index 09ea2da..d12187f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -303,6 +303,7 @@ function(toolchain_deps toolchain_deps_dir toolchain_install_dir toolchain_suffi PATCH_COMMAND patch -d -p3 -t -N < ${PROJECT_SOURCE_DIR}/patches/binutils/0001-vita.patch && patch -d -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/binutils/0002-fix-broken-reloc.patch + && patch -d -p3 -t -N < ${PROJECT_SOURCE_DIR}/patches/binutils/0003-fix-elf-vaddr.patch CONFIGURE_COMMAND ${compiler_flags} ${wrapper_command} /configure --build=${build_native} --host=${toolchain_host} diff --git a/patches/binutils/0001-vita.patch b/patches/binutils/0001-vita.patch index a88eb54..a90a5f0 100644 --- a/patches/binutils/0001-vita.patch +++ b/patches/binutils/0001-vita.patch @@ -1,12 +1,19 @@ diff -Nru a/src/binutils/ld/scripttempl/elf.sc b/src/binutils/ld/scripttempl/elf.sc ---- a/src/binutils/ld/scripttempl/elf.sc 2018-07-11 17:43:55.000000000 +0200 -+++ b/src/binutils/ld/scripttempl/elf.sc 2018-12-29 19:53:29.747662203 +0100 -@@ -580,6 +580,8 @@ - ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} - ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};}} - +--- a/src/binutils/ld/scripttempl/elf.sc ++++ b/src/binutils/ld/scripttempl/elf.sc +@@ -579,7 +579,25 @@ + ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR-${DATA_SEGMENT_ALIGN}};}}} + ${CREATE_SHLIB+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};} + ${CREATE_PIE+. = ${SHLIB_DATA_ADDR-${DATA_SEGMENT_ALIGN}};} +- ++ /* SCE self module info size */ ++ . = . + 0x5C; ++ /* SCE self module_proc_param size */ ++ . = . + 0x34; ++ /* SCE self info rsvd size(import table, etc...) */ ++ . = . + 0x7000; + /* Hacky hackity hack. Need this because otherwise data segment is not aligned enough. */ -+ . = ALIGN(0x10000); ++ . = ALIGN(0x8000); /* Exception handling */ .eh_frame ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) ${RELOCATING+*(.eh_frame.*)} } .gnu_extab ${RELOCATING-0} : ONLY_IF_RW { *(.gnu_extab) } diff --git a/patches/binutils/0003-fix-elf-vaddr.patch b/patches/binutils/0003-fix-elf-vaddr.patch new file mode 100644 index 0000000..15e98ac --- /dev/null +++ b/patches/binutils/0003-fix-elf-vaddr.patch @@ -0,0 +1,12 @@ +diff -Nru a/src/binutils/ld/emulparams/armelf.sh b/src/binutils/ld/emulparams/armelf.sh +--- a/src/binutils/ld/emulparams/armelf.sh ++++ b/src/binutils/ld/emulparams/armelf.sh +@@ -3,7 +3,7 @@ + OUTPUT_FORMAT="elf32-littlearm" + BIG_OUTPUT_FORMAT="elf32-bigarm" + LITTLE_OUTPUT_FORMAT="elf32-littlearm" +-TEXT_START_ADDR=0x8000 ++TEXT_START_ADDR=0x81000000 + TEMPLATE_NAME=elf + EXTRA_EM_FILE=armelf + OTHER_TEXT_SECTIONS='*(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)'