[Scummvm-git-logs] scummvm master -> b862b558224c91f4f5b818f0171baa536556f019

lephilousophe noreply at scummvm.org
Fri Jun 17 19:31:09 UTC 2022


This automated email contains information about 7 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
f60d229c78 PLUGINS: Implement R_ARM_PC24 relocations
052477ab7a PLUGINS: Allow use of commas in executable name
9a8ed07914 PLUGINS: Use host_os instead of backend to select PLUGIN_DIRECTORY
87f515a6e0 PLUGINS: Force export of __dso_handle
02808a019a RISCOS: Add an ELF plugin provider
f9e64f2293 RISCOS: Use OS_SynchroniseCodeAreas to flush the cache
b862b55822 RISCOS: Ensure that functions used by plugins can be found in the main executable


Commit: f60d229c7847f9d8e8cf602729ec3ec06c301468
    https://github.com/scummvm/scummvm/commit/f60d229c7847f9d8e8cf602729ec3ec06c301468
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-06-17T21:31:04+02:00

Commit Message:
PLUGINS: Implement R_ARM_PC24 relocations

These relocations are used in RiscOS even when using long calls.
As it's a relative relocation, nothing is to be done.

Changed paths:
    backends/plugins/elf/arm-loader.cpp
    backends/plugins/elf/elf32.h


diff --git a/backends/plugins/elf/arm-loader.cpp b/backends/plugins/elf/arm-loader.cpp
index 170ce8b7aa9..ca04e3ccdd3 100644
--- a/backends/plugins/elf/arm-loader.cpp
+++ b/backends/plugins/elf/arm-loader.cpp
@@ -75,6 +75,10 @@ bool ARMDLObject::relocate(Elf32_Off offset, Elf32_Word size, byte *relSegment)
 			}
 			break;
 
+		case R_ARM_PC24:
+//			debug(8, "elfloader: R_ARM_PC24: PC-relative jump, ld takes care of necessary relocation work for us.");
+			break;
+
 		case R_ARM_THM_CALL:
 //			debug(8, "elfloader: R_ARM_THM_CALL: PC-relative jump, ld takes care of necessary relocation work for us.");
 			break;
diff --git a/backends/plugins/elf/elf32.h b/backends/plugins/elf/elf32.h
index 054bef71d0b..27192c6eae1 100644
--- a/backends/plugins/elf/elf32.h
+++ b/backends/plugins/elf/elf32.h
@@ -227,6 +227,7 @@ typedef struct {
 
 // ARM relocation types
 #define R_ARM_NONE			0
+#define R_ARM_PC24			1
 #define R_ARM_ABS32			2
 #define R_ARM_THM_CALL		10
 #define R_ARM_CALL			28


Commit: 052477ab7ab01de0f0bf07deae25ebbb1b061d0d
    https://github.com/scummvm/scummvm/commit/052477ab7ab01de0f0bf07deae25ebbb1b061d0d
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-06-17T21:31:04+02:00

Commit Message:
PLUGINS: Allow use of commas in executable name

That's how RiscOS files store their type

Changed paths:
    configure


diff --git a/configure b/configure
index 5d6f3f84f30..d47a7705d13 100755
--- a/configure
+++ b/configure
@@ -4268,7 +4268,7 @@ if test "$_elf_loader" = yes; then
 	_plugin_suffix=".plg"
 	_mak_plugins='
 PLUGIN_EXTRA_DEPS	= $(EXECUTABLE)
-PLUGIN_LDFLAGS		= -nostartfiles backends/plugins/elf/version.o -Wl,-q,--just-symbols,$(EXECUTABLE),--retain-symbols-file,$(srcdir)/backends/plugins/elf/plugin.syms
+PLUGIN_LDFLAGS		= -nostartfiles backends/plugins/elf/version.o -Wl,-q,--retain-symbols-file,$(srcdir)/backends/plugins/elf/plugin.syms -Xlinker --just-symbols -Xlinker $(EXECUTABLE)
 PRE_OBJS_FLAGS		:= -Wl,--whole-archive
 POST_OBJS_FLAGS		:= -Wl,--no-whole-archive
 '"$_mak_plugins"


Commit: 9a8ed07914f35ea0218066cdbac72a35dd5ad742
    https://github.com/scummvm/scummvm/commit/9a8ed07914f35ea0218066cdbac72a35dd5ad742
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-06-17T21:31:04+02:00

Commit Message:
PLUGINS: Use host_os instead of backend to select PLUGIN_DIRECTORY

RiscOS uses SDL backend but needs a different PLUGIN_DIRECTORY

Changed paths:
    configure


diff --git a/configure b/configure
index d47a7705d13..6ab1d9b83eb 100755
--- a/configure
+++ b/configure
@@ -5996,7 +5996,7 @@ case $_host_os in
 		;;
 esac
 
-case $_backend in
+case $_host in
 	3ds)
 		append_var DEFINES "-DPLUGIN_DIRECTORY=\\\"$datadir/plugins\\\""
 		;;


