Here is Octave code which produces the same covariance values as gretl:
degrees_of_freedom = cases-predictors;
coefficients = pinv(IV)*DV;
estimates = IV*coefficients;
residuals = DV-estimates;
SSres = residuals'*residuals;
residual_variance = SSres/degrees_of_freedom;
N=IV'*IV;
Ni=inv(N);
covariance_matrix = Ni*residual_variance;