Shock absorber linkage design
You could do this with drivers and a bit of Pythagoras. 


Construct your bars and linkage in the fully extended position:





The origins of both bars, Bar_L, Bar_R are at the centers of their sliding pivots,
the centers of the large circles
The central Link (pink) is at World 0
All parented to an Empty,(the square) so all coordinates can be measured in the Empty's space, and everything transformed as a group.


Both bars are given a Locked Track constraint, aiming their X / -X at the link object:



To set up a driver, right-click in the X location field of one of the bars in the 3D View > N Properties region > 'Item' tab, and select 'Add Driver'. You have the option to open a Driver Editor on the selected object.

You can also set any split-off pane in the interface to be a Driver Editor with the Editor Type dropdown in its header.



There will be other ways of doing this, I'm sure. This way is prone to a bit of numerical error, but maybe it's good enough? 

EDIT in response to query..

If, say, you wanted the left bar tip to slide along X while the right remains stationary, then you could drive the Empty to translate the whole rig to compensate for the inward/outward movement of the right tip. For instance, the Empty could be driven to be halfway between whatever other parts were squeezing the joint open and closed. Is that what you'd like?

.. This can be done with an IK chain, see other answer.