Commit: 87f515a6e005bc1879e85b316f9892baa041647c
    https://github.com/scummvm/scummvm/commit/87f515a6e005bc1879e85b316f9892baa041647c
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-06-17T21:31:04+02:00

Commit Message:
PLUGINS: Force export of __dso_handle

Some toolchains (RiscOS) may not export it in certain conditions.
This list does not enforce the symbol to be here so it shouldn't fail
build on platforms without this symbol.

Changed paths:
    backends/plugins/elf/plugin.syms


diff --git a/backends/plugins/elf/plugin.syms b/backends/plugins/elf/plugin.syms
index 70465ae9762..97f9937f7a8 100644
--- a/backends/plugins/elf/plugin.syms
+++ b/backends/plugins/elf/plugin.syms
@@ -7,3 +7,4 @@ ___plugin_ctors
 ___plugin_ctors_end
 ___plugin_dtors
 ___plugin_dtors_end
+__dso_handle


Commit: 02808a019a3db1a14f7eee91532354f458ab6acd
    https://github.com/scummvm/scummvm/commit/02808a019a3db1a14f7eee91532354f458ab6acd
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-06-17T21:31:04+02:00

Commit Message:
RISCOS: Add an ELF plugin provider

This will allow do dynamically load plugins and not be limited by
24-bits relocations

Changed paths:
  A backends/plugins/riscos/plugin.cpp
  A backends/plugins/riscos/plugin.ld
  A backends/plugins/riscos/riscos-provider.cpp
  A backends/plugins/riscos/riscos-provider.h
    backends/module.mk
    backends/platform/sdl/riscos/riscos-main.cpp
    configure


diff --git a/backends/module.mk b/backends/module.mk
index 8f271af0952..3501fcca805 100644
--- a/backends/module.mk
+++ b/backends/module.mk
@@ -275,8 +275,13 @@ MODULE_OBJS += \
 	events/riscossdl/riscossdl-events.o \
 	fs/riscos/riscos-fs.o \
 	fs/riscos/riscos-fs-factory.o \
+	plugins/riscos/riscos-provider.o
+ifndef SDL_BACKEND
+# This is needed for null backend but already included in SDL backend
+MODULE_OBJS += \
 	platform/sdl/riscos/riscos-utils.o
 endif
+endif
 
 ifdef PLAYSTATION3
 MODULE_OBJS += \
diff --git a/backends/platform/sdl/riscos/riscos-main.cpp b/backends/platform/sdl/riscos/riscos-main.cpp
index 23a31bcb43d..04f81546005 100644
--- a/backends/platform/sdl/riscos/riscos-main.cpp
+++ b/backends/platform/sdl/riscos/riscos-main.cpp
@@ -24,7 +24,7 @@
 #if defined(RISCOS)
 
 #include "backends/platform/sdl/riscos/riscos.h"
