Skip to content

Commit

Permalink
Fix vita elf vaddr and size (#78)
Browse files Browse the repository at this point in the history
* Create 0003-fix-elf-vaddr.patch

* Fixed temporary elf size for vita.

Related to this issue : vitasdk/vita-toolchain#150

* Add 0003-fix-elf-vaddr.patch for binutils

* Remove comment
  • Loading branch information
Princess-of-Sleeping authored Jan 4, 2021
1 parent 9bdfd12 commit 0a7a0ef
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ function(toolchain_deps toolchain_deps_dir toolchain_install_dir toolchain_suffi
PATCH_COMMAND
patch -d <SOURCE_DIR> -p3 -t -N < ${PROJECT_SOURCE_DIR}/patches/binutils/0001-vita.patch
&& patch -d <SOURCE_DIR> -p1 -t -N < ${PROJECT_SOURCE_DIR}/patches/binutils/0002-fix-broken-reloc.patch
&& patch -d <SOURCE_DIR> -p3 -t -N < ${PROJECT_SOURCE_DIR}/patches/binutils/0003-fix-elf-vaddr.patch
CONFIGURE_COMMAND ${compiler_flags} ${wrapper_command} <SOURCE_DIR>/configure
--build=${build_native}
--host=${toolchain_host}
Expand Down
21 changes: 14 additions & 7 deletions patches/binutils/0001-vita.patch
Original file line number Diff line number Diff line change
@@ -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) }
12 changes: 12 additions & 0 deletions patches/binutils/0003-fix-elf-vaddr.patch
Original file line number Diff line number Diff line change
@@ -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)'

0 comments on commit 0a7a0ef

Please sign in to comment.