Thank you for the suggestions
In the meantime I have been able to perform the upgrade by using scripts generated with 'Firebird SQL Studio' (via 'extract metadata' tool). For stored procedures such a script contains a first part in which all our stored procedures are created as 'empty' procedures (without a 'body'), for example:
CREATE PROCEDURE MyProcedure(...) RETURNS (...) AS
BEGIN
SUSPEND;
EXIT;
END ^
In a second part all 'bodies' are added. (The same for triggers, but unfortunately there was no section in that script that created triggers with 'empty' bodies, so I made these manually, which was doable because of the limited number of dependencies we have in triggers; Constraints and views only contained a handful of dependencies, so that was also no problem)
That way I relatively easily put together a script that removed all BIN_AND/BIN_OR dependencies, and a second one to add back the bodies of SPs and triggers, and the handful of constraints and views. After running the first script on the 2.5 database, I could delete the BIN_AND and BIN_OR external functions. Running the second script on the database (restored in firebird 4), added all the SPs, trigger,... implementations again.