-#include "backends/plugins/sdl/sdl-provider.h"
+#include "backends/plugins/riscos/riscos-provider.h"
 #include "base/main.h"
 
 int main(int argc, char *argv[]) {
@@ -37,7 +37,7 @@ int main(int argc, char *argv[]) {
 	g_system->init();
 
 #ifdef DYNAMIC_MODULES
-	PluginManager::instance().addPluginProvider(new SDLPluginProvider());
+	PluginManager::instance().addPluginProvider(new RiscOSPluginProvider());
 #endif
 
 	// Invoke the actual ScummVM main entry point
diff --git a/backends/plugins/riscos/plugin.cpp b/backends/plugins/riscos/plugin.cpp
new file mode 100644
index 00000000000..fa359584d94
--- /dev/null
+++ b/backends/plugins/riscos/plugin.cpp
@@ -0,0 +1,54 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#ifdef USE_ELF_LOADER
+
+/**
+ * These functions are a hack to workaround a GCC limitation
+ * At every function entry, GCC adds a check on the stack size
+ * If the stack is too small, the functions _rt_stkovf_split_small or _rt_stkovf_split_big are called
+ * This call is done using a PC relative 24 bits address but we want to link back to main executable functions
+ * and this is not possible using this relocation type.
+ * So we create wrapper functions which will just jump to the main function using a 32 bits relocation.
+ * The wrapping is done by ld thanks to its --wrap argument
+ */
+
+__asm__ (
+	".global __wrap___rt_stkovf_split_small\n"
+	".type __wrap___rt_stkovf_split_small, %function\n"
+	"__wrap___rt_stkovf_split_small:\n"
+	"LDR	pc, .Lsmall\n"
+	".Lsmall:\n"
+	".word	__real___rt_stkovf_split_small\n"
+);
+
+__asm__ (
+	".global __wrap___rt_stkovf_split_big\n"
+	".type __wrap___rt_stkovf_split_big, %function\n"
+	"__wrap___rt_stkovf_split_big:\n"
+	"LDR	pc, .Lbig\n"
+	".Lbig:\n"
+	".word	__real___rt_stkovf_split_big\n"
+);
+
+#endif
diff --git a/backends/plugins/riscos/plugin.ld b/backends/plugins/riscos/plugin.ld
new file mode 100644
index 00000000000..c20b452176d
--- /dev/null
+++ b/backends/plugins/riscos/plugin.ld
@@ -0,0 +1,221 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
+OUTPUT_ARCH(arm)
+ENTRY(_start)
+
+PHDRS
+{
+	/* ScummVM's elf loader only allows a single segment, at the moment. */
+	plugin PT_LOAD FLAGS(7) /* Read | Write | Execute */;
+}
+
+SECTIONS
+{
+	/* =========== CODE section =========== */
+
+	/* Start the output high in memory so PC-relative jumps from the plugin
+	    to the main binary cannot reach, to force the linker to generate
+	    veneers converting the relative jumps to absolute jumps */
+	. = 0x8000000;
+
+	.text ALIGN(0x1000) :
+	{
+		/* .text */
+		*(.text.unlikely .text.*_unlikely .text.unlikely.*)
+		*(.text.exit .text.exit.*)
+		*(.text.startup .text.startup.*)
+		*(.text.hot .text.hot.*)
+		*(.text .stub .text.* .gnu.linkonce.t.*)
+		/* .gnu.warning sections are handled specially by elf32.em.  */
+		*(.gnu.warning)
+		*(.glue_7t) *(.glue_7) *(.riscos.libscl.chunkstub.start) *(SORT(.riscos.libscl.chunkstub.id*)) *(.riscos.libscl.chunkstub.end)
+	} : plugin
+
+	/* =========== RODATA section =========== */
+
+	. = ALIGN(0x1000);
+
+	.rodata :
+	{
+		*(.rodata)
+		*(.rodata.*)
+		*(.gnu.linkonce.r*)
+		*(.rodata1)
+		. = ALIGN(4);
+	} : plugin
+	.rodata1 :
+	{
+		*(.rodata1)
+		. = ALIGN(4);
+	} : plugin
+
+	.ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } : plugin
+	__exidx_start = .;
+	ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } : plugin
+	__exidx_end = .;
+
+	/* =========== DATA section =========== */
+
+	. = ALIGN(0x1000);
+
+	.tdata ALIGN(4) :
+	{
+		*(.tdata)
+		*(.tdata.*)
+		*(.gnu.linkonce.td.*)
+		. = ALIGN(4);
+	} : plugin
+
+	.tbss ALIGN(4) :
+	{
+		*(.tbss)
+		*(.tbss.*)
+		*(.gnu.linkonce.tb.*)
+		*(.tcommon)
+		. = ALIGN(4);
+	} : plugin
+
+	.preinit_array ALIGN(4) :
+	{
+		PROVIDE (__preinit_array_start = .);
+		KEEP (*(.preinit_array))
+		PROVIDE (__preinit_array_end = .);
+	} : plugin
+
+	.init_array ALIGN(4) :
+	{
+		PROVIDE (__init_array_start = .);
+		KEEP (*(SORT(.init_array.*)))
+		KEEP (*(.init_array))
+		PROVIDE (__init_array_end = .);
+	} : plugin
+
+	.fini_array ALIGN(4) :
+	{
+		PROVIDE (__fini_array_start = .);
+		KEEP (*(.fini_array))
+		KEEP (*(SORT(.fini_array.*)))
+		PROVIDE (__fini_array_end = .);
+	} : plugin
+
+	.ctors ALIGN(4) :
+	{
+		___plugin_ctors = .;
+		KEEP (*(SORT(.ctors.*)))
+		KEEP (*(.ctors))
+		___plugin_ctors_end = .;
+	} : plugin
+
+	.dtors ALIGN(4) :
+	{
+		___plugin_dtors = .;
+		KEEP (*(SORT(.dtors.*)))
+		KEEP (*(.dtors))
+		___plugin_dtors_end = .;
+	} : plugin
+
+	.data :
+	{
+		*(.data)
+		*(.data.*)
+		*(.gnu.linkonce.d*)
+		CONSTRUCTORS
+		. = ALIGN(4);
+	} : plugin
+	.data1 :
+	{
+		*(.data1)
+		. = ALIGN(4);
+	} : plugin
+
+	__bss_start__ = .;
+	.bss ALIGN(4) :
+	{
+		*(.dynbss)
+		*(.bss)
+		*(SORT(.bss.*))
+		*(.gnu.linkonce.b*)
+		*(COMMON)
+		. = ALIGN(4);
+	} : plugin
+	__bss_end__ = .;
+
+	__end__ = ABSOLUTE(.) ;
+
+	/* ==================
+	   ==== Metadata ====
+	   ================== */
+
+	/* Discard sections that difficult post-processing */
+	/DISCARD/ : { *(.group .comment .note) }
+
+	/* Stabs debugging sections. */
+	.stab          0 : { *(.stab) }
+	.stabstr       0 : { *(.stabstr) }
+	.stab.excl     0 : { *(.stab.excl) }
+	.stab.exclstr  0 : { *(.stab.exclstr) }
+	.stab.index    0 : { *(.stab.index) }
+	.stab.indexstr 0 : { *(.stab.indexstr) }
+
+	/* DWARF debug sections.
+	   Symbols in the DWARF debugging sections are relative to the beginning
+	   of the section so we begin them at 0. */
+
+	/* DWARF 1 */
+	.debug          0 : { *(.debug) }
+	.line           0 : { *(.line) }
+
+	/* GNU DWARF 1 extensions */
+	.debug_srcinfo  0 : { *(.debug_srcinfo) }
+	.debug_sfnames  0 : { *(.debug_sfnames) }
+
+	/* DWARF 1.1 and DWARF 2 */
+	.debug_aranges  0 : { *(.debug_aranges) }
+	.debug_pubnames 0 : { *(.debug_pubnames) }
+
+	/* DWARF 2 */
+	.debug_info     0 : { *(.debug_info) }
+	.debug_abbrev   0 : { *(.debug_abbrev) }
+	.debug_line     0 : { *(.debug_line) }
+	.debug_frame    0 : { *(.debug_frame) }
+	.debug_str      0 : { *(.debug_str) }
+	.debug_loc      0 : { *(.debug_loc) }
+	.debug_macinfo  0 : { *(.debug_macinfo) }
+
+	/* SGI/MIPS DWARF 2 extensions */
+	.debug_weaknames 0 : { *(.debug_weaknames) }
+	.debug_funcnames 0 : { *(.debug_funcnames) }
+	.debug_typenames 0 : { *(.debug_typenames) }
+	.debug_varnames  0 : { *(.debug_varnames) }
+
+	/* DWARF 3 */
+	.debug_pubtypes 0 : { *(.debug_pubtypes) }
+	.debug_ranges   0 : { *(.debug_ranges) }
+
+	/* DWARF Extension.  */
+	.debug_macro    0 : { *(.debug_macro) }
+	.gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
+	.note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }
+
+	/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
+}
diff --git a/backends/plugins/riscos/riscos-provider.cpp b/backends/plugins/riscos/riscos-provider.cpp
new file mode 100644
index 00000000000..4ffa35bf22e
--- /dev/null
+++ b/backends/plugins/riscos/riscos-provider.cpp
@@ -0,0 +1,71 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+#include "common/scummsys.h"
+
+#if defined(DYNAMIC_MODULES) && defined(RISCOS)
+
+#include "backends/plugins/riscos/riscos-provider.h"
+#include "backends/plugins/elf/arm-loader.h"
+
+#include "common/debug.h"
+
+#include <kernel.h>
+#include <swis.h>
+
+typedef void (*Cache_CleanInvalidateRangePtr)(void *start, void *end);
+
+// This function enters in supervisor mode, call the ARMop and leaves the supervisor mode
+static void call_Cache_CleanInvalidateRange(void *start, void *end, Cache_CleanInvalidateRangePtr f) __asm__(".call_Cache_CleanInvalidateRange");
+__asm__(
+	".call_Cache_CleanInvalidateRange:\n"
+	"PUSH	{r4, lr}\n" // Backup r4 and lr
+	"MRS	r4, cpsr\n" // Backup CPSR in R4
+	"SWI    0x16\n" // OS_EnterOS
+	"MOV	lr, pc\n" //
+	"MOV	pc, r2\n" // Call 3rd argument (function pointer)
+	"MSR	cpsr_c, r4\n" // Restore CPSR (leave SVC mode)
+	"POP	{r4, pc}\n" // Restore R4 and return
+);
+
+
+class RiscOSDLObject : public ARMDLObject {
+protected:
+	void flushDataCache(void *ptr, uint32 len) const override {
+		Cache_CleanInvalidateRangePtr Cache_CleanInvalidateRange;
+
+		if (!_swix(OS_MMUControl, _IN(0)|_OUT(0), 2 | 21 << 8, &Cache_CleanInvalidateRange)) {
+			call_Cache_CleanInvalidateRange(ptr, (char *)ptr + len, Cache_CleanInvalidateRange);
+			return;
+		}
+
+		// OS_MMUControl 2 or Cache_CleanInvalidateRange are not supported: fallback to old inefficient OS_MMUControl 1
+		_swix(OS_MMUControl, _IN(0), 1 | 1 << 28 | 1 << 30 | 1 << 31);
+	}
+
+};
+
+Plugin *RiscOSPluginProvider::createPlugin(const Common::FSNode &node) const {
+	return new TemplatedELFPlugin<RiscOSDLObject>(node.getPath());
+}
+
+#endif // defined(DYNAMIC_MODULES) && defined(RISCOS)
diff --git a/backends/plugins/riscos/riscos-provider.h b/backends/plugins/riscos/riscos-provider.h
new file mode 100644
index 00000000000..171e7e9293f
--- /dev/null
+++ b/backends/plugins/riscos/riscos-provider.h
@@ -0,0 +1,36 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#if defined(DYNAMIC_MODULES) && defined(RISCOS)
+
+#ifndef BACKENDS_PLUGINS_RISCOS_PROVIDER_H
+#define BACKENDS_PLUGINS_RISCOS_PROVIDER_H
+
+#include "backends/plugins/elf/elf-provider.h"
+
+class RiscOSPluginProvider : public ELFPluginProvider {
+public:
+	Plugin *createPlugin(const Common::FSNode &node) const;
+};
+
+#endif // BACKENDS_PLUGINS_RISCOS_PROVIDER_H
+
+#endif // defined(DYNAMIC_MODULES) && defined(RISCOS)
diff --git a/configure b/configure
index 6ab1d9b83eb..284b9d5178a 100755
--- a/configure
+++ b/configure
@@ -4248,6 +4248,16 @@ POST_OBJS_FLAGS := -Wl,-no-whole-archive
 _mak_plugins='
 LDFLAGS				+= -Wl,-T$(srcdir)/backends/plugins/psp/main_prog.ld  -Wl,-zmax-page-size=128
 PLUGIN_LDFLAGS		+= -Wl,-T$(srcdir)/backends/plugins/psp/plugin.ld -Wl,-zmax-page-size=128 -lstdc++
