Mine looked like that, too. Thanks to windshield replacement goons with no talent/knowledge. The dealership dweebs didn't have a clue how to replace the trim, either. Armed with the FSM, I managed to fix it.
Pull the rivet-cover strip out from inside the channel of the trim piece you are looking at to expose the rivets. It's little more than a strip of flexible plastic/rubber with a little shoulder on one side.
Drill the rivets out, 5/32" bit. Remove the trim piece. If it's still stuck to the roof a little, slip a strand of fishing line in there to cut through the adhesive. Protect the paint with some masking tape. Be careful not to bend it if it's a bit stuck to the A-pillar because of excess windshield sealant. Clean all the adhesive/tape/crap and whatever off the piece of windshield trim and the channel it sits in. You may have to re-bend it a little to match the contour of the A-pillar to roof line, but it's easy. Dry fit until you are satisfied. I used some automotive trim adhesive in the channel on the roof and on the corresponding part of the trim piece (or use double sided tape made for the same purpose--I read that Permatex makes some that isn't foam/thick) and put it back in place. Re-attach the part along the windshield with the appropriate sized rivets and work the flimsy looking rivet-covering strip into the channel. Step back and admire your work.
Tip: the tip of my rivet gun was too fat to fit in the channel and seat the rivet. So, I made a short (1/4" or so) spacer sleeve to go between the rivet flange and the tip of the gun so the rivet would seat and the rivet tool would still pull the stem of the pop rivet. Protect the windshield with a piece of cardboard while you are installing the rivets.
That windshield trim is expensive, so it pays to reuse it. When it comes time for another windshield, I'll remove and re-install those pieces so the glass guys don't have the chance to screw it up.
Galen