How to merge primary partition with 'Free Space', when there is a Linux ext4 partition between them?
If you hesitate to dd partitions or backup and restore your data with Time Machine, you may convert the first OS X partition of your disk to a Physical Volume and create a Logical Volume Group. After creating a second partition in the free space you can add it to your LVG and expand your current Logical Volume.

The approach is similar to a Fusion Drive (two Physical Volumes -> one Logical Volume Group/Logical Volume) however using only one disk.


Boot to Macintosh HD
Attach a backup drive and use Time Machine to backup Macintosh HD.
Detach the backup drive
Open Disk Utility and add a JHFS+ partition in the free space (~500 GB)
Enter diskutil list to list all partitions
Enter diskutil cs convert /dev/disk0s2 to convert your main volume to CoreStorage
Enter diskutil cs list to get all CoreStorage items 
Enter diskutil cs addDisk lvgUUID diskYsZ to add the new empty 500 GB partition as Physical Volume to the Logical Volume Group. 

lvgUUID is the UUID of the Logical Volume Group, diskYsZ is the disk identifier of the empty partition 500 GB partition (probably disk0s6). The content of the partition will be destroyed!
Enter diskutil cs resizeVolume lvUUID size to extend Macintosh HD.

lvUUID is the UUID of the Logical Volume, size: size in t, g, m, k or b (in your case ~850g. If you get an error regarding missing space use a slightly smaller size like 849g).
Enter diskutil verifyDisk disk0 and diskutil verifyVolume disk0s2.


The pros:

it's fast; it takes about 3 minutes.

The cons:

your CoreStorage LVG is non-contiguous and "fragmented".