+'
+		;;
+	riscos)
+		_elf_loader=yes
+		append_var DEFINES "-DELF_LOADER_CXA_ATEXIT"
+		append_var CXXFLAGS "-fuse-cxa-atexit"
+		append_var DEFINES "-DUNCACHED_PLUGINS"
+_mak_plugins='
+PLUGIN_EXTRA_DEPS	+= backends/plugins/riscos/plugin.o
+PLUGIN_LDFLAGS		+= -static -Wl,-T$(srcdir)/backends/plugins/riscos/plugin.ld backends/plugins/riscos/plugin.o -Wl,--wrap=__rt_stkovf_split_small -Wl,--wrap=__rt_stkovf_split_big
 '
 		;;
 	*)
@@ -6011,6 +6021,9 @@ case $_host in
 		# without a scummvm sub directory.
 		append_var DEFINES "-DPLUGIN_DIRECTORY=\\\"$libdir\\\""
 		;;
+	arm-*riscos)
+		append_var DEFINES "-DPLUGIN_DIRECTORY=\\\"\${datarootdir}/plugins\\\""
+		;;
 	*)
 		append_var DEFINES "-DPLUGIN_DIRECTORY=\\\"$libdir/scummvm\\\""
 		;;
@@ -6245,7 +6258,13 @@ case $_host_os in
 		fi
 		append_var CXXFLAGS "-ffunction-sections"
 		append_var CXXFLAGS "-fdata-sections"
