Right now,you have to gain his trust

It´s ok to spoil him and help him understand that you arent a threat,but at the same time he needs some structure and some education...they apreciate that.
I´d be as positive as possible about training.Try not to yell at him or make him feel uncomfortable etc.
I rescued a dog that came with tons of issues.His previous owner had beaten him alot so he had serious trust issues too.He would pee himself if anyone raised their voice (not at him,just in general),he´d poop and gulp it down as if trying to hide it (I think he had been hit for pooping indoors) and he would hide if we called him etc.The poor thing was a mess.
It took a while,but eventually he started coming out of his shell and he was a fantastic dog
Try not to feel sorry for him,pitty doesnt help

Be strong for him,love him to bits and give him some time,he´ll come around

Good luck!