I can't speak to EU regulations, but I imagine the FAA is the same.
121 and 135 (airline and charter) are required to clear all obstacles by 35' in the event of an engine failure.
Since it's an emergency situation you do not need to follow an ATC clearance. The operator pays a company like APG who has obstacle data at each airport, and they construct a departure path (for emergency use only) that is the least onerous (allowing the highest possible takeoff weights). Most of the time the path is runway track, or even to follow a SID to a certain fix then climb in a hold.
This is known at Runway Analysis.
Here are a couple videos on the subject, I hope that helps.