-		append_var LDFLAGS "-Wl,--gc-sections"
+		if test "$_dynamic_modules" = no ; then
+			append_var LDFLAGS "-Wl,--gc-sections"
+		else
+			# toolchain asks for gc-sections
+			append_var LDFLAGS "-Wl,--no-gc-sections"
+			append_var CXXFLAGS "-mlong-calls"
+		fi
 		;;
 	n64)
 		# Move some libs down here, otherwise some symbols requires by libvorbis aren't found


Commit: f9e64f2293c852ba2b73d0ebc938a708da54d9df
    https://github.com/scummvm/scummvm/commit/f9e64f2293c852ba2b73d0ebc938a708da54d9df
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2022-06-17T21:31:04+02:00

Commit Message:
RISCOS: Use OS_SynchroniseCodeAreas to flush the cache

Changed paths:
    backends/plugins/riscos/riscos-provider.cpp


diff --git a/backends/plugins/riscos/riscos-provider.cpp b/backends/plugins/riscos/riscos-provider.cpp
index 4ffa35bf22e..d4b606f5c60 100644
--- a/backends/plugins/riscos/riscos-provider.cpp
+++ b/backends/plugins/riscos/riscos-provider.cpp
@@ -32,34 +32,16 @@
 #include <kernel.h>
 #include <swis.h>
 
-typedef void (*Cache_CleanInvalidateRangePtr)(void *start, void *end);
-
-// This function enters in supervisor mode, call the ARMop and leaves the supervisor mode
-static void call_Cache_CleanInvalidateRange(void *start, void *end, Cache_CleanInvalidateRangePtr f) __asm__(".call_Cache_CleanInvalidateRange");
-__asm__(
-	".call_Cache_CleanInvalidateRange:\n"
-	"PUSH	{r4, lr}\n" // Backup r4 and lr
-	"MRS	r4, cpsr\n" // Backup CPSR in R4
-	"SWI    0x16\n" // OS_EnterOS
-	"MOV	lr, pc\n" //
-	"MOV	pc, r2\n" // Call 3rd argument (function pointer)
-	"MSR	cpsr_c, r4\n" // Restore CPSR (leave SVC mode)
-	"POP	{r4, pc}\n" // Restore R4 and return
-);
-
-
 class RiscOSDLObject : public ARMDLObject {
 protected:
 	void flushDataCache(void *ptr, uint32 len) const override {
-		Cache_CleanInvalidateRangePtr Cache_CleanInvalidateRange;
+		_kernel_swi_regs regs;
 
-		if (!_swix(OS_MMUControl, _IN(0)|_OUT(0), 2 | 21 << 8, &Cache_CleanInvalidateRange)) {
-			call_Cache_CleanInvalidateRange(ptr, (char *)ptr + len, Cache_CleanInvalidateRange);
-			return;
-		}
+		regs.r[0] = 1;
+		regs.r[1] = (int)ptr;
+		regs.r[2] = (int)ptr + len;
 
-		// OS_MMUControl 2 or Cache_CleanInvalidateRange are not supported: fallback to old inefficient OS_MMUControl 1
-		_swix(OS_MMUControl, _IN(0), 1 | 1 << 28 | 1 << 30 | 1 << 31);
+		_kernel_swi(OS_SynchroniseCodeAreas, &regs, &regs);
 	}
 
 };


Commit: b862b558224c91f4f5b818f0171baa536556f019
    https://github.com/scummvm/scummvm/commit/b862b558224c91f4f5b818f0171baa536556f019
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2022-06-17T21:31:04+02:00

Commit Message:
RISCOS: Ensure that functions used by plugins can be found in the main executable

Changed paths:
    backends/plugins/riscos/riscos-provider.cpp


diff --git a/backends/plugins/riscos/riscos-provider.cpp b/backends/plugins/riscos/riscos-provider.cpp
index d4b606f5c60..0e2d5de61a2 100644
--- a/backends/plugins/riscos/riscos-provider.cpp
+++ b/backends/plugins/riscos/riscos-provider.cpp
@@ -32,6 +32,30 @@
 #include <kernel.h>
 #include <swis.h>
 
+// HACK: This is needed so that standard library functions that are only
+// used in plugins can be found in the main executable.
+void pluginHack() {
+	volatile float f = 0.0f;
+	volatile double d = 0.0;
+
+	byte *b = new (std::nothrow) byte[100];
+
+	f = tanhf(f);
+	f = logf(f);
+	f = lroundf(f);
+	f = frexpf(f, NULL);
+	f = ldexpf(f, 1);
+	f = fmaxf(f, f);
+	f = fminf(f, f);
+	f = truncf(f);
+
+	d = nearbyint(d);
+
+	rename("dummyA", "dummyB");
+
+	delete[] b;
+}
+
 class RiscOSDLObject : public ARMDLObject {
 protected:
 	void flushDataCache(void *ptr, uint32 len) const override {




More information about the Scummvm-git-logs mailing list